getting robot location members to update all the time.

asked 2019-01-13 08:57:15 -0600

ophir gravatar image

updated 2019-01-13 09:01:19 -0600

Hello, I'm new to ROS and I'm working on indigo and gazebo with python 2.7. I have a task to implement robotic navigation where the map is known in advance. I'm having difficulties to make my robot object update its x,y, and yaw (2D world, I only care about x location, y location and orientation).

Here is the code that suppose to get me the most accurate values, but for some reason when it does not seem to work:

def get_robot_location():
    listener = tf.TransformListener()
    listener.waitForTransform("/map", "/base_footprint", rospy.Time(0), rospy.Duration(10.0))

    (trans, rot) = listener.lookupTransform("/map", "/base_footprint", rospy.Time(0))
    robot_x = trans[0]
    robot_y = trans[1]
    (roll, pitch, yaw) = euler_from_quaternion(rot)
    rospy.loginfo("current position (%f,%f)" % (robot_x, robot_y))
    rospy.loginfo("yaw is: %f", yaw)
    return robot_x, robot_y, yaw

I would appreciate very much if someone can help me to insert the x,y and yaw as members of my robot object, that keeps updating through time. Thanks!

edit retag flag offensive close merge delete