Optimize Navigation Stack / Turtlebot drives circles
Hello Guys,
i am using Ros Kinetic on a Ubuntu 16.04 PC. I using Turtlebot package for simulation in Gazebo. A few weeks a go a posted a similar question with rtab map without an answer so i am back on the default navigation paket.
I created a map with gmapping and now i can start the map with :
roslaunch turtlebot_gazebo amcl_demo.launch map_file:=/home/user/turtlebot_custom_maps/tutorial.yaml
This works fine i see my robot in rviz and i could drive to specific point.
My problem now is that the robot drives in circles to reach a specific point. Even is there is no obstacle near him. So i am new in the planner configuration could u give me a tip which parameter i need to change that the robot don´t drive in circles to a point?
Here is my code for reaching a point:
class GoToPose():
def __init__(self):
self.goal_sent = False
# What to do if shut down (e.g. Ctrl-C or failure)
rospy.on_shutdown(self.shutdown)
# Tell the action client that we want to spin a thread by default
self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
rospy.loginfo("Wait for the action server to come up")
# Allow up to 5 seconds for the action server to come up
self.move_base.wait_for_server(rospy.Duration(5))
def goto(self, pos, quat):
# Send a goal
self.goal_sent = True
goal = MoveBaseGoal()
goal.target_pose.header.frame_id = 'map'
goal.target_pose.header.stamp = rospy.Time.now()
goal.target_pose.pose = Pose(Point(pos['x'], pos['y'], 0.000),
Quaternion(quat['r1'], quat['r2'], quat['r3'], quat['r4']))
# Start moving
self.move_base.send_goal(goal)
# Allow TurtleBot up to 60 seconds to complete task
success = self.move_base.wait_for_result(rospy.Duration(80))
state = self.move_base.get_state()
result = False
if success and state == GoalStatus.SUCCEEDED:
# We made it!
result = True
else:
self.move_base.cancel_goal()
self.goal_sent = False
return result
def shutdown(self):
if self.goal_sent:
self.move_base.cancel_goal()
rospy.loginfo("Stop")
rospy.sleep(1)
if __name__ == '__main__':
try:
rospy.init_node('nav_test', anonymous=False)
navigator = GoToPose()
# Customize the following values so they are appropriate for your location
position = {'x': 1.89, 'y' : 1.21}
quaternion = {'r1' : 0.000, 'r2' : 0.000, 'r3' : 0.000, 'r4' : 1.000}
rospy.loginfo("Go to (%s, %s) pose", position['x'], position['y'])
success = navigator.goto(position, quaternion)
if success:
rospy.loginfo("Hooray, reached the desired pose")
position = {'x': -2.76, 'y' : 2.68}
quaternion = {'r1' : 0.000, 'r2' : 0.000, 'r3' : 0.000, 'r4' : 1.000}
rospy.loginfo("Go to (%s, %s) pose", position['x'], position['y'])
success2 = navigator.goto(position, quaternion)
else:
rospy.loginfo("The base failed to reach the desired pose")
# Sleep to give the last log messages time to be sent
rospy.sleep(1)
except rospy.ROSInterruptException:
rospy.loginfo("Ctrl-C caught. Quitting")
In the code i let him drive to 2 points this works after some time he reaches the points but like i described the way to the point is not very straight it more like the robot rotates ...
Can you please post a video showing the behavior of the robot. Also, please fix the indenting of your code. As it is, it won't run because of mismatched indentation levels.