MGC Vehicle Controller

The Mini Grand Challenge vehicle is controlled via the Open-Source and Open-Hardware Arduino Microcontrollers. The Arduino reads IIC sensor data (A compass, two sonar distance-range finders and a wheel encoder), and returns the data to the PC platform running Player over serial. It also receives commands from Player which control the motor and servos. For these devices to properly communicate, certain standards and protocols must be shared between the Arduino and Player platform. This document will provide the critical "Hand-shaking procedures" as well as command syntax.

The communication occurs on a serial connection, in our case over the port /dev/ttyUSB#, where # is the index assigned to the specific USB/Serial converter by the Operating System. The commands and data, to and from each device, is always a null-terminated character string. The Aurduino side application is expected to receive these string commands, parse then run the appropriate function, then return any needed variables or status.

Owners
Tony Jones

Commands and Return Statements
All commands will be sent as character strings, with a character being defined as ASCII, not Unicode, over serial. An ASCII table may be found here. Each commands begins with the character '!' (Exclamation mark). A returning statement always begins with the character '?' (Question mark). Those commands that have parameters, such as the command that sets the speed has its command string end with three numbers representing a decimal value. "000" is the equivalent to just 0, as well as "123" is the equivalent to 123. There will never be negative values, thus the character '-' will never be used. Those commands that return values, such as the command that returns the vehicle speed, has the same format, discussed in detail below. The list of valid commands and return statements are as follows:

Communication Example
On power-up, the devices do not initialize attached components. Initialization must be started after power-up, through software. The process of registration for a device, or "Hand-Shaking" is as follows:
 * 1) The PC driver will attempt, on connection, to send "!IN", which tells the Arduino there is a server trying to connect.
 * 2) The Arduino will initialize at this point, return the string "?000", letting the PC know that the Arduino is now listening for PC commands and identifies itself as Arduino number zero.
 * 3) The PC is now free to send commands to and receive data from the Arduino

Get/Set Speed Example
When the server side application queries the current speed and sets it to new velocity, the commands are as follows:
 * 1) The PC driver will send the string "!GS" (Get Speed), which tells the Arduino it should find the current speed via the motor controller and then return it.
 * 2) The Arduino will return the string "?128", meaning that the vehicle current is traveling at 128 units. (Units are defined more clearly in the above table.
 * 3) The PC now re-calculates a new velocity and sends with the the string "!SS134" (Set Speed), with a value of 134 units.
 * 4) The Arduino receives this string and sets the vehicle speed to the given value of 134. The Arduino confirms this command has correctly executed by returning a string "?OK".
 * 5) The PC receives this confirmation string and continues the program loop.