introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
916 stars 549 forks source link

Bad time in TF messages #1158

Closed flabrosse closed 1 month ago

flabrosse commented 1 month ago

It seems that most, or at least many, of the rtabmap nodes that do publish TF messages publish the wrong time: a constant time. I think this is because of lines like this:

ros::Time tfExpiration = ros::Time::now() + ros::Duration(tfTolerance);

(this one being from rtabmap_slam/src/CoreWrapper.cpp, the specific issue I'm having that lead me to exploring this).

My understanding is that ros::Time::now() in ROS2 does not exist (or does not do what would be expected). It should now be replaced with this->get_clock()->now(), as described here and here.

PS. I am guessing that the now() I see everywhere in the ros2 branch resolves to ros::Time::now(). The default and most up to date master branch explicitly uses ros::Time::now().

PPS. I also reported this in the old issue #960.

flabrosse commented 1 month ago

It turns out that I was wrong, on many accounts.

(1) the master branch is not a ROS2 branch but a ROS1 so using ros::Time::now() is correct there.

(2) In the ros2 branch, now() is in fact a static function of rclcpp::Time.

The issue was that gazebo was not initialising ROS properly and therefore not publishing anything on the /clock topic. I solved the problem by following this post.

Closing this issue.