22. RobotController Configuration - m-marini/wheellyj GitHub Wiki

RobotController Configuration

The RobotController is configured through a YAML document that defines the timing parameters of the control loop and the calibration used to convert raw power supply measurements into voltages.

The configuration is validated against the controller-schema-2.0 JSON schema before the controller is created.

Configuration Parameters

Parameter Type Required Description
reactionInterval integer Yes Minimum simulation time (milliseconds) between two consecutive inference executions.
commandInterval integer Yes Minimum simulation time (milliseconds) between two command synchronization cycles.
supplyValues integer[2] Yes Two raw ADC values used for battery voltage calibration.
voltages number[2] Yes Voltages corresponding to the two calibration points defined in supplyValues.

Example Configuration

reactionInterval: 100
commandInterval: 50

supplyValues:
  - 512
  - 768

voltages:
  - 10.8
  - 12.6

Parameter Description

reactionInterval

Defines how frequently the controller is allowed to execute the inference algorithm.

The controller does not execute inference after every sensor event. Instead, it waits until the configured interval has elapsed since the previous execution.

A smaller value results in:

  • faster reactions;
  • higher CPU utilization.

A larger value results in:

  • lower computational load;
  • slower robot response.

commandInterval

Defines how frequently the controller synchronizes the desired robot command with the actual robot state.

During each synchronization cycle, the controller verifies whether the requested command has already been achieved. If not, the appropriate command is sent to the robot.

This mechanism avoids repeatedly transmitting identical commands while ensuring that command execution remains reliable.

supplyValues

Defines two raw measurements produced by the robot's power supply sensor.

These values represent the calibration points of the analog-to-digital converter (ADC).

The array must contain exactly two integer values.

Example:

supplyValues:
  - 520
  - 780

voltages

Defines the voltages corresponding to the raw values specified in supplyValues.

The array must contain exactly two floating-point values.

Example:

voltages:
  - 10.5
  - 12.6

Voltage Calibration

The controller computes the battery voltage using linear interpolation between the two calibration points.

Given:

Raw1  -> Voltage1
Raw2  -> Voltage2

every measured raw value is converted into a voltage using a linear mapping.

For example:

Raw value Voltage
520 10.5 V
650 11.55 V
780 12.6 V

This calibration allows the controller to convert hardware-specific ADC readings into meaningful physical values.

Validation Rules

The configuration is validated before the controller is created.

The following conditions must be satisfied:

  • reactionInterval must be present.
  • commandInterval must be present.
  • supplyValues must contain exactly two integers.
  • voltages must contain exactly two floating-point values.
  • The document must conform to the controller-schema-2.0 JSON schema.

If any validation fails, controller creation is aborted with an exception.

Internal Initialization

During initialization, the controller performs the following steps:

  1. Validates the YAML document.
  2. Reads the timing parameters.
  3. Reads the voltage calibration points.
  4. Creates a linear interpolation function for voltage conversion.
  5. Instantiates the RobotController with the configured parameters.

The resulting controller is immediately ready to be connected to a RobotApi instance.

Release

Current version: 0.27.0