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

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
2

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
2

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;
    publisher.publish(Goal_Pose);

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

edit flag offensive delete link more

Comments

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 image Lorenz  ( 2012-08-01 10:00:52 -0500 )edit
2

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

Question Tools

1 follower

Stats

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

Seen: 3,837 times

Last updated: Aug 01 '12