TrChassis
vectorlib::TrChassis — fields, methods, parameters and return types.
pub struct TrChassisPerforms distance sensor resets (tr_chassis).
Create it while the robot is not moving.
Methods
Prop
Type
new
pub fn new(chassis: impl TrDrivebase + 'static, sensors: [TrSensor; 4]) -> SelfA TitanReset chassis on a plastic field. sensors are [north, east, south, west]:
the sensors facing the front, right, back and left of the robot.
Parameters
Prop
Type
Returns
Selfnew_with_field
pub fn new_with_field(
chassis: impl TrDrivebase + 'static,
sensors: [TrSensor; 4],
field_radius: f32,
) -> SelfLike TrChassis::new, with the field radius (see tr_fields).
Parameters
Prop
Type
Returns
Selfsensor
pub fn sensor(&self, index: usize) -> &TrSensorThe sensor in index: 0 north, 1 east, 2 south, 3 west.
Panics
If index is greater than 3.
Parameters
Prop
Type
Returns
&TrSensorquadrant_recursive
pub fn quadrant_recursive(mut heading: f32) -> f32Normalize a heading to [0, 360] by adding or subtracting whole turns.
Parameters
Prop
Type
Returns
f32can_position_exist
pub fn can_position_exist(pose: TrVector3) -> boolWhether the position is inside the field (not out of bounds).
Parameters
Prop
Type
Returns
boolget_quadrant_string
pub fn get_quadrant_string(quadrant: TrQuadrant) -> &'static strThe quadrant's name, as TitanReset spells it.
Parameters
Prop
Type
Returns
&'static strsensor_relevancy
pub fn sensor_relevancy(&self) -> TrQuadrantThe heading sector of the robot's current heading (which sensors face which walls).
Returns
TrQuadrantsensor_relevancy_for
pub fn sensor_relevancy_for(heading: f32) -> TrQuadrantThe heading sector of a heading normalized to [0, 360]:
(315, 45] → PosPos, (45, 135] → NegPos, (135, 225] → NegNeg,
(225, 315] → PosNeg.
Parameters
Prop
Type
Returns
TrQuadrantget_quadrant
pub fn get_quadrant(&self) -> TrQuadrantThe field quadrant of the robot's current position (PosPos on an axis).
Returns
TrQuadrantconf_avg
pub fn conf_avg(one: TrDistance, two: TrDistance) -> f32Average confidence of two readings.
Parameters
Prop
Type
Returns
f32get_position_calculation
pub fn get_position_calculation(&self, quadrant: TrQuadrant) -> TrConfPair<TrVector3>The position the sensors give in quadrant, using the robot's current heading.
Parameters
Prop
Type
Returns
TrConfPair<TrVector3>get_position_calculation_with
pub fn get_position_calculation_with(
&self,
quadrant: TrQuadrant,
heading: f32,
) -> TrConfPair<TrVector3>The position the sensors give in quadrant for a robot at heading, with the
confidence of the two readings used (0 if the position is out of bounds).
Parameters
Prop
Type
Returns
TrConfPair<TrVector3>perform_dsr
pub fn perform_dsr(&self) -> boolDistance sensor reset when the robot knows roughly where it is and where it faces: uses the quadrant of the current position. Returns whether the reset happened (the calculated position was in bounds and the readings had confidence).
Returns
boolperform_dsr_quad
pub fn perform_dsr_quad(&self, quadrant: TrQuadrant) -> boolDistance sensor reset in a given quadrant. Use after a movement that may have crossed quadrants, such as driving over a parking zone.
Parameters
Prop
Type
Returns
boolperform_dsr_init
pub fn perform_dsr_init(&self, quadrant: TrQuadrant, heading: f32) -> boolDistance sensor reset when the robot does not know where it is: sets the heading,
then resets in quadrant. Use before an autonomous starts, where the robot always
starts in a familiar place.
Parameters
Prop
Type
Returns
boolis_sensor_used
pub fn is_sensor_used(&self, r_sensor: i32) -> boolWhether a sensor (a tr_sensors flag) was used by the last position calculation.
Parameters
Prop
Type
Returns
booldebug_lines
pub fn debug_lines(&self) -> [(u8, String); 5]The lines TitanReset's debug screen (update_display) prints, as
(LLEMU line, text).
TitanReset reads the heading for this screen from an inertial-sensor pointer it never sets; this reads the drivebase heading instead.
Returns
[(u8, String); 5]start_location_recording
pub fn start_location_recording(&self, name: &str, date: Option<&str>, time: Option<&str>)Record the drivebase pose every 50 ms in a background task, to the file
<name>_<date>_<time>_<millis>.txt on the SD card, one x, y, heading line each.
date and time default to the date and time VectorLib was built, in the format of
C's __DATE__ ("Mar 7 2026") and __TIME__ ("17:36:11"); spaces in the date and
colons in the time become dashes. Starting a recording stops the previous one.
Parameters
Prop
Type
Returns
()stop_location_recording
pub fn stop_location_recording(&self)Stop the current location recording.
Returns
()