Kobuki's nodelets seem to lack proper thread synchronization mechanisms (e.g. mutex), to protect against the reading of inconsistent values (mid-write) and stale data (writes made by one thread are not visible to another). This is true for kobuki_safety_controller, kobuki_random_walker and kobuki_node (this one to a lesser extent).
Are these mechanisms provided somewhere else (e.g. super-classes), and I just missed them? Otherwise, these nodelets are relying on chance to behave correctly.
Example (with kobuki_safety_controller)
After the robot bumps into an obstacle, the safety controller receives a bumper event and SafetyController::bumperEventCB is called on the "main" thread of the nodelet. This callback is supposed to update, say, bumper_center_pressed_ = true;.
The update thread will, eventually, call spin, where it attempts to read bumper_center_pressed_. Since there are no synchronization mechanisms of any sort, there is no guarantee that this thread will ever see true on this variable (if it relies on the processor's cache). This will result in the safety action not being triggered, leaving the robot to keep pushing the obstacle.
Kobuki's nodelets seem to lack proper thread synchronization mechanisms (e.g. mutex), to protect against the reading of inconsistent values (mid-write) and stale data (writes made by one thread are not visible to another). This is true for
kobuki_safety_controller
,kobuki_random_walker
andkobuki_node
(this one to a lesser extent).Are these mechanisms provided somewhere else (e.g. super-classes), and I just missed them? Otherwise, these nodelets are relying on chance to behave correctly.
Example (with
kobuki_safety_controller
)After the robot bumps into an obstacle, the safety controller receives a bumper event and
SafetyController::bumperEventCB
is called on the "main" thread of the nodelet. This callback is supposed to update, say,bumper_center_pressed_ = true;
.The update thread will, eventually, call
spin
, where it attempts to readbumper_center_pressed_
. Since there are no synchronization mechanisms of any sort, there is no guarantee that this thread will ever seetrue
on this variable (if it relies on the processor's cache). This will result in the safety action not being triggered, leaving the robot to keep pushing the obstacle.