Universal_Robots_ROS_Driver icon indicating copy to clipboard operation
Universal_Robots_ROS_Driver copied to clipboard

Make several members of hw_interface atomic, for thread safety

Open AndyZe opened this issue 4 years ago • 5 comments

Addresses #447.

I look at this as cheap insurance because there's no downside to making these variables atomic AFAIK.

AndyZe avatar Aug 06 '21 18:08 AndyZe

Thank you @AndyZe for this contribution! I'll have a look.

stefanscherzinger avatar Aug 09 '21 09:08 stefanscherzinger

@fmauch you probably know more about it than I do. The way I look at it is:

position_controller_running_ and velocity_controller_running_ are used in write() and doSwitch(). They are probably safe if ros_control does its job of stopping the read/write loop before switching. So I could probably revert those if you want me to.

robot_program_running_ is used in write(), isRobotProgramRunning(), handleRobotProgramState(), and stopControl(). That's quite a few places that I don't all trust to be threadsafe (but maybe they are...)

Same thing with controller_reset_necessary_. It's used in read(), handleRobotProgramState(), and shouldResetControllers(). Several places that might not all be threadsafe.

AndyZe avatar Aug 12 '21 17:08 AndyZe

position_controller_running_ and velocity_controller_running_ are used in write() and doSwitch(). They are probably safe if ros_control does its job of stopping the read/write loop before switching. So I could probably revert those if you want me to.

No, I'm absolutely fine with keeping them. @stefanscherzinger do you think this would make sense to merge into master or staging? Intuitively I would merge it into master, but it will probably create conflicts with staging. Additionally, we introduced other members in the staging branch that should get the same treatment. I would go for merging this into master and adapting staging accordingly.

fmauch avatar Aug 15 '21 11:08 fmauch

As we plan to merge staging very soon, I'd postpone this after the merge.

fmauch avatar Sep 01 '21 09:09 fmauch

Looking at the conflicts it looks as if we have to extend this PR with the new interfaces. @AndyZe would you like to do it or should I update this PR?

fmauch avatar Sep 16 '21 07:09 fmauch