Skip to Content
VectorLib

TrackingWheel

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


pub struct TrackingWheel

A tracking wheel: an encoder (or motor group) and the geometry to turn it into distance.

View source

Methods

Prop

Type

new

pub fn new(
        encoder: impl Into<TrackingEncoder>,
        wheel_diameter: f32,
        distance: f32,
        gear_ratio: f32,
    ) -> Self

Create a tracking wheel from a rotation sensor or an ADI encoder.

  • encoder — a vexide RotationSensor or AdiEncoder (or a TrackingEncoder)
  • wheel_diameter — the diameter of the wheel, in inches (see Omniwheel)
  • distance — distance between the tracking wheel and the center of rotation, in inches. Same sign convention as LemLib: negative is left / back.
  • gear_ratio — gear ratio of the tracking wheel (LemLib default 1), defined as output / input



// pros::Rotation verticalEnc(-11);
// lemlib::TrackingWheel vertical(&verticalEnc, lemlib::Omniwheel::NEW_275, -2.5);
let vertical_enc = RotationSensor::new(peripherals.port_11, Direction::Reverse);
let vertical = TrackingWheel::new(vertical_enc, Omniwheel::NEW_275, -2.5, 1.0);

Parameters

Prop

Type

Returns

Self

View source

from_motors

pub fn from_motors(
        motors: Rc<RefCell<MotorGroup>>,
        wheel_diameter: f32,
        distance: f32,
        rpm: f32,
    ) -> Self

Create a "tracking wheel" from drivetrain motors (LemLib's MotorGroup* constructor).

  • motors — the motor group
  • wheel_diameter — the diameter of the drivetrain wheels, in inches
  • distance — half the track width, negative for the left side
  • rpm — theoretical maximum rpm of the drivetrain wheels

Parameters

Prop

Type

Returns

Self

View source

reset

pub fn reset(&mut self)

Reset the tracking wheel position to 0.

Returns

()

View source

get_distance_traveled

pub fn get_distance_traveled(&self) -> f32

Get the distance traveled by the tracking wheel, in inches.

Returns

f32

View source

get_offset

pub fn get_offset(&self) -> f32

Get the offset of the tracking wheel from the center of rotation.

Returns

f32

View source

get_type

pub fn get_type(&self) -> i32

Get the type of tracking wheel: 0 for an encoder, 1 for motors.

Returns

i32

View source