[sim] Add CAN message schema to wpilib-ws.yaml and add 2 CANMotor props (#6651)

Co-authored-by: CoolSpy3 <coolspythree@gmail.com>
This commit is contained in:
Dean Brettle
2024-05-24 12:56:34 -07:00
committed by GitHub
parent dc0e9712e6
commit 237ebfd0f2
2 changed files with 172 additions and 6 deletions

View File

@@ -261,12 +261,14 @@ C++/Java implementation note: these are created as SimDevice nodes where the dev
Only one of ``"supplyCurrent"`` or ``"motorCurrent"`` should be sent by the hardware; the other value should be set to zero. If ``"busVoltage"`` is not simulated it should also be set to zero.
| Data Key | Type | Description |
| -------------------- | ---------------- | ------------------------------------------------ |
| ``"<percentOutput"`` | Integer or Float | Percent output (-1 to 1 range) |
| ``">supplyCurrent"`` | Float | The supply current in amps as simulated/measured |
| ``">motorCurrent"`` | Float | The motor current in amps as simulated/measured |
| ``">busVoltage"`` | Float | The bus voltage as simulated/measured |
| Data Key | Type | Description |
| -------------------- | ---------------- | ----------------------------------------------------------------------------------- |
| ``"<percentOutput"`` | Integer or Float | Percent output (-1 to 1 range) |
| ``"<brakeMode"`` | Boolean | Whether to brake (true) or coast (false) when `\|percentOutput\| < neutralDeadband` |
| `"<neutralDeadband"` | Float | `\|percentOutput\|` below which `brakeMode` matters (0 to 1) |
| ``">supplyCurrent"`` | Float | The supply current in amps as simulated/measured |
| ``">motorCurrent"`` | Float | The motor current in amps as simulated/measured |
| ``">busVoltage"`` | Float | The bus voltage as simulated/measured |
#### CANEncoder

View File

@@ -52,6 +52,7 @@ components:
- $ref: "#/components/schemas/relayData"
- $ref: "#/components/schemas/solenoidData"
- $ref: "#/components/schemas/roborioData"
- $ref: "#/components/schemas/simdeviceData"
schemas:
accelData:
@@ -514,3 +515,166 @@ components:
">3v3_faults":
type: integer
description: "Number of faults on 3.3V rail"
canmotorData:
type: object
required:
- type
- device
properties:
type:
type: string
description: "Dummy type used for SimDevice type with device=CANMotor:*"
const: CANMotor
device:
type: string
description: "Should have the form CANMotor: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: "Dummy type used for SimDevice type with device=CANEncoder:*"
const: CANEncoder
device:
type: string
description: "Should have the form CANEncoder:ControllerClassName[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"
simdeviceData:
type: object
required:
- type
- device
oneOf:
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "(?!(DutyCycle|CAN(Motor|Encoder|Gyro|Accel|AIn|DIO|DutyCycle)):.+).+"
data:
type: object
additionalProperties:
type: string
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "DutyCycle:.+"
data:
$ref: "#/components/schemas/dutycycleData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANMotor:.+"
data:
$ref: "#/components/schemas/canmotorData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANEncoder:.+"
data:
$ref: "#/components/schemas/canencoderData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANGyro:.+"
data:
$ref: "#/components/schemas/gyroData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANAccel:.+"
data:
$ref: "#/components/schemas/accelData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANAIn:.+"
data:
$ref: "#/components/schemas/aiData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANDIO:.+"
data:
$ref: "#/components/schemas/dioData/properties/data"
- properties:
type:
type: string
const: SimDevice
device:
type: string
format: "CANDutyCycle:.+"
data:
$ref: "#/components/schemas/dutycycleData/properties/data"