Turtlebot not moving according to input (in simulation and reality)
Hello, I'm using a Turtlebot with Kobuki base and running Ros Hydro on Ubuntu 12.04.
I need the Turtlebot to move in the shape of a square and guiding myself by this codes: albany , turtlebot motion and turtlebot tutorials, I put together a code that only sends the appropriate cmd_vel messages to make the robot move at a certain speed for a chosen time and another one that uses tf information from odom->base_footprint to make the robot move a chosen distance at a certain speed.
I was first testing the codes on turtlesim and they seemed to work well, but when I tested them on the gazebo turtlebot simulator and on the real turtlebot this was the outcome (obtained from the /odom topic on rviz):
Gazebo Simulation - From the code that doesn't use tf:
Gazebo Simulation - From the code that uses the odom->base_footprint tf:
Real Turtlebot - From the code that doesn't use tf:
Real Turtlebot - From the code that uses the odom->base_footprint tf:
From what I've read the odom->base_footprint tf uses the wheel odometry and IMU data and the kobuki base already comes with a calibrated gyro, so I don't think the problem is in the odometry tf. Also, the movement of the turtlebot with the code that doesn't use the tf looks similar to the one the /odom topic shows.
The result from the real turtlebot is terrible, but I was surprised that even in the simulation the code doesn't work well. I don't really know how to improve this results, because I expected that the way to improve the first code was to use the one that implements the tf and that one is the one that works the worst.
Am I misusing the tfs or am I missing something particular about the turtlebot with the messages I'm sending? at least in the first code it looks as if the robot doesn't move as much as the speed would indicate but the tf should be indifferent to that. I read the similar questions in the FAQs but none of them help me solve this.
Thank you very much in advance and sorry for the rviz plots, I didn't find another way to get the trajectory of the robot.
The two codes are below:
Code that only sends the appropriate cmd_vel messages to make the robot move at a certain speed for a chosen time:
#!/usr/bin/env python
# http://library.isr.ist.utl.pt/docs/roswiki/rospy%282f%29Overview%282f%29Time.html
""" Example code of how to move a robot around the shape of a square. """
import roslib
import rospy
import math
import time
from geometry_msgs.msg import Twist
class square: """ This example is in the form of a class. """
def __init__(self):
""" This is the constructor of our class. """
# register this function to be called on shutdown
rospy.on_shutdown(self.cleanup)
# publish to cmd_vel
self.p = rospy.Publisher('cmd_vel', Twist)
#twist ...