tree: c32907cddc54d110ea15020f642642269882b97f [path history] [tgz]
  1. src/
  2. build.gradle
  3. CMakeLists.txt
  4. README.md
third_party/allwpilib/simulation/halsim_xrp/README.md

HAL XRP Client

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.

Configuration

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.

XRP Protocol

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 bytes1 byten bytes
uint16_t sequenceuint8_t control<Tagged Data>

Control Byte

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.

Tagged Data

The Tagged Data section can contain an arbitrary number of data blocks. Each block has the format below:

1 byte1 byten bytes
uint8_t sizeuint8_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:

TagDescription
0x12XRPMotor
0x13XRPServo
0x14DIO
0x15AnalogIn
0x16XRPGyro
0x17BuiltInAccel
0x18Encoder

XRPMotor

OrderData TypeDescription
0uint8_tID
1floatValue [-1.0, 1.0]

IDs: | ID | Description | |----|-------------| | 0 | Left Motor | | 1 | Right Motor | | 2 | Motor 3 | | 3 | Motor 4 |

XRPServo

OrderData TypeDescription
0uint8_tID
1floatValue [0.0, 1.0]

IDs: | ID | Description | |----|-------------| | 4 | Servo 1 | | 5 | Servo 2 |

DIO

OrderData TypeDescription
0uint8_tID
1uint8_tValue (True/False)

AnalogIn

OrderData TypeDescription
0uint8_tID
1floatValue

XRPGyro

OrderData TypeDescription
0floatrate_x (dps)
1floatrate_y (dps)
2floatrate_z (dps)
3floatangle_x (deg)
4floatangle_y (deg)
5floatangle_z (deg)

BuiltInAccel

OrderData TypeDescription
0floataccel_x (g)
1floataccel_y (g)
2floataccel_z (g)

Encoder

OrderData TypeDescription
0uint8_tID
1int32_tValue

IDs: | ID | Description | |----|---------------------| | 0 | Left Motor Encoder | | 1 | Right Motor Encoder | | 2 | Motor 3 Encoder | | 3 | Motor 4 Encoder |