Reputation: 17942
I'm trying to access the GPIO pins of a Raspberry Pi 2 using the robot operating systen ROS. I know, there are many tutorials on this topic. But my problem is as follows:
/sys/class/gpio
sysfs is not enabled by default. I'd need to recompile the kernel with a custom configuration./sys/class/gpio
, it looks like I need to use /dev/mem
(e.g. with the RPi.GPIO package)./dev/mem
is only accessible to root.rospy
and the whole ROS setup.So, what's the "easiest" way to get GPIO access within a ROS node?
Upvotes: 0
Views: 2274
Reputation: 17942
I think I've found a rather clean solution to my problem:
The pigpio library is what I needed. It runs a daemon started with sudo, which is controlling the GPIO pins. A client program (started without sudo) communicates with the deamon and thus indirectly controls the pins.
You can even run the client on a remote machine. This way a ROS node can control the GPIO pins of a remote raspberry, which itself isn't even running ROS.
My current setup is a rospy node (indigo) on a fitlet PC talking to a Raspberry Pi 2, both running Ubuntu 14.04.
djsw's answer in the ROS forum pointed me in the right direction.
Upvotes: 1