This is an extension that provides a client version of the XRP protocol for transmitting robot hardware interface state to an XRP robot over UDP.
The XRP client has a number of configuration options available through environment variables.
HALSIMXRP_HOST
: The host to connect to. Defaults to localhost.
HALSIMXRP_PORT
: The port number to connect to. Defaults to 3540.
The WPILib -> XRP protocol is binary-based to save on bandwidth due to hardware limitations of the XRP robot. The messages to/from the XRP follow a the format below:
2 bytes | 1 byte | n bytes |
---|---|---|
uint16_t sequence | uint8_t control | <Tagged Data> |
The control byte is used to indicate the current enabled
state of the WPILib robot code. When this is set to 1
, the robot is enabled, and when it is set to 0
it is disabled.
Messages originating from the XRP have an unspecified value for the control byte.
The Tagged Data
section can contain an arbitrary number of data blocks. Each block has the format below:
1 byte | 1 byte | n bytes |
---|---|---|
uint8_t size | uint8_t tagID | <payload> |
The size
byte encodes the size of the data block, excluding itself. Thus the smallest block size is 2 bytes, with a size value of 1 (1 size byte, 1 tag byte, 0 payload bytes). Maximum size of the payload is 254 bytes.
Utilizing tagged data blocks allows us to send multiple pieces of data in a single UDP packet. The tags currently implemented for the XRP are as follows:
Tag | Description |
---|---|
0x12 | XRPMotor |
0x13 | XRPServo |
0x14 | DIO |
0x15 | AnalogIn |
0x16 | XRPGyro |
0x17 | BuiltInAccel |
0x18 | Encoder |
Order | Data Type | Description |
---|---|---|
0 | uint8_t | ID |
1 | float | Value [-1.0, 1.0] |
IDs: | ID | Description | |----|-------------| | 0 | Left Motor | | 1 | Right Motor | | 2 | Motor 3 | | 3 | Motor 4 |
Order | Data Type | Description |
---|---|---|
0 | uint8_t | ID |
1 | float | Value [0.0, 1.0] |
IDs: | ID | Description | |----|-------------| | 4 | Servo 1 | | 5 | Servo 2 |
Order | Data Type | Description |
---|---|---|
0 | uint8_t | ID |
1 | uint8_t | Value (True/False) |
Order | Data Type | Description |
---|---|---|
0 | uint8_t | ID |
1 | float | Value |
Order | Data Type | Description |
---|---|---|
0 | float | rate_x (dps) |
1 | float | rate_y (dps) |
2 | float | rate_z (dps) |
3 | float | angle_x (deg) |
4 | float | angle_y (deg) |
5 | float | angle_z (deg) |
Order | Data Type | Description |
---|---|---|
0 | float | accel_x (g) |
1 | float | accel_y (g) |
2 | float | accel_z (g) |
Order | Data Type | Description |
---|---|---|
0 | uint8_t | ID |
1 | int32_t | Value |
IDs: | ID | Description | |----|---------------------| | 0 | Left Motor Encoder | | 1 | Right Motor Encoder | | 2 | Motor 3 Encoder | | 3 | Motor 4 Encoder |