return turtlebot to initial position
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()