ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

return turtlebot to initial position

asked 2016-04-11 18:22:16 -0500

toddwf gravatar image

I have a turtlebot that is executing a simple movement. I'm using the odom message store the initial position. I'm trying to return to the initial position. I'm using some code I found online for navigation to move to a goal, with the goal being the initial odom position. This does not work. The code below ends in the goal failed mode (cancel_goal()). Any ideas?

Do I need tf? or am I just misunderstanding pose? I'm just getting the position from /odom. I don't know if /robot_pose_ekf is better (I would need to install and configure that.), but it's a simple motion--mostly rotation and small movement.

Code snippet:

    #'initial' is the odometry initial position
    goal = MoveBaseGoal()
    goal.target_pose.header.frame_id = 'map'
    goal.target_pose.header.stamp = rospy.Time.now()
    goal.target_pose.pose = Pose(Point(self.initial.position.x, self.initial.position.y, self.initial.position.z),
                             Quaternion(self.initial.orientation.x,self.initial.orientation.y,
                                self.initial.orientation.z, self.initial.orientation.w))

    # Start moving
    self.move_base.send_goal(goal)
    rospy.loginfo('after goal sent')

    # Allow TurtleBot up to 60 seconds to complete task
    success = self.move_base.wait_for_result(rospy.Duration(60))

    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()
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-15 06:16:14 -0500

jorge gravatar image

First of all, you must think that odom topic doesn't provide you the robot pose, just a dead-reckoning estimation of the robot motion since startup. The robot pose (not the real one, but the one robot "thinks" he is) is obtained by correcting the odom pose with a localization system, as amcl. See the bottom of amcl wiki for a better explanation.

So better you use the initial robot pose as provided by map -> base_footprint tf, e.g:

    try:
        now = rospy.Time.now()
        listener.waitForTransform('map', 'base_footprint', now, rospy.Duration(10.0))
        (bf_trans, bf_rot) = listener.lookupTransform('map', 'base_footprint', now)
    except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException) as e:
        rospy.logerr(e)

and send it to move_base instead of the odom first message.

That said, we need more information to guess what is your problem. What error messages provides move_base? Are you using amcl for localizaiton, and if so, what is the initial pose? If not 0, 0, 0, this is a probable cause of your problem, because you are telling the robot to go back to the origin of the map, not to its initial position.

edit flag offensive delete link more

Comments

thank you, this clarifies pose vs odometry for me. I took a simpler route (for now, just a dead reckoning return to position), but I may need to return to this approach.

Really for now, all I'm trying to do is rotate the robot back to an initial position. So no lateral movement.

toddwf gravatar image toddwf  ( 2016-04-21 11:02:53 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-04-11 18:22:16 -0500

Seen: 1,839 times

Last updated: Apr 15 '16