Skip to Content
VectorLib

TrSensor

vectorlib::TrSensor — fields, methods, parameters and return types.


pub struct TrSensor

A distance sensor used for distance sensor resets (tr_sensor).

View source

Methods

Prop

Type

new

pub fn new(offset: impl Into<TrVector2>, sensor: impl DistanceDevice + 'static) -> Self

A sensor at offset (inches) from the centre of the robot.

Parameters

Returns

Self

View source

relative_square

pub fn relative_square(heading: f32) -> f32

Map a heading into [-45, 45): how far the robot is from square to the walls.

Parameters

Prop

Type

Returns

f32

View source

raw_distance

pub fn raw_distance(&self) -> TrDistance

The reading in inches, without correcting for heading or offset (distance()). A missing reading is 9999 with confidence 0.

Returns

TrDistance

View source

distance

pub fn distance(&self, heading: f32) -> TrDistance

The perpendicular distance from the centre of the robot to the wall the sensor faces, inches, for a robot at heading (distance(float heading)). A missing reading is 9999 with confidence 0.

Parameters

Prop

Type

Returns

TrDistance

View source