Ask Your Question

Can someone explain how the Quaternion works for MoveBaseActions?

asked 2012-08-01 09:18:56 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I really want to be able to send a goal to move base that is it's current position, but a different orientation/ rotation. I know I can send a twist command to rotate the robot, but I was wondering how someone would do it via MoveBase?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2012-08-01 09:25:50 -0500

Lorenz gravatar image

updated 2012-08-01 09:32:07 -0500

Have a look here to understand quaternions.

To rotate the robot, you can, for instance, send a PoseStamped with frame id base_link and the relative orientation of your goal relative to your robot to move_base.

edit flag offensive delete link more

answered 2012-08-01 09:33:14 -0500

prasanna.kumar gravatar image

If you are sure of the quaternion values. You can simply publish using geometry_msgs/PoseStamped. Sample:

    publisher = nh.advertise<move_base_msgs::MoveBaseActionGoal>("move_base/goal", 5);
    geometry_msgs::PoseStamped GoalPose;
    move_base_msgs::MoveBaseActionGoal Goal_Pose;

    GoalPose.pose.position.x = <current pose x>;
    GoalPose.pose.position.y = <current pose y>;
    GoalPose.pose.position.z = <current pose z>;

    GoalPose.pose.orientation.x = <desired orientation x>;
    GoalPose.pose.orientation.y = <desired orientation y>;
    GoalPose.pose.orientation.z = <desired orientation z>;
    GoalPose.pose.orientation.w = <desired orientation w>;

    Goal_Pose.header.seq = GoalPose.header.seq = 1;
    GoalPose.header.stamp = 1;
    Goal_Pose.header.frame_id = GoalPose.header.frame_id = "/map";

    Goal_Pose.goal.target_pose = GoalPose;

I used the above on a TurtleBot and it worked perfectly!

edit flag offensive delete link more


This will send the robot to a different location in map unless the correct x and y values for position are used. It is much easier to set the frame_id to base_link and the position to 0. Why are you setting the stamp to 1? This should not work. Set the time to ros::Time::now() or 0.

Lorenz gravatar imageLorenz ( 2012-08-01 10:00:52 -0500 )edit

answered 2012-08-01 15:33:26 -0500

weiin gravatar image

For robots moving in 2D space, I usually use

GoalPose.pose.orientation = tf::createQuaternionMsgFromYaw(<desired direction>);
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2012-08-01 09:18:56 -0500

Seen: 3,247 times

Last updated: Aug 01 '12