step.servo.preset¶
ServoPreset — named positions for a servo, generated from project YAML.
A ServoPreset wraps a raw Servo and provides callable attributes
for each named position. It is the recommended way to interact with servos
that have well-defined positions (e.g., “open”, “closed”, “up”, “down”).
Calling a position without speed uses an instant servo() command.
Calling with speed uses SlowServo for eased motion.
The optional offset shifts all positions by a fixed amount — useful
when a servo is remounted slightly off from its original alignment.
Instances are normally code-generated from raccoon.project.yml
into defs.py, so users just import and call:
from src.hardware.defs import Defs
# In a mission sequence:
Defs.pom_arm.down() # instant
Defs.pom_arm.up(speed=250) # eased at 250 deg/s
YAML definition:
definitions:
pom_arm:
type: Servo
port: 1
offset: 0 # optional, default 0
positions:
down: 0
above_pom: 50
up: 90
Classes¶
Named servo positions with optional mounting offset. |
Module Contents¶
- class step.servo.preset.ServoPreset(servo: raccoon.hal.Servo, positions: dict[str, float], offset: float = 0)¶
Named servo positions with optional mounting offset.
Each position becomes a callable attribute that returns a Step.
- Parameters:
servo – The underlying
Servohardware device.positions – Mapping of position name to angle in degrees.
offset – Fixed angle offset added to every position (default 0).
- property device: raccoon.hal.Servo¶
The underlying Servo hardware device, for raw access.