Turtlebot and Husky responding differently to twist commands through /cmd_vel topic

Hi, this is regarding ROS navigation in 5 days course, chapter 3 -Robot localization, Exercise 3.12.

I was trying to move the robot Husky using topic /husky_velocity_controller/cmd_vel publisher. But the robot moves only for 1 sec and stops. From other posts on this forum, i saw that while loops are being used to publish into it continuously. I tried the same code with the turtlebot, by changing the publishing topic to /cmd_vel and it worked as it supposed to be. why is it different with husky?

The mentioned on the forum post is as below:

    def move_forward(self, linear_speed=0.5, angular_speed=0.0):
        self.cmd.linear.x = linear_speed
        self.cmd.angular.z = angular_speed
        i = 0
        while i < 50:
            i += 1

The code i used is as follows:

#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist

while pub.get_num_connections()<1:
print("start moving")
#move forward for 5 secs
#stop root

Can you tell me why the difference in how each of them behave upon receiving the commands through /cmd_vel topic. I thought the all robots responded the same to the /cmd_vel command. am i wrong?

Let me know your thoughts on this.

Hello @Joseph1001 ,

This happens because the controllers are different.

  • With the Turtlebot robot, if you publish 1 message (with velocities) to the cmd_vel topic, the robot will start moving and continue moving until you publish a message with the velocities set to 0.

  • With the Husky robot, if you publish 1 message to the cmd_vel topic the robot will move for a moment and then stop again. Therefore, if you want to move it continuously you have to keep publishing messages into the cmd_vel topic with a loop (just as you say in your message).

Usually, you will encounter the 2nd case. This is done like this mainly for security reasons. The robot will stop automatically after a message is published into the cmd_vel (imagine 1 message is published by mistake) unless you specifically keep publishing messages into the topic.

Hope this clarifies your doubts,

1 Like

Thank you @albertoezquerro , this clairified it