ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As the node was started as root it was not possible for it to catch ctrl+c I could use rosnode kill to kill the node but in my case I wanted the node to die after ctrl+ced my Launchfile.

So I had two options:

  • Find a way to run `Pigpio with a non-root user

  • Find a way to kill the node started as root with the ctrl+c of the launchfile

I didn't find any way to use Pigpio without root, so I went for the second option.

I created a second node in the same package that was publishing a topic (with an empty msg) and added it to the launchfile (without sudo for this one). In the node started as Root I added a subscriber for this topic. And if I am not receiving anything for 1 second I just exit the node, thus release the access to GPIO.

As the node was started as root it was not possible for it to catch ctrl+c I could use rosnode kill to kill the node but in my case I wanted the node to die after ctrl+ced my Launchfile.

So I had two options:

  • Find a way to run `Pigpio with a non-root user

  • Find a way to kill the node started as root with the ctrl+c of the launchfile

I didn't find any way to use Pigpio without root, so I went for the second option.

I created a second node in the same package that was publishing a topic (with an empty msg) and added it to the launchfile (without sudo for this one). In the node started as Root I added a subscriber for this topic. And if I am not receiving anything for 1 second I just exit the node, thus release releasing the access to GPIO.

As the node was started as root it was not possible for it to catch ctrl+c I could use rosnode kill to kill the node but in my case I wanted the node to die after ctrl+ced my Launchfile.

So I had two options:

  • Find a way to run `Pigpio with a non-root user

  • Find a way to kill the node started as root with the ctrl+c of the launchfile

I didn't find any way to use Pigpio without root, so I went for the second option.

I created a second node in the same package that was publishing a topic (with an empty msg) and added it to the launchfile (without sudo for this one). In the node started as Root I added a subscriber for this topic. And if I am not receiving anything for 1 second I just exit the node, thus releasing the access to GPIO.