|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +# Copyright 2024 Clearpath Robotics, Inc. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# @author Hilary Luo ([email protected]) |
| 18 | + |
| 19 | +from launch import LaunchDescription |
| 20 | +from launch.actions.declare_launch_argument import DeclareLaunchArgument |
| 21 | +from launch.substitutions import LaunchConfiguration |
| 22 | +from launch_ros.actions import Node |
| 23 | + |
| 24 | + |
| 25 | +def generate_launch_description(): |
| 26 | + namespaces = ['tb21', 'tb10'] |
| 27 | + # namespaces = LaunchConfiguration('namespaces') |
| 28 | + |
| 29 | + # arg_namespaces = DeclareLaunchArgument( |
| 30 | + # 'namespaces', |
| 31 | + # default_value='[tb10, tb11]') |
| 32 | + |
| 33 | + ffmpeg_nodes = [] |
| 34 | + |
| 35 | + for i, ns in enumerate(namespaces): |
| 36 | + ffmpeg_nodes.append( |
| 37 | + Node( |
| 38 | + package='image_transport', |
| 39 | + executable='republish', |
| 40 | + name=f'ffmpeg_decoder{i}', |
| 41 | + remappings=[ |
| 42 | + ('in/ffmpeg', f'/{ns}/oakd/rgb/preview/encoded/ffmpeg'), |
| 43 | + ('out', f'/{ns}/oakd/rgb/preview/ffmpeg_decoded')], |
| 44 | + arguments=['ffmpeg', 'raw'], |
| 45 | + ) |
| 46 | + ) |
| 47 | + |
| 48 | + display_node = Node( |
| 49 | + package='turtlebot4_vision_tutorials', |
| 50 | + executable='pose_display', |
| 51 | + name='pose_display', |
| 52 | + parameters=[{'namespaces': namespaces}], |
| 53 | + |
| 54 | + ) |
| 55 | + |
| 56 | + ld = LaunchDescription() |
| 57 | + # ld.add_action(arg_namespaces) |
| 58 | + for n in ffmpeg_nodes: |
| 59 | + ld.add_action(n) |
| 60 | + ld.add_action(display_node) |
| 61 | + |
| 62 | + return ld |
0 commit comments