odometry giving wrong data after some time

asked 2019-11-06 08:29:06 -0500

mechamecha gravatar image

hey, I am trying to simulate turtlebot and I use these lines of code for getting coordinates of the current position of the robot. I use ROS Kinetic package, Gazebo as simulator and Python to code. I am very new to ROS; so, please let me know if this topic has something wrong.

listener = tf.TransformListener()
try:
            (translation,orientation) = listener.lookupTransform("/odom", "/base_footprint", rospy.Time(0));
except  (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException) as e:
            print("EXCEPTION:",e)
            delay.sleep()
            continue
r_xorient, r_yorient, r_zorient = transformations.euler_from_matrix(transformations.quaternion_matrix(orientation))
robot_theta = r_zorient

Therefore, translation[0] is my x position, translation[1] is my y position and robot_theta is angle about z axis. However, that data becomes altered after some movements, I realized that when I compared with Gazebo interface or with 'get_state' command. For example, for an instant, get_state command yields x=1.154919213 y=0.13513421 and odometry yields x=1.69158371 y=-0.008069573 How can I fix this problem?

edit retag flag offensive close merge delete