RobotecAI / ros2cs

A C# (.Net) implementation of ros2 client library (rcl), enabling communication between ros2 ecosystem and C#/.Net applications such as Unity3D
Apache License 2.0
91 stars 22 forks source link

Allow non-blocking spinOnce #17

Closed AlgoryxJosef closed 2 years ago

AlgoryxJosef commented 2 years ago

Passing 0 or even negative numbers to the final rcl_wait is well defined and there is no reason to impose any limitation in this wrapper code, that I know of.

See: https://docs.ros2.org/beta1/api/rcl/wait_8h.html#a732278988c802fe2c9d8ec24752f9dd9

The unit of timeout is nanoseconds. If the timeout is negative then this function will block indefinitely until something in the wait set is valid or it is interrupted. If the timeout is 0 then this function will be non-blocking; checking what's ready now, but not waiting if nothing is ready yet. If the timeout is greater than 0 then this function will return after that period of time has elapsed or the wait set becomes ready, which ever comes first.

My suggestion is to simply pull: https://github.com/RobotecAI/ros2cs/pull/16 which removes the lower-bound checking of timeoutSec in spinOnce.

This has been tested and we noticed a big performance boost when running in a high-frequency application.

adamdbrw commented 2 years ago

Thank you for the suggestion, we are looking at the PR.