step.motion.drive¶
Classes¶
Drive forward with distance or condition-based termination. |
|
Drive backward with distance or condition-based termination. |
|
Strafe left with distance or condition-based termination. |
|
Strafe right with distance or condition-based termination. |
Module Contents¶
- class step.motion.drive.DriveForward(cm: float = None, speed: float = 1.0, until: step.condition.StopCondition = None, heading: float = None)¶
Bases:
_ConditionalDriveDrive forward with distance or condition-based termination.
Uses profiled PID motion control with a trapezoidal velocity profile. The robot accelerates, cruises, and decelerates while maintaining heading via IMU feedback. When
headingis given, the controller holds that absolute heading (degrees from heading reference) instead of the heading at start, preventing drift accumulation across consecutive drives.Requires
calibrate_distance()for distance-based mode. Requiresmark_heading_reference()when usingheading.- Parameters:
heading – Absolute heading in degrees from the heading reference to hold during this drive.
None(default) holds the heading at the start of the drive (relative mode).
Example:
drive_forward(25) # 25 cm, relative heading drive_forward(25, heading=90) # hold 90° absolute drive_forward(speed=0.8).until(on_black(s)) # until sensor
- class step.motion.drive.DriveBackward(cm: float = None, speed: float = 1.0, until: step.condition.StopCondition = None, heading: float = None)¶
Bases:
_ConditionalDriveDrive backward with distance or condition-based termination.
Identical to
drive_forward()but in reverse. Uses profiled PID motion control while maintaining heading via IMU feedback. Supports the sameheadingparameter for absolute heading hold.Requires
calibrate_distance()for distance-based mode. Requiresmark_heading_reference()when usingheading.- Parameters:
heading – Absolute heading in degrees from the heading reference to hold during this drive.
None(default) holds the heading at the start of the drive (relative mode).
Example:
drive_backward(20) drive_backward(20, heading=0) # hold 0° absolute drive_backward(speed=0.5).until(on_white(s))
- class step.motion.drive.StrafeLeft(cm: float = None, speed: float = 1.0, until: step.condition.StopCondition = None, heading: float = None)¶
Bases:
_ConditionalDriveStrafe left with distance or condition-based termination.
Requires a mecanum or omni-wheel drivetrain. The robot moves laterally to the left while maintaining heading via IMU feedback. Supports the same
headingparameter for absolute heading hold.Requires
mark_heading_reference()when usingheading.- Parameters:
heading – Absolute heading in degrees from the heading reference to hold during this strafe.
None(default) holds the heading at the start of the strafe (relative mode).
Example:
strafe_left(15) strafe_left(15, heading=90) # hold 90° absolute strafe_left(speed=0.6).until(on_black(s))
- class step.motion.drive.StrafeRight(cm: float = None, speed: float = 1.0, until: step.condition.StopCondition = None, heading: float = None)¶
Bases:
_ConditionalDriveStrafe right with distance or condition-based termination.
Requires a mecanum or omni-wheel drivetrain. The robot moves laterally to the right while maintaining heading via IMU feedback. Supports the same
headingparameter for absolute heading hold.Requires
mark_heading_reference()when usingheading.- Parameters:
heading – Absolute heading in degrees from the heading reference to hold during this strafe.
None(default) holds the heading at the start of the strafe (relative mode).
Example:
strafe_right(15) strafe_right(15, heading=0) # hold 0° absolute strafe_right(speed=0.6).until(on_black(s))