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

Revision history [back]

click to hide/show revision 1
initial version

Just answering this question for future inquiries.

You can do so by calculating the angle between the current position of the robot and the goal. Then convert this angle to quaternion and give it to send goal function. This way the robot will reach the goal without additional rotating after it arrives. Here is how:

    angle_to_goal=math.atan2(self.targety-self.currentY,  self.targetx-self.currentX)

    q_angle = tf.transformations.quaternion_from_euler(0, 0, angle_to_goal, axes='sxyz')

    q = Quaternion(*q_angle)

    self.goal = MoveBaseGoal()

    self.goal.target_pose.pose = Pose(Point(self.targetx, self.targety, 0.000), q)

    self.goal.target_pose.header.frame_id = 'map'

    self.move_base.send_goal(self.goal)