Race conditions in publisher and callback

asked 2022-01-28 02:19:21 -0500

Hey!

I am writing a ROS2 node where I have 2 subscribers and 1 publisher. 2 subscribers are synchronized with message_filters and then in the synchronized callback I calculate a new value, say "output". I have a publisher that has to publish this "output" with a different frequency.

Since publisher and subscriber work in parallel, does it cause a race condition (subscriber tries to write to "output" variable, publisher tried to read from it)? Is it handled by ROS2 or mutexes are better to be used in this scenario?

Thanks.

edit retag flag offensive close merge delete