ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
In your first example, you make a tf::StampedTransform
to hold the transform, then use transformTFToMsg
to put it into a message object.
In the second example, tf2
is _already_ returning a geometry_msgs::TransformStamped
message type (instead of a StampedTransform
object). So you're trying to convert a message to a message. You're effectively doing this:
geometry_msgs::TransformStamped transformStamped;
geometry_msgs::Transform tt;
tf::transformTFToMsg(transformStamped, tt);
But those are both message types, so you don't need to do that at all. You have two options:
transformStamped
instead of tt
in the rest of your code, since they are both messages.Just do this:
geometry_msgs::TransformStamped transformStamped;
<your transform try/catch block>
geometry_msgs::Transform tt = transformStamped.transform;
2 | No.2 Revision |
In your first example, you make a tf::StampedTransform
to hold the transform, then use transformTFToMsg
to put it into a message object.
In the second example, tf2
is _already_ already returning a geometry_msgs::TransformStamped
message type (instead of a StampedTransform
object). So you're trying to convert a message to a message. You're effectively doing this:
geometry_msgs::TransformStamped transformStamped;
geometry_msgs::Transform tt;
tf::transformTFToMsg(transformStamped, tt);
But those are both message types, so you don't need to do that at all. You have two options:
transformStamped
instead of tt
in the rest of your code, since they are both messages.Just do this:
geometry_msgs::TransformStamped transformStamped;
<your transform try/catch block>
geometry_msgs::Transform tt = transformStamped.transform;