[Notice] Nav2 Migrated to TwistStamped to replace Twist for cmd_vel Topics

Hi all,

Your Friendly Neighborhood Navigator here!

I wanted to announce a key breaking change in Nav2: We have now migrated away from Twist in favor of TwistStamped for all cmd_vel and related topics!

This was a change motivated for several reasons, including the Aerial community’s interest in working with command velocities in various reference frames, as well as AMR applications wanting a stamp to reject stale velocity commands in the header.

We started this process earlier this year, but selected to not make it default in Nav2 for Jazzy due to its LTS nature. Since Kilted is non-LTS, this is a nice staging distribution to … break … folks and start the Nav2 adjacent and robot hardware packages’ migrations.

If you are one such broken item, the migration is very straight forward. Good news! We have some utility functions you can leverage that we use across Nav2 that makes it easy to switch: a Twist Publisher and Twist Subscriber. It then also sets a standard parameter name (enable_stamped_cmd_vel) that is used across the board for toggling between Twist and Twist Stamped messages. In the migration, we simple switched them from false to true and made the appropriate updates in the simulation / hardware cmd_vel subscriptions. At some point in the distant future, we may depreciate Twist in favor of solely TwistStamped, but that would be many years away.

I have also filed tickets in the related ecosystem packages I could think of:

If I missed anyone, please let them know! We’ve also updated Nav2’s documentation on this in our Migration Guide with examples of how to migrate Gazebo (spoiler: easy). If you would not like to use TwistStamped, you can set enable_stamped_cmd_vel: false for all nodes in Nav2 and it should continue to use Twist.

Let us know if you have any issues, questions, or comments!

Happy twisting!

Steve Macenski

12 Likes

The toggle is a great idea!

1 Like

hi . i use “enable_stamped_cmd_vel: true” in nav2_params.yaml and add to parameters navigation lunch file but still cmd_vel_nav type is “twist” not “twiststamped” . my ros is jazzy .

Which node? Perhaps share a branch to reproduce this?

1 Like

I was able to do it with enable_stamped_cmd_vel : true

twist_mux:
ros__parameters:
topics:
navigation:
topic : cmd_vel_nav

twist_mux_params = os.path.join(get_package_share_directory(‘gg_gazebo’),‘config’,‘twist_mux.yaml’)
twist_mux = Node(
package=“twist_mux”,
executable=“twist_mux”,
parameters=[twist_mux_params, {‘use_sim_time’: True,‘use_stamped’: True}],
remappings=[(‘/cmd_vel_out’,‘/gg_diff_cont_controller/cmd_vel’)]
)

ros2 topic info -v /cmd_vel_nav
Type: geometry_msgs/msg/TwistStamped

Publisher count: 6
Node name: controller_server (1)
Node name: behavior_server (5)

Subscription count: 2
Node name: twist_mux
Node name: velocity_smoother

Inside nav2_params.yaml I put all the parts related to publishers enable_stamped_cmd_vel: True
My personal robot (gg Robot) can now navigate with the diff_drive_controller/DiffDriveController and use_stamped_vel on Jazzy ros2 .
Is this the correct way to set parameters for enable stamped_cmd_vel?(thanks)