step.motion.sensor_group

SensorGroup: pre-bind IR sensor pairs with default threshold, speed, and PID gains so mission code doesn’t repeat them on every call.

Usage:

from raccoon.step.motion.sensor_group import SensorGroup

front = SensorGroup(
    left=front_left_ir,
    right=front_right_ir,
)

# In a mission:
front.lineup_on_black()
front.drive_until_black()
front.drive_over_line()
front.follow_right_edge(cm=125)

# Override defaults per-call:
front.lineup_on_black(threshold=0.5)
front.strafe_left_until_black(speed=0.3, threshold=0.3)

# Single-sensor access for raw builder calls:
strafe_left(speed=0.3).until(on_black(front.right))

Classes

SensorGroup

A named sensor pair with pre-bound defaults for threshold, speed, and PID.

Module Contents

class step.motion.sensor_group.SensorGroup(left=None, right=None, threshold: float = 0.7, speed: float = 1.0, follow_speed: float = 0.8, follow_kp: float = 0.5, follow_ki: float = 0.02, follow_kd: float = 0.0)

A named sensor pair with pre-bound defaults for threshold, speed, and PID.

Provides convenience methods for common sensor-triggered operations: lineup, drive-until, strafe-until, and line-following. All methods return Step builders that can be used directly in seq([...]).

Parameters:
  • left – IR sensor mounted on the left side (or None).

  • right – IR sensor mounted on the right side (or None).

  • threshold – Default confidence threshold (0.0–1.0) for black/white detection. Defaults to 0.7.

  • speed – Default motion speed fraction (0.0–1.0). Defaults to 1.0.

  • follow_speed – Default speed for line-following. Defaults to 0.8.

  • follow_kp – Proportional gain for line-follow PID. Defaults to 0.5.

  • follow_ki – Integral gain for line-follow PID. Defaults to 0.02.

  • follow_kd – Derivative gain for line-follow PID. Defaults to 0.0.

left = None
right = None
lineup_on_black(threshold=None)
lineup_on_white(threshold=None)
lineup(target=None, threshold=None)
backward_lineup_on_black()
backward_lineup_on_white()
drive_until_black(speed=None, threshold=None)
drive_until_white(speed=None, threshold=None)
drive_over_line(speed=None, threshold=None)

Drive forward through black then white (crosses one line).

drive_backward_until_black(sensor=None, speed=None, threshold=None)
strafe_left_until_black(sensor=None, speed=None, threshold=None)
strafe_right_until_black(sensor=None, speed=None, threshold=None)
strafe_right_until_white(sensor=None, speed=None, threshold=None)
follow_right_edge(cm, speed=None)
follow_right_until_black(speed=None)