Hardware configuration¶
Robot.configure() declares which sensors and effectors are connected to the
robot. Call it exactly once, before Robot.run().
robot.configure(
sensors={"S2": IMU, "S3": RadioBeacon},
effectors={"A1": Thruster, "A5": Servo},
pid={"A1": (0.8, 0.1, 0.0)},
)
Port declarations¶
The keys are port names and the values are HELM classes:
| Mapping | Required prefix | Supported types |
|---|---|---|
sensors |
S |
IMU, RadioBeacon |
effectors |
A |
Thruster, Servo |
The current Python validation checks the prefix, not a fixed numeric port list.
For example, "S2" and "A1" have the expected form. The robot still verifies
the complete declaration and can reject unsupported physical ports or hardware.
Pass the classes themselves, not instances:
PID gains¶
The optional pid mapping supplies (kp, ki, kd) current-loop gains for
thrusters:
Each PID entry must:
- refer to an effector declared in the same call;
- refer to a
Thruster, not aServo; - contain exactly three numeric values.
Configuration verification¶
During configuration, the library:
- validates the local declarations;
- opens its local connection to the HELM extension;
- sends the configuration to the robot through the extension;
- waits for the parsed configuration to be echoed back;
- raises an error if the echo does not match.
This fail-loud behavior prevents a program from arming with a different hardware layout than the one the student declared.
Accessing configured hardware¶
Explicit accessors work for every configured object:
robot.effector(port) returns either effector type. The typed accessors raise
TypeError if the port contains the wrong kind.
Sensor shortcuts¶
When exactly one sensor of a given type is configured, the robot adds a lowercase shortcut:
If two sensors have the same type, that shortcut is not created because it would be ambiguous:
robot.configure(
sensors={"S1": IMU, "S2": IMU},
effectors={},
)
front_imu = robot.sensor("S1")
rear_imu = robot.sensor("S2")
Prefer robot.sensor(port) in reusable code and whenever multiple sensors of
one type may be installed.