task_motor module¶
task_motor.py
Cooperative task that wraps a PIController around a single Motor/Encoder pair on the Romi robot. Multiple instances are created (one per wheel) and run by the cooperative scheduler.
- States:
S0_INIT (0): One-shot initialization; transitions immediately to S1_WAIT. S1_WAIT (1): Waits for the go flag to be set before enabling the motor. S2_RUN (2): Runs closed-loop PI velocity control; transitions back to S1_WAIT when the go flag is cleared.
- class task_motor.task_motor(mot, enc, goFlag, kpVal, kiVal, setpoint, dataValues, timeValues, wheelDistance, motorVoltage, motorAngVelocity)[source]¶
Bases:
objectCooperative scheduler task for closed-loop velocity control of one motor.
Each instance owns a Motor, an Encoder, and a PIController. The task reads the encoder velocity, computes a PI correction, and drives the motor accordingly. Instantiate once per wheel (left and right).