rm-proto
A no_std, allocation-free Rust implementation of the RoboMaster referee system and vision link communication protocols.
Crates
| Crate | Description |
|---|---|
rm-frame |
Core framing layer: CRC, encode/decode, error types, optional remote control |
rm-link-serial |
Referee system serial protocol messages |
rm-link-vision |
Vision link messages (Custom2Robot) |
Frame Format
┌──────┬─────┬─────┬──────┬────────┬──────┬───────┐
│ SOF │ LEN │ SEQ │ CRC8 │ CMD_ID │ DATA │ CRC16 │
├──────┼─────┼─────┼──────┼────────┼──────┼───────┤
│ 1 B │ 2 B │ 1 B │ 1 B │ 2 B │ N B │ 2 B │
└──────┴─────┴─────┴──────┴────────┴──────┴───────┘
| Field | Details |
|---|---|
| SOF | Start of frame marker: 0xA5 |
| LEN | Payload length, little-endian u16 |
| SEQ | Sequence number, wrapping u8 |
| CRC8 | CRC8/DJI over [SOF, LEN, SEQ], initial value 0xFF |
| CMD_ID | Command ID, little-endian u16 |
| DATA | Payload bytes |
| CRC16 | CRC16/DJI over the entire preceding frame, initial value 0xFFFF |
Minimum frame size (empty payload): 9 bytes.
rm-frame
The Marshaler Trait
Implement this trait to make a type encodable and decodable:
Implementing Marshaler automatically provides the ImplMarshal (encode-only) and ImplUnMarshal (decode-only) sub-traits. Types that only need one direction can implement these directly.
Messager
The main entry point for sending and receiving frames:
let mut messager = new; // initial sequence number
// Encode a message into a buffer
let n = messager.pack?;
// Decode a raw frame from a buffer
let = messager.unpack?;
// Decode directly into a typed message
let = messager.?;
Error Types
| Type | When it occurs |
|---|---|
PackError |
Buffer too small, invalid payload size |
UnPackError |
Missing header, bad checksum, incomplete data |
MarshalerError |
CMD_ID mismatch, wrong data length |
UnPackError::skip() returns how many bytes to advance for re-synchronization.
CRC Utilities
use ;
let crc8 = calc_dji8;
let crc16 = calc_dji16;
rm-link-serial
Some referee system messages implement the full Marshaler trait (encode + decode).
Messages
| Module | Type | CMD_ID | Rate / Trigger | Payload |
|---|---|---|---|---|
states |
GameStatus |
0x0001 |
1 Hz | 11 B |
result |
GameResult |
0x0002 |
On match end | 1 B |
health |
GameRobotHP |
0x0003 |
3 Hz | 16 B |
event |
GameEvent |
0x0101 |
1 Hz | 4 B |
warning |
RefereeWarning |
0x0104 |
On penalty / 1 Hz | 3 B |
dart |
DartInfo |
0x0105 |
1 Hz | 3 B |
status |
RobotStatus |
0x0201 |
10 Hz | 13 B |
heat |
PowerHeat |
0x0202 |
10 Hz | 14 B |
pos |
RobotPos |
0x0203 |
1 Hz | 12 B |
buff |
RobotBuff |
0x0204 |
3 Hz | 8 B |
hurt |
HurtData |
0x0206 |
On damage | 1 B |
Usage
use Messager;
use RobotStatus;
let messager = new;
let : = messager.unmarshal?;
println!;
rm-link-vision
Custom2Robot — CMD_ID 0x0302, 30 bytes
A custom controller-to-robot command carrying 6 joint angles (f32) and a gripper state (bool). Decode-only (ImplUnMarshal).
use Messager;
use Custom2Robot;
let messager = new;
let : = messager.unmarshal?;
let joints = cmd.get_joints; // &[f32; 6]
let gripper = cmd.get_gripper; // bool
Feature Flags
| Feature | Crates | Effect |
|---|---|---|
defmt |
all | Derives defmt::Format on error types and key enums for embedded structured logging |
remote |
rm-frame |
Enables [RemoteControl] for decoding VT03/VT13 uplink control frames |
no_std Support
All crates are #![no_std] with no heap allocation. They can be used directly in bare-metal and RTOS environments.
Remote Control (Optional)
When the remote feature is enabled, rm-frame provides [RemoteControl] to decode DT7/DR16 RC receiver frames from VT03/VT13 vision links.
use RemoteControl;
let rc = new;
// Call from your DMA/interrupt handler
rc.update?;
// Read from any task
let ch = rc.right_horizontal; // i16, roughly [-660, 660]
let sw = rc.switch; // Switch::C / N / S
let w = rc.keyboard_w; // bool
let vx = rc.mouse_vx; // i16
Available inputs:
| Category | Members |
|---|---|
| Analog channels | right_horizontal, right_vertical, left_horizontal, left_vertical |
| Switch | switch (C / N / S) |
| Buttons | pause, left_fn, right_fn, trigger, wheel |
| Mouse | mouse_vx/vy/vz, left/mid/right_button |
| Keyboard | W S A D Shift Ctrl Q E R F G Z X C V B |
Examples
static SIG_BUFFER: = new;
pub static RC: RemoteControl = unsafe ;
pub async !
async ! >new;
loop
}
Reference
This library implements the RoboMaster University Series 2026 Communication Protocol V1.2.0 (2026-02-09).
See RoboMaster Resources Hub for official documentation and protocol details: RMU Communication Protocol