An Arduino Mega 2560
rosserial_arduino
client for controlling a Sawppy rover.
To be used in conjunction with the
curio
packages.
The firmware implements an instance of a
rosserial_client
that runs on the Arduino and is managed by a
rosserial
node
running on the rover's onboard computer.
The firmware provides:
Both functions can be enabled or disabled by compile time switches, and the radio control decoder can be configured to process either pulse width modulated signals or a radio control serial communication protocol called SUMD.
rosserial_python
- manages the host-side of
the serial connection and communication to other ROS nodes.rosserial_arduino
-
provides the client Arduino ROS interface: publish and subscribe messages,
access parameters, etc.curio_msgs
-
define the message format used for controlling servos and publishing
radio control PWM data.Here we describe how to build and install the firmware to your Arduino. In the following SKETCHBOOK_PATH is the path to your Arduino sketchbook directory.
Clone the repository into your catkin workspace, then build:
cd ~/curio_ws/src
git clone https://github.com/srmainwaring/curio_firmware.git
cd ~/curio_ws
catkin build
Build and install the ROS libraries for the Arduino:
cd ~/curio_ws
rosrun rosserial_arduino make_libraries.py .
cp -rp ./ros_lib SKETCHBOOK_PATH/libraries
Add a file ros_dummy.h
to the ROS Arduino library in SKETCHBOOK_PATH/libraries/ros_lib/
containing the following:
// ros_dummy.h
// A placeholder so that the Arduino IDE can find header files
// in subdirectories of ros_lib when re-declaring ros.h
// in your project
//
// In your copy of ros.h include this file.
//
// Resources:
// http://wiki.ros.org/rosserial_arduino/Tutorials/NodeHandle%20and%20ArduinoHardware
// https://www.codeproject.com/Articles/1279552/Rodney-A-Long-Time-Coming-Autonomous-Robot-Part-7
#ifndef _ROS_LIB_ROS_DUMMY_H_
#define _ROS_LIB_ROS_DUMMY_H_
namespace ros {
}
#endif // _ROS_LIB_ROS_DUMMY_H_
(My thanks to Phil Hopley's excellent blog for his explanation of why this is is needed).
Copy the firmware source to the sketchbook folder:
cp -rp `rospack find curio_firmware`/firmware/curio_firmware SKETCHBOOK_PATH/curio_firmware
From the Arduino IDE open the sketch and adjust configuration settings described in the section below as required. Finally compile the sketch and download it to your Arduino.
The main sketch file curio_firmware.ion
contains the following
configuration flags:
ENABLE_ARDUINO_LX16A_DRIVER
1
: Enable the Arduino LX-16A driver.
The Arduino will subscribe to servo commands and publish unfiltered
servo positions.0
: Disable the Arduino LX-16A driver.
All servo control is carried out by the Python base controller.Note that the corresponding flag in curio_base/src/base_controller.py
must also be set.
ENABLE_RADIO_CONTROL_DECODER
1
: Enable the radio control decoder. The Arduino will publish
radio control PWM values on a curio_msgs/Channels
message.0
: Disable the radio control decoder.ENABLE_RADIO_CONTROL_SUMD
1
: Use the SUMD decoder.0
: Use the PWM decoder.The following wiring instructions apply to the Arduino Mega 2560.
5V
on the BusLinker to Arduino +5V
GND
on the BusLinker to Arduino GND
TX
on the BusLinker to Arduino RX1
PIN 19RX
on the BusLinker to Arduino TX1
PIN 18+
on the receiver to Arduino +5V
-
on the receiver to Arduino GND
S
channel 5 on the receiver to Arduino RX2
PIN 17+
on the receiver to Arduino +5V
-
on the receiver to Arduino GND
S
channel 1 on the receiver to Arduino PIN 2S
channel 2 on the receiver to Arduino PIN 3S
channel 3 on the receiver to Arduino PIN 4S
channel 4 on the receiver to Arduino PIN 5S
channel 5 on the receiver to Arduino PIN 6S
channel 6 on the receiver to Arduino PIN 7See the documentation for curio
.
The parameters, publications and subscriptions supported
are affected by the configuration settings. For instance if radio control
is disabled the curio_msgs::Channels
messages will not be published.
This software is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.