Files
allwpilib/simulation/halsim_ws_core/doc/wpilib-ws.yaml

709 lines
22 KiB
YAML

asyncapi: 2.0.0
info:
title: WPILib WebSocket Remote Endpoint API
version: "1.1.0"
description: |
API to route WPILib HAL calls over WebSockets.
license:
name: WPILib BSD
channels:
wpilibws:
description: General channel for WPILib WebSocket messages
publish:
operationId: wpilibwsPublish
message:
$ref: "#/components/messages/wpilibwsMsg"
subscribe:
operationId: wpilibwsSubscribe
message:
$ref: "#/components/messages/wpilibwsMsg"
components:
messages:
wpilibwsMsg:
title: WPILib WebSocket Message
summary: Message envelope. Note that the "data" field contains a diff of the current state of a particular device. E.g. If only the "value" changes for a DIO device, then only the "<>value" field will be sent.
contentType: application/json
examples:
- payload:
type: PWM
device: "1"
data:
"<duty_cycle": 0.5
- payload:
type: DIO
device: "3"
data:
"<init": true
payload:
type: object
oneOf:
- $ref: "#/components/schemas/accelData"
- $ref: "#/components/schemas/addressableLEDData"
- $ref: "#/components/schemas/aiData"
- $ref: "#/components/schemas/dioData"
- $ref: "#/components/schemas/dpwmData"
- $ref: "#/components/schemas/driverstationData"
- $ref: "#/components/schemas/dutycycleData"
- $ref: "#/components/schemas/encoderData"
- $ref: "#/components/schemas/gyroData"
- $ref: "#/components/schemas/halData"
- $ref: "#/components/schemas/joystickData"
- $ref: "#/components/schemas/pcmData"
- $ref: "#/components/schemas/pwmData"
- $ref: "#/components/schemas/solenoidData"
- $ref: "#/components/schemas/roborioData"
- $ref: "#/components/schemas/canmotorData"
- $ref: "#/components/schemas/canencoderData"
- $ref: "#/components/schemas/cangyroData"
- $ref: "#/components/schemas/canaccelData"
- $ref: "#/components/schemas/canainData"
- $ref: "#/components/schemas/candioData"
- $ref: "#/components/schemas/candutycycleData"
- $ref: "#/components/schemas/simdeviceData"
schemas:
addressableLEDData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: AddressableLED
device:
type: string
description: Arbitrary device number
data:
type: object
description: "Addressable LED Data (type: AddressableLED, device: arbitrary)"
properties:
<init:
type: boolean
description: "If the led strip is initialized in the robot program"
"<output_port":
type: integer
description: "DIO pin number"
"<length":
type: integer
description: "The number of leds in the strip"
"<running":
type: boolean
description: "Whether the strip is outputting data"
"<data":
type: array
description: "One value per led"
items:
type: object
description: "An object with \"r\", \"g\", and \"b\" keys, representing the rgb (0-255) components of the color"
properties:
r:
type: integer
g:
type: integer
b:
type: integer
aiData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: AI
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Analog Input Data (type: AI, device: channel number)"
properties:
<init:
type: boolean
description: "If analog input is initialized in the robot program"
">voltage":
type: number
description: "Input voltage, in volts"
dioData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: DIO
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Digital Input/Output Data (type: DIO, device: channel number)"
properties:
<init:
type: boolean
description: "If DIO is initialized in the robot program"
<input:
type: boolean
description: "True if input, false if output"
<>value:
type: boolean
description: "Input or output state"
"<pulse_length":
type: number
description: "Reserved for future use"
dpwmData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: dPWM
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Duty Cycle Output Data (type: dPWM, device: channel number)"
properties:
<init:
type: boolean
description: "If output is initialized in the robot program"
<duty_cycle:
type: number
description: "Duty cycle %"
minimum: 0.0
maximum: 1.0
<dio_pin:
type: integer
description: "DIO pin number"
driverstationData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: DriverStation
device:
type: string
description: Should be left blank
data:
type: object
description: "Driver Station Data (type: DriverStation)"
properties:
">new_data":
type: boolean
description: "One shot. If set to true in a message, notifies the robot program that new DS and Joystick data is available."
">enabled":
type: boolean
description: "True to enable the robot program"
">autonomous":
type: boolean
description: "True for autonomous mode; false for teleoperated mode"
">test":
type: boolean
description: "True for test mode; false for other modes"
">estop":
type: boolean
description: "True to emergency stop (no motor outputs)"
">fms":
type: boolean
description: "True if the DS is connected to a Field Management System (FMS)"
">ds":
type: boolean
description: "True if a DS application is connected"
">station":
type: string
description: "Station color and number; supported values are 'red1', 'red2', 'red3', 'blue1', 'blue2', 'blue3'."
">match_time":
type: number
description: "Match time countdown, in seconds, for each match period (e.g. for 15 second period, starts at 15 and counts down to 0). If not in a match, -1."
">game_data":
type: string
description: "Game-specific data; arbitrary string contents"
dutycycleData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: DutyCycle
device:
type: string
description: Arbitrary device name
data:
type: object
description: "Duty Cycle Input Data (type: DutyCycle, device: channel number)"
properties:
">connected":
type: boolean
description: "True if the encoder is connected"
">position":
type: number
description: "The position in rotations"
encoderData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: Encoder
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Quadrature Encoder Data (type: Encoder, device: channel number)"
properties:
<init:
type: boolean
description: "If encoder is initialized in the robot program"
<channel_a:
type: integer
description: "Digital channel number for 'A' phase"
<channel_b:
type: integer
description: "Digital channel number for 'B' phase"
<samples_to_avg:
type: integer
description: "Number of samples to average for period measurement"
">count":
type: integer
description: "Accumulated count (pulses)"
">period":
type: number
description: "Period between pulses in seconds"
"<reverse_direction":
type: boolean
description: "If the encoder direction should be inverted"
gyroData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: Gyro
device:
type: string
description: Arbitrary device name
data:
type: object
description: "Gyro Data (type: Gyro, device: channel number)"
properties:
<init:
type: boolean
description: "If gyro is initialized in the robot program"
<range:
type: number
description: "Gyro range in degrees/second (optional)"
">connected":
type: boolean
description: "True if the gyro is connected"
">angle_x":
type: number
description: "The gyro angle in degrees"
">angle_y":
type: number
description: "The gyro angle in degrees"
">angle_z":
type: number
description: "The gyro angle in degrees"
">rate_x":
type: number
description: "The current gyro angular rate of change in degrees/second"
">rate_y":
type: number
description: "The current gyro angular rate of change in degrees/second"
">rate_z":
type: number
description: "The current gyro angular rate of change in degrees/second"
halData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: HAL
device:
type: string
description: "\"HAL\""
const: HAL
data:
type: object
description: "HAL Data (type: HAL, device: HAL)"
properties:
">sim_periodic_before":
type: boolean
description: "Sent by the robot before running periodic simulation functions"
">sim_periodic_after":
type: boolean
description: "Sent by the robot after running periodic simulation functions"
joystickData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: Joystick
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Joystick Data (type: Joystick, device: channel number)"
properties:
">axes":
type: array
items:
type: number
description: "Value of an individual axis on this joystick"
minimum: -1.0
maximum: 1.0
">povs":
type: array
description: "One array element per POV; value is a"
items:
type: integer
description: "State of all POV switches on this joystick; an angle in degrees of the POV (e.g. 0, 90, 315) if pressed, or -1 if the POV is not pressed"
">buttons":
type: array
description: State of all buttons on this joystick
items:
type: boolean
description: Pressed state of an individual button
<rumble_left:
type: number
description: "Left rumble"
minimum: 0.0
maximum: 1.0
<rumble_right:
type: number
description: "Right rumble"
minimum: 0.0
maximum: 1.0
<outputs:
type: integer
description: "LED Output Color (0xRRGGBB)"
pcmData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CTREPCM
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "PCM Output Data (type: PCM, device: module number)"
properties:
<init:
type: boolean
description: "If PCM is initialized in the robot program"
">on":
type: boolean
description: "Whether the compressor is running"
"<closed_loop":
type: boolean
description: "Whether closed-loop control is enabled"
">pressure_switch":
type: boolean
description: "The value of the pressure switch"
">current":
type: number
description: "The amount of current being drawn by the compressor, in Amps"
pwmData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: PWM
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "PWM Output Data (type: PWM, device: channel number)"
properties:
<init:
type: boolean
description: "If PWM is initialized in the robot program"
"<raw":
type: integer
description: "The pulse time in microseconds"
"<output_period":
type: integer
description: "Scales the PWM signal by squelching setting a 2-bit mask of outputs to squelch (ex. `1` -> squelch every other value; `3` -> squelch 3 of 4 values)"
solenoidData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: Solenoid
device:
type: string
description: Device Identifier (usually channel)
data:
type: object
description: "Solenoid Data (type: Solenoid, device: channel number)"
properties:
<init:
type: boolean
description: "If Solenoid is initialized in the robot program"
<output:
type: boolean
description: "The state of the solenoid"
roborioData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: RoboRIO
device:
type: string
description: Should be left blank
data:
type: object
description: "RoboRIO Data (type: RoboRIO)"
properties:
">vin_voltage":
type: number
description: "Vin rail voltage"
">3v3_voltage":
type: number
description: "3.3V rail voltage"
">3v3_current":
type: number
description: "3.3V rail current"
">3v3_active":
type: boolean
description: "True if 3.3V rail active, false if inactive"
">3v3_faults":
type: integer
description: "Number of faults on 3.3V rail"
canmotorData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANMotor
device:
type: string
description: "Should have the form ControllerClassName[id]"
data:
type: object
description: "CANMotor Data"
properties:
<init:
type: boolean
description: "If CANMotor is initialized in the robot program"
"<percentOutput":
type: number
description: "Percent Output"
minimum: -1.0
maximum: 1.0
">supplyCurrent":
type: number
description: "Supply current in Amps"
minimum: 0.0
">motorCurrent":
type: number
description: "Motor current in Amps"
minimum: 0.0
">busVoltage":
type: number
description: "Bus voltage in Volts"
minimum: 0.0
"<neutralDeadband":
type: number
description: "Neutral Deadband"
minimum: 0
maximum: 1.0
"<brakeMode":
type: boolean
description: "Is in brake mode"
canencoderData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANEncoder
device:
type: string
description: "Should have the form EncoderClassName[id]"
data:
type: object
description: "CANEncoder Data"
properties:
<init:
type: boolean
description: "If CANEncoder is initialized in the robot program"
">position":
type: number
description: "Position in rotations"
">velocity":
type: number
description: "Velocity in rotations per second"
cangyroData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANGyro
device:
type: string
description: "Should have the form GyroClassName[id]"
data:
$ref: "#/components/schemas/gyroData/properties/data"
canaccelData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANAccel
device:
type: string
description: "Should have the form AccelClassName[id]"
data:
$ref: "#/components/schemas/accelData/properties/data"
canainData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANAIn
device:
type: string
description: "Should have the form AnalogInputClassName[id]"
data:
$ref: "#/components/schemas/aiData/properties/data"
candioData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANDIO
device:
type: string
description: "Should have the form DIOClassName[id]"
data:
$ref: "#/components/schemas/dioData/properties/data"
candutycycleData:
type: object
required:
- type
- device
properties:
type:
type: string
description: Device Type (e.g. DIO/AI/PWM/Encoder etc)
const: CANDutyCycle
device:
type: string
description: "Should have the form DutyCycleClassName[id]"
data:
$ref: "#/components/schemas/dutycycleData/properties/data"
simdeviceData:
type: object
required:
- type
- device
properties:
type:
type: string
const: SimDevice
device:
type: string
data:
type: object
additionalProperties:
type: string