swri-robotics / marti_common

Common utility functions for MARTI
BSD 3-Clause "New" or "Revised" License
54 stars 63 forks source link

Fix calling ageSeconds() on subscriber throws exception (#609) #610

Closed mschickler closed 3 years ago

mschickler commented 3 years ago

The original code used rclcpp::Clock::now() to retrieve the time, which returns a clock of type RCL_SYSTEM_TIME. All other code is using rclcpp::Node::now() which returns a clock of type RCL_ROS_TIME. The two time sources are not compatible and cannot be compared or operated on together. This change pushes the code down into the impl where the node handle is available for calling now() when now is not provided as an argument.

It is worth noting that calling age(node->now()) instead of age() is not even possible as a workaround since that will result in another exception due to the passed time object source not being compatible with rclcpp::Time(0,0). Similar "what" text as the original problem, just having to do with comparing to unlike time sources.

mschickler commented 3 years ago

Closing. Will re-open.