stereolabs / zed-ros-wrapper

ROS wrapper for the ZED SDK
https://www.stereolabs.com/docs/ros/
MIT License
441 stars 388 forks source link

improve workflow to avoid added latency #895

Open bmegli opened 1 year ago

bmegli commented 1 year ago

Preliminary Checks

Proposal

Publish depth/rgb data after grabbing instead of:

With:

This is adding worst case single frame latency (publish just before new data) and half frame latency on average.

Use-Case

Any low-latency ROS application needing depth/RGB data

Anything else?

grab thread (std::thread)

https://github.com/stereolabs/zed-ros-wrapper/blob/50dda077a5ea72b7f8c00faad5746938331e46c2/zed_nodelets/src/zed_nodelet/src/zed_wrapper_nodelet.cpp#L3158

ROS publish thread (ROS thread)

https://github.com/stereolabs/zed-ros-wrapper/blob/50dda077a5ea72b7f8c00faad5746938331e46c2/zed_nodelets/src/zed_nodelet/src/zed_wrapper_nodelet.cpp#L569

Run separately


It may be possible to keep current code structure and trigger ROS publishing after successful grab (as opposed to timer based publishing)

Myzhar commented 1 year ago

The original ROS wrapper was made in that way. We added a separate publishing thread when other users (too much to not listen to their request) asked to publish data at a lower frequency than the grab frequency.

I can understand your requirement, you can apply your modification if you need it. I'm sorry, but we are not planning major changes to the ROS wrapper since ROS is close to EOL and most of the ROS users are moving to ROS 2.

bmegli commented 1 year ago

Thank you @Myzhar

Oh, ok, I now see this was improved in ROS2

bmegli commented 1 year ago

In that case, thank you for a quick answer.

bmegli commented 1 year ago

For anybody in need to remove added latency in ROS1 fix is in:

To keep compatibility with existing behavior:

All above was used to keep existing threading model and behavior compatibility.

bmegli commented 1 year ago

@Myzhar

We avoid maintaining third-party forks if possible.

If the fix looks like something mergeable we are happy to open pull request (and adapt as requested).

If not let me know, I will close the issue.