[03] RoboBoard X3
Note
This page contains information for controlling Mini Control Board or RoboBoard X3 remotely from other devices. If you are looking for RoboBoard X3 programming documentation go to RoboBoard X3 documentation section.
#include <Totem.h>
TotemModule module(03);
Module commands
Command naming convention
Some commands controls various channels (A, B, C, ...). There is a logic behind command naming for flexibility:
• write("commandA", 10)
- will set value 10
for individual channel A.
• write("commandAll", 100)
- will set value 100
for all existing channels.
• write("commandABCD", 10, 20, 30, 40)
- will set individual values for A, B, C, D channels.
• write("commandABC", 10, 20, 30)
- will set individual values for A, B, C channels.
Only commands listed in "Module commands" will be accepted. Other variations will be discarded.
All commands are case sensitive! Calls like CommandA
, COMMANDa
, motorA/BRAKE
will be ignored.
Configuration
Commands starting with "cfg" retains its value after module power off. Used as module configuration parameters.
cfg/robot/name ( name
)
- Configure robot name visible during connection.
Parameter:
name
- string (text) up to 30 bytes max.
Default:Totem X3-FBI
.
module.write("cfg/robot/name", "My robot"); // Set robot name
cfg/robot/model ( model
)
- Configure Totem robot model (MiniTrooper, Truck, ...).
Used to identify type of the robot. Can be set to any value. Also received with getModel().
Value can be generated with command:TotemModule::hashModel("model")
.
Parameter:
model
- 16bit hash of robot model name [0
:0xFFFF
].
Default:0
.
// Set robot model to Truck
module.write("cfg/robot/model", TotemModule::hashModel("Truck"));
// Check if robot is Truck
ModuleData data;
if (module.readWait("cfg/robot/model", data) &&
data.getInt() == TotemModule::hashModel("Truck")) { }
cfg/robot/color ( color
)
- Configure robot color.
Used to recognize robot appearance by its color. It may be displayed inside mobile application or on-board RGB lights.
Parameter:
color
- 24bit RGB color value (without brightness) [0x000000
:0xFFFFFF
].
Default:0
.
module.write("cfg/robot/color", 0x0000FF); // Set robot color to BLUE
// Alternative to set individual RGB colors:
module.write("cfg/robot/color", 0, 0, 255); // Set robot color to BLUE
cfg/motorABCD/invert ( onA
, onB
, onC
, onD
)
- Configure motor output polarity.
Individual motors can be configured to invert its spinning direction. Allows to fix reversed motor wiring without reconfiguring robot controls.
Parameter:
onA
- invert channel A [true
:false
].
onB
- invert channel B [true
:false
].
onC
- invert channel C [true
:false
].
onD
- invert channel D [true
:false
].
Default:false
(off)
// Invert channels A and B. C, B - not inverted.
module.write("cfg/motorABCD/invert", true, true, false, false);
cfg/reset ( )
- Reset all module configuration to factory default.
module.write("cfg/reset"); // Reset all module settings to default
DC motor control
motorA ( power
)
motorB ( power
)
motorC ( power
)
motorD ( power
)
- Set individual DC motor A, B, C, D channel power.
Positive - forward, negative - backward,0
- stop.
Parameter:
power
- channel output power [-100
:100
]%.
module.write("motorA", 100); // Write channel A
motorABCD ( powerA
, powerB
, powerC
, powerD
)
- Set DC motor A, B, C, D channels power with a single command call.
Positive - forward, negative - backward,0
- stop.
Parameter:
powerA
- set channel A output power [-100
:100
]%.
powerB
- set channel B output power [-100
:100
]%.
powerC
- set channel C output power [-100
:100
]%.
powerD
- set channel D output power [-100
:100
]%.
module.write("motorABCD", 100, 50, 0, -100); // Write channels A, B, C, D
Servo motor control
servoA ( position
)
servoB ( position
)
- Set servo motor A, B channels position (-100, 0, 100) = (0°, 90°, 180°).
Parameter:
position
- position of servo arm [-100
:100
].
module.write("servoA", 0); // Set servo channel A to 90° angle
Light bar control
leds ( state
)
- Control red LED bar.
Each bit in 12bit value represents individual on-board LED. 1 - on, 0 - off.
Parameter:
state
- [0b000000000000
:0b111111111111
].
module.write("leds", 0b110011110011); // Set led bar to: on|on|off|off|on|on|on|on|off|off|on|on
Battery
battery ( )
- Get connected battery voltage. This command is read-only.
Returned value is in millivolts. Divide by 1000 to get volts [2.7V
:4.2V
].
Returns: [2700
:4200
]mV.
// Read battery voltage
int voltage = module.readWait("battery").getInt(); // Result: 3350 → 3.350V
// 'readWait' will delay code execution until result is received from the module.
ModuleData data; // Prepare variable to store read result
module.readWait("battery", data); // Perform read with wait until result is received
bool voltage = data.getInt(); // Get battery value from result. 3350 → 3.350V
// Function that will receive all subscribed commands of module
void onModuleData(ModuleData data) {
if (data.is("battery")) { // Check if received command is "battery"
bool voltage = data.getInt(); // Get battery value from result. 3350 → 3.350V
Serial.print("Battery voltage = ");
Serial.println(voltage);
}
}
void setup() {
module.attachOnData(onModuleData); // Register onModuleData function
module.subscribe("battery"); // Subscribe to receive any state change of battery
}
Commands list
These are low level TotemBUS commands accepted by module. Is not required when using objective API described above.
Command | Parameters | Description |
---|---|---|
cfg/robot/name |
(string ) |
Set robot name |
cfg/robot/model |
(int ) |
Set robot model hash |
cfg/robot/color |
(int ) |
Set robot appearance color |
cfg/motorABCD/invert |
(bool , bool , bool , bool ) |
Set DC A |
cfg/motorABCD/autobrake |
(byte , byte , byte , byte ) |
Set DC A |
cfg/reset |
None | Reset to default configuration |
motorABCD |
(byte , byte , byte , byte ) |
Set each DC channel spin direction and power |
motorA |
(byte ) |
Set DC A channel spin direction and power |
motorB |
(byte ) |
Set DC B channel spin direction and power |
motorC |
(byte ) |
Set DC C channel spin direction and power |
motorD |
(byte ) |
Set DC D channel spin direction and power |
motorABCD/brake |
(byte , byte , byte , byte ) |
Set each DC channel brake power |
motorA/brake |
(byte ) |
Set DC A channel brake power |
motorB/brake |
(byte ) |
Set DC B channel brake power |
motorC/brake |
(byte ) |
Set DC C channel brake power |
motorD/brake |
(byte ) |
Set DC D channel brake power |
servoA |
(byte ) |
Set servo A channel position |
servoB |
(byte ) |
Set servo B channel position |
leds |
(int ) |
12-bit mask to set each LED on/off |
battery |
Returns:(int ) |
Get battery voltage |
* brake feature is not supported in v.1.5 board revision.