I've done the tutorial for tf2, and everything works fine.
Now I'm trying to reproduce the "follow" behavior with drones, but this time it fails.
I've got a Node for each drone. I do the broadcast exactly like in the tutorial and it works. At least I can see the transformation with ros2 run tf2_ros tf2_echo cis_drone_2 cis_drone_1
At time 1693834924.724220138
- Translation: [1.000, 1.000, 0.000]
- Rotation: in Quaternion [0.000, -0.000, -0.000, 1.000]
- Rotation: in RPY (radian) [0.000, -0.000, -0.000]
- Rotation: in RPY (degree) [0.000, -0.000, -0.000]
- Matrix:
1.000 0.000 -0.000 1.000
-0.000 1.000 -0.000 1.000
0.000 0.000 1.000 0.000
0.000 0.000 0.000 1.000
This is on startup, both drones are on the floor. Then I start the "follow action" building the TransformListener once again like in the tutorial. Here is my callback
# frames involved
from_frame = self._leader
to_frame = self.name
# Look up for the transformation between leader_frame and this mobile frame
try:
t = self.__buffer.lookup_transform(
to_frame,
from_frame,
rclpy.time.Time(),
timeout=rclpy.duration.Duration(seconds=3.0),
)
except TransformException as ex:
self.get_logger().info(
f'Could not transform {to_frame} to {from_frame}: {ex}')
return
self.get_logger().info(f"Transform is {t}")
Here I get an exception :
Could not transform cis_drone_2 to cis_drone_1: "cis_drone_2" passed to lookupTransform argument target_frame does not exist.
And in the terminal running tf2_echo
I get this error :
Failure at 1693834935.374
Exception thrown:Lookup would require extrapolation into the past. Requested time 1693834924.724220 but the earliest data is at time 1693834925.739769, when looking up transform from frame [cis_drone_1] to frame [cis_drone_2]
The current list of frames is:
Frame cis_drone_1 exists with parent warehouse_lanes.
Frame cis_drone_2 exists with parent warehouse_lanes.
I tried to use 0
as a value for time
in lookup_transform
, doc says it will get the latest, but I get this new error
[drone-11] File "/opt/ros/humble/lib/python3.10/site-packages/tf2_ros/buffer.py", line 135, in lookup_transform
[drone-11] self.can_transform(target_frame, source_frame, time, timeout)
[drone-11] File "/opt/ros/humble/lib/python3.10/site-packages/tf2_ros/buffer.py", line 221, in can_transform
[drone-11] not self.can_transform_core(target_frame, source_frame, time)[0] and
[drone-11] TypeError: time must have sec and nanosec, or nanoseconds.
Do I have to use the "traveling in time" to perform this "immediate" follow ?
Duration()
which is probably equal to 0 s. Still I do not understand why it is necessary. $\endgroup$