Capability 001: Forward Drive Commands and Status Queries¶
Status: Accepted
Context¶
The robot and its Drive are described in the mission statement. The Drive consists of two Motor Controller Boards with two motor outputs each. They speak UART only, in a fixed binary format, and run their released firmware unchanged. The Bridge therefore relays the CAN messages of the Drive to the boards. It is passive: it translates and distributes, but decides nothing.
References¶
- CAN messages:
drive.dbc - UART protocol, including 115200 8N1: hoverboard-firmware v1.0.0,
command_api.md - CAN identifiers: ADR-001 and the CAN identifier allocation
Mapping¶
| CAN message | Board 1 | Board 2 |
|---|---|---|
| DriveCommand (motor 1, 2, 3) | Command: left = motor 1, right = motor 2 | Command: left = motor 3, right = 0 |
| StatusQuery | Query | Query |
Functional Requirements¶
- The Bridge splits each Drive Command across the boards as mapped.
- It translates each message into the UART format, including start marker and checksum.
- It passes values on unchanged: no checking, limiting, or scaling.
- Messages of other subsystems never reach the software; the acceptance filter of the CAN controller drops them.
Non-Functional Requirements¶
- At most 10 ms from the complete reception of a CAN message to the start of the UART transmission, measured with a logic analyzer.
- Load: one Drive Command every 250 ms, Status Queries on demand.
Error Handling¶
- CAN errors (error flags, bus-off) are reported as plain text over USB serial, at most once per second.
- When the transmit buffer of a board is full, the new message evicts the oldest one, and the eviction is reported over USB serial.
- Before its initialization is complete, the Bridge sends nothing.
Solution Constraints¶
- The CAN receive interrupt translates the message, puts the result into the transmit buffers (one per board), and starts the transmission.
- UART transmission is interrupt-driven.
- Interrupts never write to USB serial. They count errors, and the main loop reports them.
- The transmit buffers hold two frames each. Eviction moves the read index, so it runs with interrupts disabled.
Out of Scope¶
- Checking, limiting, or scaling values
- Repeating or refreshing commands (mission statement, principle Safe when silent)
- Timeout supervision: each board stops on its own after about 800 ms without a command
- The direction from the boards to the CAN bus
Acceptance Criteria¶
- DriveCommand (300, −300, 100): board 1 receives Command (300, −300), board 2 receives Command (100, 0), both with a valid checksum.
- DriveCommand (5000, 0, 0): board 1 receives 5000 unchanged.
- StatusQuery: each board receives one Query.
- CAN bus error: reported over USB serial, no UART frame is sent.
- Full transmit buffer: the oldest message is evicted, and the eviction is reported over USB serial.
- Under the load of NFR 2: at most 10 ms delay.
Test vectors for criteria 1 to 3, in hexadecimal bytes as they appear on the wire:
| Criterion | CAN (identifier: payload) | Board 1 (UART) | Board 2 (UART) |
|---|---|---|---|
| 1 | 08200001: 2c 01 d4 fe 64 00 |
cd ab 2c 01 d4 fe 35 54 |
cd ab 64 00 00 00 a9 ab |
| 2 | 08200001: 88 13 00 00 00 00 |
cd ab 88 13 00 00 45 b8 |
cd ab 00 00 00 00 cd ab |
| 3 | 08200002: (no payload) |
c1 ab c1 ab |
c1 ab c1 ab |
Decisions¶
- The robot sees one Drive, not two boards: one Drive Command and one Status Query for the whole Drive.
A later CAN board with three motor outputs can replace the Bridge without a change to
drive.dbc. - Motor 3 is connected to the left output of board 2; the right output receives 0.
- The Superordinate Controller computes the kinematics; the Bridge receives motor speeds.
- The Bridge deviates from the CAN bus guideline to keep it small:
- The encode and decode code is written by hand, because
drive.dbchas two messages only. Round-trip tests check it against the values indrive.dbc. - The receive interrupt translates instead of only enqueuing, because translation is short and bounded and saves a second buffer.
- The Bridge supervises no timeouts; the boards do.