How to define GPIO pins in ROS on a Raspberry Pi 2?
I am using a Raspberry pi 2 with ubuntu 14.04 and ros Indigo installed. I want to make a robot which would make a map of the surroundings and then autonomously navigate in it. I have sonars and no other sensors. So my question is how can write the GPIO code in ROS node thats going to publish and populate my range/sensor.msg so that my Raspberry Pi can communicate with the sonars?
It would also be help full if you can take a look at this question and see if you can help. http://answers.ros.org/question/23126...
Thanks & Regards, Mukut
It depends on your sonar sensors. What kind of output signal do they have? Analog signal, SPI, I2C, USB? A good starting point would be wiringPi if you want to use the GPIO
Thanks john for your fast reply! I am using a HC-SR04. It works fine with the digital pins of my Raspberry pi. So I think it's digital.
Yes, it is a digital signal, where you can measure the time and calculate the distance to the object. A short google search also found this Pi driver. But either with this driver or wiringPi, you have tow write the node yourself.
Okay, so all I have to do is to include this driver in the node right? Also can you take a look at my other question?
You need to compile and load the driver first. It is documented on the github page. I cannot answer your second question, I don't know anything about mapping.
So it can also be written in python? It would be the same? And in that case I need not need any external GPIO library like the wiring Pi because it has its own library, RPi.GPIO. Is it possible?
It should be possible. I haven't used RPi.GPIO yet, but after a short google search I found that it also supports interrupts (described here). In theory it will work, but I don't know how precise it will be.
okay. So its better with wiringpi.