Distance sensor reset
Correct odometry from the field walls with TitanReset.
TitanReset corrects odometry from the field walls. Four distance sensors face the front, right, back and left of the robot. From the robot's heading it picks the two that face the walls of its quadrant, corrects each reading for how far the robot is from square, and sets the position.
Set up the sensors
Offsets are in inches from the robot's tracking centre: x along the way the sensor faces, y across it, positive to the right.
use vectorlib::titan_reset::{TrChassis, TrQuadrant, TrSensor, tr_fields};
let dsr = TrChassis::new(
chassis.clone(),
[
TrSensor::new([4.75, -4.625], DistanceSensor::new(peripherals.port_19)), // front
TrSensor::new([5.25, -1.0], DistanceSensor::new(peripherals.port_8)), // right
TrSensor::new([5.823, 4.691], DistanceSensor::new(peripherals.port_3)), // back
TrSensor::new([5.25, -1.0], DistanceSensor::new(peripherals.port_4)), // left
],
);
// metal field perimeter instead of plastic:
// TrChassis::new_with_field(chassis.clone(), sensors, tr_fields::METAL);Reset the position
| Call | When to use it |
|---|---|
dsr.perform_dsr() | The robot roughly knows where it is: uses the quadrant of the current pose. |
dsr.perform_dsr_quad(TrQuadrant::NegPos) | After crossing quadrants, for example over a parking zone. |
dsr.perform_dsr_init(TrQuadrant::NegNeg, 90.0) | Before autonomous: sets the heading, then the position from the walls. |
Each returns false and leaves the pose alone when the result would be out of bounds or the readings have no confidence. The heading is never changed except by perform_dsr_init.
Stay close to square
DSR works within about 20–30° of square to the walls. Further off, near a corner, a beam reaches the neighbouring wall first. That is a limit of the method, not of the port.
Record the robot's path
// writes SKILLS_<date>_<time>_<ms>.txt to the SD card, one "x, y, heading" line every 50 ms
dsr.start_location_recording("SKILLS", None, None);
dsr.stop_location_recording();TrChassis::debug_lines() returns the five lines of TitanReset's debug screen (quadrants, sensors used, readings, calculated and current pose) for printing to the brain or the terminal.