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:
self.husky_vel_publisher.publish(self.cmd)
self.rate.sleep()
i += 1
The code i used is as follows:
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
rospy.init_node("Particle_test_node")
pub=rospy.Publisher("/husky_velocity_controller/cmd_vel",Twist,queue_size=1)
while pub.get_num_connections()<1:
pass
print("start moving")
TW=Twist()
#move forward for 5 secs
TW.linear.x=0.5
TW.angular.z=0
pub.publish(TW)
rospy.sleep(5)
#stop root
print("stopping")
TW.linear.x=0
TW.angular.z=0
pub.publish(TW)
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.