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

Remove lower bound check of timeoutSec in SpinOnce #16

Closed AlgoryxJosef closed 2 years ago

AlgoryxJosef commented 2 years ago

We are running a high-frequency application (around 1000Hz), and allowing zero timeout, making the spinOnce non-blocking, increased performace by a large amount.

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://github.com/ros2/rcl/blob/5040c6049f2320fb34fb803ac97c4a458212102c/rcl/include/rcl/wait.h#L448

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.

adamdbrw commented 2 years ago

This looks like a good catch, thank you! We will briefly test it but it doesn't seem to be problematic and I don't expect issues.

I edited your comment link to point to proper ros2 version (unfortunately google often still shows Beta ros2 documentation)

pijaro commented 2 years ago

Lgtm, thanks!

adamdbrw commented 2 years ago

fixes #17