Robotics StackExchange | Archived questions

Turtlebot ride backwards a specified distance

I want to write a python script that makes Turtlebot ride backwards for a specified distance in meters. I have this function

def ImuCallback(data, angle):


 global stage
  quat = data.orientation
  q = [quat.x, quat.y, quat.z, quat.w]
  roll, pitch, yaw = euler_from_quaternion(q)

  sys.stdout.write("\r\033[1mGyro Angle\033[0m: [" + "{0:+.4f}".format(yaw) + " rad]  ["\
                 + "{0: >+7.2f}".format(degrees(yaw)) + " deg]"\
                 + "            \033[1mRate\033[0m: [" + "{0:+.4f}".format(data.angular_velocity.z) + " rad/s]  ["\
                 + "{0: >+7.2f}".format(degrees(data.angular_velocity.z)) + " deg/s] ")
  if angle > 0:
    if yaw > angle or yaw < 0:
      stage += 1
  else:
    if yaw > angle and yaw < 0:
      stage += 1 

which makes it stop when the robot is rotating. I would like to read the distance travelled by the robot similarly as to how I read the angle of its rotation. I feel it has to be simple but I don't know how to do it. Thanks in advance!

Asked by Elizaveta.Elagina on 2015-03-04 10:20:07 UTC

Comments

Answers

I see that class TravelForward can be used for my purpose. Probably it's not the most straightforward way but it works.

Asked by Elizaveta.Elagina on 2015-03-05 05:47:07 UTC

Comments

This kobuki script might be helpful to implement backward move.

https://github.com/yujinrobot/kobuki/blob/indigo/kobuki_testsuite/scripts/test_motion_forward.py

Asked by jihoonl on 2015-03-09 19:04:01 UTC

Comments