Rotate turtlebot 10 degrees about its axis
Hi all. How are you? How can I turn turtlebot2 10 degrees about its axis and then pause. Note: The robot will not move, it will just rotate 10 degrees once every say 20 seconds. I tried setting the Twist() object's angular velocity in the Z direction but only one wheel moves and ultimately the robot is displaced.
below is my code:
angular_velocity = radians(10) #10 degs / s
r = rospy.Rate(5) #5Hz
#rospy.loginfo("starting loop")
while not rospy.is_shutdown():
rospy.loginfo("in loop")
new_angle = (angle + new_angle) % 360
real_angle = real_angle + angle
#real_angle = rea1_angle + 5
rospy.loginfo("after addition")
new_angle = real_angle % 360
turn_cmd.angular.z = angular_velocity #turns 10 degrees a second
#turn at 10 degrees a second for 1 second
for i in range(5):
self.cmd_vel.publish(turn_cmd)
r.sleep()
#r.sleep()
The above is my logic. But not only does the robot move, it also does not turn 10 degrees as I expect. What am i doing wrong? Thank you very much. Am using ROS indigo kobuki and turtlebot2
That being said - on slightly different note - what would be the favorable values for the rospy.Rate()
function and the inner for
loop to achieve the 10
or even 30
degree rotation at a relative higher angular velocity, say 25 degrees per second
. Because it seems the robot does not work well with low velocities such as 10 degs/s
. Some it does not move at all when low velocities are given. Eitherway, thanks.