As we've mentioned before, our long term plan for ArduPilot includes it being compatible with Willow Garage's Robot Operating System as a "ROS Node", which is to say that it can communicate with ground computers running ROS for things like swarming and multi-UAV control. The Willow Garage team is supporting this, too, and here's their latest update on Arduino+ROS progress:
We recently wanted to hook up an analog gyro (the Analog Devices ADXRS614) to ROS, and decided to use an Arduino to handle the conversion.
The Arduino runs a tiny loop that reads the analog values from its six analog lines,and writes these values to the USB serial connection. Meanwhile on the robot, a small ROS Python node listens to the USB reports, and publishes them as a ROS topic.
That's all there is to it: the whole thing takes under 40 lines of code.
This is probably the simplest possible way to use an Arduino with ROS. There are quite a few more sophisticated projects:
- pmad - controls an Arduino's I/Os using ROS service calls
- avr_bridge - automates generation of ROS-Arduino message transport
- arduino - our own package: an Arduino as an Ethernet-connected ROS node
Comments
I Iike simple, but sometimes it comes at a price.
The 40 line Arduino analogRead() / Serial.print method is a very inefficient way of reading the ADC inputs. At 115200 baud the example above will be able to read each gyro about 350-400 times a second. Maybe this is good enough, but I suspect you will eventually run into problems with excessive gyro drift because of the relatively infrequent reading of gyro values.
On the other hand, if you are willing to step around some of the Arduino limits by programming directly for the AVR chip. You can use a free running ADC interrupt to read each GYRO sensor many thousand of times each second. Accumulating those values, you get a much more accurate gyro reading for transmission to the ROS unit.
If you want an immediate solution, I'd like to highlight the already existing MAVLink to ROS node, which immediately enables ArduPilotMega to ROS connections with the current APM code trunk. We have used it so far just to connect MAVCONN to ROS, but added, since this seems a hot topic, a serial interface process that will directly connect APM with ROS. This is work in progress, but will be finishes within the next 1-2 days - we would like to encourage testers to get in touch with us:
https://github.com/pixhawk/mavlink-ros-pkg