Setting robot orientation
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);
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?
Updated my question. Hope it's more clear now.
I think that you have to broadcast the transform again. Have a look at the "Writing a tf broadcaster" tutorial.
@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!