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/231269/can-i-rely-on-the-navigation-tutorials-when-working-with-sonar/
Thanks & Regards, Mukut
Originally posted by mukut_noob on ROS Answers with karma: 35 on 2016-04-25
Post score: 0
Original comments
Comment by JohnDoe2991 on 2016-04-25:
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
Comment by mukut_noob on 2016-04-25:
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.
Comment by JohnDoe2991 on 2016-04-25:
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.
Comment by mukut_noob on 2016-04-25:
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?
Comment by JohnDoe2991 on 2016-04-26:
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.
Comment by mukut_noob on 2016-04-26:
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?
Comment by JohnDoe2991 on 2016-04-27:
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.
Comment by mukut_noob on 2016-04-27:
okay. So its better with wiringpi.