Turtlebot3 still has twist values after setting position with gazebo message

I’m working on getting the turtlebot3 robot to follow along the wall of the course as per the first part of the project. I want to set up an easy way to put the robot in the exact same position after each test so that I can reliably set up the same experiment and so I don’t have to drive the robot back every time. To do this I run this command:

    ros2 topic pub --once /gazebo/set_model_state gazebo_msgs/ModelState "{model_name: turtlebot3_burger, pose: {position: {x: .9, y: -.5}, orientation: {z: 1}}}"

Which caused the following output:

publisher: beginning loop
publishing #1: gazebo_msgs.msg.ModelState(model_name='turtlebot3_burger',pose=geometry_msgs.msg.Pose(position=geometry_msgs.msg.Point(x=0.9, y=-0.5, z=0.0), orientation=geometry_msgs.msg.Quaternion(x=0.0, y=0.0, z=1.0, w=1.0)), twist=geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=0.0), angular=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=0.0)), reference_frame='')

Which sets the position of the robot correctly but the robot is still moving. Why is the robot still moving when the output of the command says that all the twist values are zero? I have no terminals running or publishing any messages.


I reccomedn you to do the following:

  1. The turtlebot need to have read a Stop cmd_vel command. Restarting its position its not enough. So check that its recieving that command and stopping before restarting its position
  2. You can also use the service call to restart_gazebo world. It will restart the world and probably the robot state.

/gazebo/reset_simulation /gazebo/reset_world

rosservice call /gazebo/reset_simulation “{}”
rosservice call /gazebo/reset_world “{}”

How would you do option 1 exactly? My understanding is that I am doing option 1. If you look at the output of my command it has the following message:

twist=geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=0.0), angular=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=0.0))

Twist is the message type of the cmd_vel topic. So I am sending a message to stop the motion of the turtlebot.

But option 2 does work by resetting the world. I just then have to send my command to change the position. It just doesn’t make sense why that step is also required to set the velocity to zero when it already received a command to do so.