luxonis / depthai-ros

Official ROS Driver for DepthAI Sensors.
MIT License
239 stars 173 forks source link

Handle ROS Time Shifts and C++14 Build Issue #332

Closed IntelligentJackal closed 1 year ago

IntelligentJackal commented 1 year ago

Overview

Author: @chacalnoir, @IntelligentJackal

Issue

Changes

Testing

This has been tested on an Ubuntu 20.04 system, ROS noetic, with the new function being called at regular intervals. The results were that the ROS base time was updated as expected.

saching13 commented 1 year ago

Thanks for the PR. LGTM.

  1. Can you adjust the styling ?
  2. Can you include the change in stereo_inertial_node with the option to disable it based on parameters?
saching13 commented 1 year ago

Do you by any chance have an idea if this is the case with ROS2 timer too?

IntelligentJackal commented 1 year ago

Do you by any chance have an idea if this is the case with ROS2 timer too?

I do not know for sure, having not used ROS 2 directly. However, based on reading this (https://design.ros2.org/articles/clock_and_time.html) design info concerning ROS 2 clock, it looks like ROS 2 clock has the ability to parallel several clock implementations, with one being steady_clock. As such, I would think the problem likely exists for ROS 2 as well.

IntelligentJackal commented 1 year ago

Thanks for the PR. LGTM.

1. Can you adjust the styling  ?

2. Can you include the change in `stereo_inertial_node` with the option to disable it based on parameters?

(1) Done (2) Working on this

IntelligentJackal commented 1 year ago

Thanks for the PR. LGTM.

1. Can you adjust the styling  ?

2. Can you include the change in `stereo_inertial_node` with the option to disable it based on parameters?

(1) Done (2) Working on this

The stereo_inertial_node appears to primarily operate on callbacks, which makes these functions a bit harder to call. Likewise, the BridgePublisher acts similarly. So, I added a setting into each of the converters for automatically updating ROS base time on each toRosMsg call. May be called more or less often depending on how many messages are flowing. But, the updates to the ROS base time can now fully reside within the converters. This is controlled via a launch parameter in stereo_inertial_node.

saching13 commented 1 year ago

LGTM. thanks for the PR.

borongyuan commented 11 months ago

A better solution is using realtime_clock from realtime_tools.

IntelligentJackal commented 11 months ago

A better solution is using realtime_clock from realtime_tools.

I agree that better solves the problem when using a real-time clock. However, I did not want to leverage the requirement on this software and users thereof that they have either the steady clock or the real-time clock. So, there was the option to implement all ROS clock options or implement this solution, which enables an external user to update this clock to match what they are doing. Adding a real-time clock option could be useful for when users of this software are using a real-time clock (they'll get exactly the desired behavior), while keeping this more generic option to capture all potential clock-type usages.