tf2 starts saying frame doesn't exist
I have a problem where whenever I ask for a transform, the very first tf2 message returns with a "frame does not exist error", this is causing problems down the line for my functions. My node is in c++ and using tf_buffer->transform()
but I experience the same behavior in terminal.
Test
Set up the transforms in one terminal with
$ ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 frame1 frame2
[INFO] [1638370239.897375496] [static_transform_publisher_CmYNZrUxpQX1bhQB]: Spinning until killed publishing transform from 'frame1' to 'frame2'
Then echo the transform in another terminal by
$ ros2 run tf2_ros tf2_echo frame1 frame2
[INFO] [1638370253.913909210] [tf2_echo]: Waiting for transform frame1 -> frame2: Invalid frame ID "frame1" passed to canTransform argument target_frame - frame does not exist
At time 0.0
- Translation: [0.000, 0.000, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
Obviously the transform exists, but without fail I am guaranteed that the first attempt throws a tf2::LookupException
.
Edit
My original confusion stems from my attmpt to use transform
, like
tf_->transform(in_pose, out_pose, target_frame,
tf2::Duration(std::chrono::seconds(5)));
Where tf_
is a std::shared_ptr<tf2_ros::Buffer>
, this not finding a transform doesn't make sense to me. I've checked, using ros2 run tf2_tools view_frames.py
, that the transform from in_pose
frame to target_frame
exists and is published with 30Hz, therefore 5 seconds should be more than enough to find it. But somehow it asserts that one of the frames doesn't exist?
Note, buffer is initialized in constructor, and this transform happens in an action server, prompted by a client. So there is significant delay between when the server is started and the client is run. Note, also this is wrapped with try
and catch
statements, this formulations throws a LookupException
with the exception saying:
"map" passed to lookupTransform argument target_frame does not exist.
Hi @morten, have you considered using
waitForTransform
? http://wiki.ros.org/tf/Tutorials/tf%2...Re your edit. Do you have a
tf2_ros::TransformListener
constructed and updating the buffer? Tutorial on writing a c++ listener