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

Launching a Wiringpi cpp node with roslaunch

asked 2018-08-05 12:52:47 -0500

Prof. xavier gravatar image

updated 2018-08-05 12:53:49 -0500

I have a node that talks to motor driver on a raspberry pi working with wiringpi lib, normally executable of the nodes are made in /ros_ws/devel/lib/<pkg> but this executable is built in /ros_ws/build/<pkg>. the node does not work normally with rosrun, I have to execute it with ./wheels (wheels is the name of the executable), also root permission is needed to run the executable.

Now I have to run this executable with roslaunch and also accommodate root access with it. is there a way to do so? if not then what are the other ways I can have to tackle this problems. I could not find any related questions about this. Please help me with this and try to give a step by step answer so that it will help others as well. thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-05 20:17:53 -0500

Geoff gravatar image

Your node needs root permission to run because it needs to access hardware and you haven't given your user the correct permissions to access that hardware.

The GPIO pins on the Raspberry Pi are apparently typically accessed using a memory-map device node called /dev/gpiomem. The permissions of this node should be set up to allow access to any user in the gpio group. You can confirm the permissions be executing ls /dev/gpiomem. Make sure the group permissions allow reading and writing, and that the group is gpio (the owner will probably be root.

Then you need to make sure your user is a member of the gpio group:

$ sudo adduser [your user name] gpio

Log out and log back in again for the group change to take effect.

An alternative to all of the above, if you are willing to write your node in Python, is to use the pigpio library. It uses a daemon that runs as root and provides a gateway to the GPIO so that users of the module do not have to.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-08-05 12:52:47 -0500

Seen: 536 times

Last updated: Aug 05 '18