-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tier4_perception_launch): enable to use multi camera on traffic …
…light recognition (#8676) * main process Signed-off-by: MasatoSaeki <[email protected]> * style(pre-commit): autofix * add exception if input is invalid Signed-off-by: MasatoSaeki <[email protected]> --------- Signed-off-by: MasatoSaeki <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d57f82d
commit edb4179
Showing
6 changed files
with
360 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ception_launch/launch/traffic_light_recognition/traffic_light_camera_info_relay.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Copyright 2024 TIER IV, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import launch | ||
from launch.actions import DeclareLaunchArgument | ||
from launch.actions import GroupAction | ||
from launch.actions import OpaqueFunction | ||
from launch.substitutions import LaunchConfiguration | ||
from launch_ros.actions import Node | ||
from launch_ros.actions import PushRosNamespace | ||
import yaml | ||
|
||
|
||
def create_traffic_light_camera_info_relay(namespace): | ||
relay_node = Node( | ||
package="topic_tools", | ||
executable="relay", | ||
name="traffic_light_camera_info_relay", | ||
arguments=[f"/sensing/camera/{namespace}/camera_info", "camera_info"], | ||
) | ||
|
||
group = GroupAction( | ||
[ | ||
PushRosNamespace(namespace), | ||
relay_node, | ||
] | ||
) | ||
|
||
return group | ||
|
||
|
||
def launch_setup(context, *args, **kwargs): | ||
# Load all camera namespaces | ||
all_camera_namespaces = LaunchConfiguration("all_camera_namespaces").perform(context) | ||
|
||
# Convert string to list | ||
all_camera_namespaces = yaml.load(all_camera_namespaces, Loader=yaml.FullLoader) | ||
if not isinstance(all_camera_namespaces, list): | ||
raise ValueError( | ||
"all_camera_namespaces is not a list. You should declare it like `['camera6', 'camera7']`." | ||
) | ||
if not all((isinstance(v, str) for v in all_camera_namespaces)): | ||
raise ValueError( | ||
"all_camera_namespaces is not a list of strings. You should declare it like `['camera6', 'camera7']`." | ||
) | ||
|
||
# Create containers for all cameras | ||
traffic_light_recognition_containers = [ | ||
create_traffic_light_camera_info_relay(namespace) for namespace in all_camera_namespaces | ||
] | ||
return traffic_light_recognition_containers | ||
|
||
|
||
def generate_launch_description(): | ||
return launch.LaunchDescription( | ||
[ | ||
DeclareLaunchArgument("all_camera_namespaces", description="camera namespace list"), | ||
OpaqueFunction(function=launch_setup), | ||
] | ||
) |
Oops, something went wrong.