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

Setting robot orientation

asked 2014-03-12 03:51:26 -0500

SpiderRico gravatar image

updated 2014-03-12 09:38:50 -0500

Hello all,

I have 2 robots erratic robots in gazebo and I want them to have approximately the same orientation. I am trying following piece of code but it doesn't seem to have any effect on my robot's rotation.

tf::TransformListener listener;
    tf::StampedTransform transform;
    try {

        listener.waitForTransform("/odom", "/base_link", ros::Time(0),
                ros::Duration(3.0));
        listener.lookupTransform("/odom", "/base_link", ros::Time(0),
                transform);
    } catch (tf::TransformException ex) {
        ROS_ERROR("%s", ex.what());
    }

    tf::Quaternion rotation;
    rotation.setValue(robot2.orientation.x, robot2.orientation.y, robot2.orientation.z);
    transform.setRotation(rotation);
edit retag flag offensive close merge delete

Comments

What do you mean "doesn't seem to be working"? Does it give a compilation error? Does the pose end up in the wrong place? How are you sending these transforms to gazebo?

jbinney gravatar image jbinney  ( 2014-03-12 09:07:15 -0500 )edit

Updated my question. Hope it's more clear now.

SpiderRico gravatar image SpiderRico  ( 2014-03-12 09:39:10 -0500 )edit
1

I think that you have to broadcast the transform again. Have a look at the "Writing a tf broadcaster" tutorial.

atp gravatar image atp  ( 2014-03-12 10:07:30 -0500 )edit

@atp How did I miss that! It helped me a lot. If you add this as an answer, I'll accept it mate. Thank you!

SpiderRico gravatar image SpiderRico  ( 2014-03-12 15:00:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-03-18 02:19:10 -0500

SpiderRico gravatar image

updated 2014-03-18 02:19:27 -0500

As atp suggested following this) tutorial solved my problem:

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-12 03:51:26 -0500

Seen: 346 times

Last updated: Mar 18 '14