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

Summary of the comments: To use the Pi's GPIO in ROS, you have to use a third party library, for example wiringPi (C++) or RPi.GPIO (Python). Both examples support interrupts (examples: wiringPi, RPi.GPIO), which you need to measure the time the sound signal of your HC-SR04 needs to travel to an object and back to the sensor.

Alternatively, there's a driver for the Raspberry Pi and the HC-SR04 here (Github). I have never used this driver, so I cannot say if it works or not.

Also think about the fact, that the default Raspbian is not a realtime operating system. The measured times are not consistent and may vary depending on the Pi's CPU load. You should test the variation in your system before trusting any measurements.