14 Commands
14 Commands
TECHNICAL
DOCUMENTATION
ARDUINO/ARXTERRA PROGRAMMING
PART I - COMMANDS
GETTING STARTED
ARXROBOT FIRMWARE DEFINE ROBOT FEATURES
You can download the arxrobot_firmware from the Arxterra GitHub releases page:
https://github.com/arxterra/arxrobot-firmware/releases.
Based on the Arxterra robot you are building, set definitions to TRUE or FALSE
mini-Rosco rover configured with bluetooth communictions with an ultrasonic pinger.
GETTING STARTED
ARXROBOT FIRMWARE DEFINE ROBOT PINOUTS
Once you have configured your code. Open the pinouts_robot.h tab and make sure
your rovers pinouts are correct.
COMMAND ENCODING
BYTE ARRAY FORMATTED INTO A PACKET
Packet ID 0xA5 indicates the start of a command packet
Packet Length is the number of bytes following minus the LRC byte.
Command ID is an 8-bit code identifying the instruction to be executed.
Command ID byte is followed by some number of bytes.
Longitudinal Redundancy Check (LRC) is generated over the entire packet.
COMMAND ENCODING
EXAMPLE - MOVE (0X01) FORWARD HALF SPEED TEST
i =
N =
A5 05 01 01 80 01 80 A1
sendPacket
data[0] A5 = Command Packet ID
data[1] 05 = Packet Length N w/o parity byte
data[2] 01 = Move ID
data[3] 01 = Left Motor Forward
data[4] 80 = Half Speed (128/255)
data[5] 01 = Right Motor Forward
data[6] 80 = Half Speed (128/255)
data[7] A1 = Longitudinal Redundancy Check (LRC)
COMMAND ENCODING
COMMAND DEFINITIONS IS INCLUDED IN THE PINOUTS_ROBOT.H FILE
COMMAND ENCODING
CUSTOM COMMANDS
Arxterra control panel allows you to create
your own custom commands
Control panel designed to support a Hexapod robot
Control Panel User interface (UI) widgets include:
radio buttons, sliders, drop down menus, and more.
IMPLEMENTING COMMANDS
HOW THE ARXROBOT FIRMWARE DETECTS, READS, AND HANDLES
COMMANDS
All Arduino programs contain a setup() and a loop() method. Commands are detected
in the loop() method.
Once detected, commands are decoded in the commandDecoder() function.
You can find the command decoder code under the command tab within the Arduino
IDE (Integrated Development Environment).
IMPLEMENTING COMMANDS
COMMAND DECODER FINITE STATE MACHINE (FSM)
IMPLEMENTING COMMANDS
COMMAND EXCEPTION CODES
01
02
03
04
05
IMPLEMENTING COMMANDS
HOW THE ARXROBOT FIRMWARE DETECTS, READS, AND HANDLES
COMMANDS
If the command is successfully decoded then the commandHandler function is called
from state 3 of the FSM.
IMPLEMENTING COMMANDS
COMMAND DECODER
To understand these two parameters, review move (0x01) command example.
i =
N =
Data = A5 05 01 01 80 01 80 A1
The command handler function assigns the third byte to the unsigned byte variable cmd.
IMPLEMENTING COMMANDS
HOW TO WRITE ARDUINO CODE FOR YOUR ROBOTS UNIQUE COMMAND(S)
The simplest is to throw away the code within the else if block and adding your own.
2.
The second is to add your code in such a way that the original functionality of the code is
not lost.
IMPLEMENTING COMMANDS
METHOD 2: MAINTAINING CODE COMPATIBILITY
Step 1
Add a new C++ preprocessor directive for your robot. Declare it TRUE and the
remaining robots FALSE.
#define BiPed TRUE
#define PaperBot FALSE
#define Rosco FALSE
Step 2
Scroll down to the command block you are implementing
Append a #elif preprocessor conditional directive (before #endif).
Add a function call to your command
IMPLEMENTING COMMANDS
METHOD 2: MAINTAINING CODE COMPATIBILITY CONTINUED
Step 3
IMPLEMENTING COMMANDS
METHOD 2: MAINTAINING CODE COMPATIBILITY - EXAMPLE
if (cmd == MOVE) {
#if Rosco == TRUE // Adafruit L293D motorshield
move_L293D(data);
#elif Pathfinder
move_VNH5019(data);
#elif PaperBot
// Sparkfun TB6612FNG
move_TB6612FNG(data);
#elif BiPed
walk_BiPed(data);
#endif
IMPLEMENTING COMMANDS
UNPACKING/FORMATTING COMMAND ARGUMENTS
All command data is in the form of a byte array, formatted as an Arxterra command
packet.
Your unique commands may want data formatted as a type other than an 8-bit byte.
In this example, four (4) bytes are converted into a 32-bit unsigned long data type
and saved in variable ping_interval.
COMMANDS
ADDITIONAL READING