-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Modified Twist imports to work with Jazzy. Also added Joy Teleop #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: jazzy
Are you sure you want to change the base?
Changes from all commits
579e06e
3950a8e
d3253e0
afca8af
5c25d36
33f0dd8
f1d02f4
c5522a5
2de8205
d93f505
107b6c7
501a3fc
94f40f6
2d39e36
de213b8
23a4906
bfce208
5b9d8a1
02441cf
e1b0ec6
769be3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,3 +60,7 @@ build-*/ | |
| *.gch | ||
| /.project | ||
| .DS_Store | ||
| .vscode/ | ||
| log/ | ||
| build/ | ||
| install/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import os | ||
| from ament_index_python.packages import get_package_share_directory | ||
| from launch import LaunchDescription | ||
| from launch.substitutions import Command | ||
| from launch_ros.actions import Node | ||
|
|
||
| def generate_launch_description(): | ||
|
|
||
| TURTLEBOT3_MODEL = os.environ.get('TURTLEBOT3_MODEL', 'burger') | ||
|
|
||
| urdf_file = os.path.join( | ||
| get_package_share_directory('turtlebot3_description'), | ||
| 'urdf', | ||
| f'turtlebot3_{TURTLEBOT3_MODEL}.urdf' | ||
| ) | ||
|
|
||
| rviz_config_file = os.path.join( | ||
| get_package_share_directory('turtlebot3_description'), | ||
| 'rviz', | ||
| 'model.rviz' | ||
| ) | ||
|
|
||
| return LaunchDescription([ | ||
| Node( | ||
| package='robot_state_publisher', | ||
| executable='robot_state_publisher', | ||
| output='screen', | ||
| parameters=[{ | ||
| 'robot_description': Command(['xacro ', urdf_file]) | ||
| }] | ||
| ), | ||
|
|
||
| Node( | ||
| package='joint_state_publisher_gui', | ||
| executable='joint_state_publisher_gui', | ||
| output='screen' | ||
| ), | ||
|
|
||
| Node( | ||
| package='rviz2', | ||
| executable='rviz2', | ||
| arguments=['-d', rviz_config_file], | ||
| output='screen' | ||
| ), | ||
| ]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /**: | ||
| ros__parameters: | ||
| axis_linear: | ||
| x: 1 | ||
| axis_angular: | ||
| yaw: 3 | ||
| publish_stamped_twist: true | ||
| scale_linear: | ||
| x: 0.5 | ||
| scale_angular: | ||
| yaw: 0.5 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from launch import LaunchDescription | ||
| from launch_ros.actions import Node | ||
| from launch.actions import IncludeLaunchDescription | ||
| from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
| from launch.substitutions import PathJoinSubstitution | ||
| from launch_ros.substitutions import FindPackageShare | ||
|
|
||
|
|
||
| def generate_launch_description(): | ||
|
|
||
| # Include the robot bringup launch file | ||
| robot_bringup = IncludeLaunchDescription( | ||
| PythonLaunchDescriptionSource([ | ||
| PathJoinSubstitution([ | ||
| FindPackageShare('turtlebot3_bringup'), | ||
| 'launch', | ||
| 'robot.launch.py' | ||
| ]) | ||
| ]) | ||
| ) | ||
|
|
||
| # Joy node to read joystick | ||
| joy_node = Node( | ||
| package='joy', | ||
| executable='joy_node', | ||
| name='joy_node' | ||
| ) | ||
|
|
||
| # Teleop node to convert joy to cmd_vel | ||
| teleop_node = Node( | ||
| package='teleop_twist_joy', | ||
| executable='teleop_node', | ||
| name='teleop_twist_joy_node', | ||
| parameters=[PathJoinSubstitution([ | ||
| FindPackageShare('turtlebot3_teleop'), | ||
| 'config', | ||
| 'joy_teleop.yaml' | ||
| ])] | ||
| ) | ||
|
Comment on lines
+30
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better reusability and to avoid hardcoding, it's recommended to define these parameters in a separate YAML configuration file. This allows users to easily adapt the joystick configuration without modifying the launch file. You could create a # Teleop node to convert joy to cmd_vel
teleop_node = Node(
package='teleop_twist_joy',
executable='teleop_node',
name='teleop_twist_joy_node',
parameters=[PathJoinSubstitution([
FindPackageShare('turtlebot3_bringup'),
'param',
'joy_teleop.yaml'
])]
)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this one. I would put the .yaml file in the config folder to keep it consistent however. |
||
|
|
||
| return LaunchDescription([ | ||
| robot_bringup, | ||
| joy_node, | ||
| teleop_node | ||
| ]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using
TwistStampedmessages, it's crucial to populate theheaderfield, especially the timestamp, before publishing. This allows other nodes to know when the command was issued. You should update the timestamp every time you are about to publish the message.Additionally, it would be good practice to set the
frame_idin the__init__method, for example:self.twist.header.frame_id = 'base_link'.