

Merge pull request #24 from HarvestX/teleop_turtlesim
Create teleop_turtlesim.launch.py
@3606e6a222e025686040a2cf1a72057385453a30
+++ p9n_bringup/launch/teleop_turtlesim.launch.py
... | ... | @@ -0,0 +1,71 @@ |
1 | +# Copyright 2023 HarvestX Inc. | |
2 | +# | |
3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | +# you may not use this file except in compliance with the License. | |
5 | +# You may obtain a copy of the License at | |
6 | +# | |
7 | +# http://www.apache.org/licenses/LICENSE-2.0 | |
8 | +# | |
9 | +# Unless required by applicable law or agreed to in writing, software | |
10 | +# distributed under the License is distributed on an "AS IS" BASIS, | |
11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | +# See the License for the specific language governing permissions and | |
13 | +# limitations under the License. | |
14 | + | |
15 | +from launch import LaunchDescription | |
16 | +from launch.actions import DeclareLaunchArgument | |
17 | +from launch.substitutions import LaunchConfiguration | |
18 | +from launch.substitutions import TextSubstitution | |
19 | +from launch_ros.actions import ComposableNodeContainer, Node | |
20 | +from launch_ros.descriptions import ComposableNode | |
21 | + | |
22 | + | |
23 | +def generate_launch_description(): | |
24 | + """Generate launch description.""" | |
25 | + hw_type_arg = DeclareLaunchArgument( | |
26 | + 'hw_type', default_value=TextSubstitution(text='DualSense')) | |
27 | + topic_name_arg = DeclareLaunchArgument( | |
28 | + 'topic_name', default_value=TextSubstitution(text='/turtle1/cmd_vel')) | |
29 | + | |
30 | + joy_container = ComposableNodeContainer( | |
31 | + name='joy_container', | |
32 | + package='rclcpp_components', | |
33 | + executable='component_container', | |
34 | + namespace='', | |
35 | + composable_node_descriptions=[ | |
36 | + ComposableNode( | |
37 | + package='joy', | |
38 | + plugin='joy::Joy', | |
39 | + name='joy', | |
40 | + namespace='', | |
41 | + ), | |
42 | + ComposableNode( | |
43 | + package='p9n_node', | |
44 | + plugin='p9n_node::TeleopTwistJoyNode', | |
45 | + name='teleop_twist_joy_node', | |
46 | + namespace='', | |
47 | + parameters=[{ | |
48 | + 'hw_type': LaunchConfiguration('hw_type') | |
49 | + }], | |
50 | + remappings=[ | |
51 | + ('cmd_vel', LaunchConfiguration('topic_name')) | |
52 | + ], | |
53 | + ) | |
54 | + ], | |
55 | + ) | |
56 | + | |
57 | + turtlesim = Node( | |
58 | + name='turtlesim', | |
59 | + package='turtlesim', | |
60 | + executable='turtlesim_node' | |
61 | + ) | |
62 | + | |
63 | + ld = LaunchDescription() | |
64 | + | |
65 | + ld.add_action(hw_type_arg) | |
66 | + ld.add_action(topic_name_arg) | |
67 | + | |
68 | + ld.add_action(joy_container) | |
69 | + ld.add_action(turtlesim) | |
70 | + | |
71 | + return ld |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?