Access GPIO pins of Raspberry Pi 2 with ROS

我是研究僧i 提交于 2019-12-13 07:13:34

问题


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:

  • The recommended Linux distribution for ROS is Ubuntu. Since there are other Ubuntu machines in the ROS network, I'd like to avoid compiling ROS for a different OS.
  • In Ubuntu the /sys/class/gpio sysfs is not enabled by default. I'd need to recompile the kernel with a custom configuration.
  • If I can't use /sys/class/gpio, it looks like I need to use /dev/mem (e.g. with the RPi.GPIO package).
  • But /dev/mem is only accessible to root.
  • And I can't run a ROS node as root, since it's missing rospy and the whole ROS setup.

So, what's the "easiest" way to get GPIO access within a ROS node?


回答1:


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.



来源:https://stackoverflow.com/questions/36018085/access-gpio-pins-of-raspberry-pi-2-with-ros

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!