LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
light::tracking_wheel Class Reference

Single tracking wheel for odometry. More...

#include <tracking_wheel.hpp>

Public Member Functions

 tracking_wheel (std::vector< int > ports, double wheel_diameter, double distance_to_center=0.0, double ratio=1.0)
 Creates a new tracking wheel with an ADI Encoder.
 
 tracking_wheel (int smart_port, std::vector< int > ports, double wheel_diameter, double distance_to_center=0.0, double ratio=1.0)
 Creates a new tracking wheel with an ADI Encoder plugged into a 3-wire expander.
 
 tracking_wheel (int port, double wheel_diameter, double distance_to_center=0.0, double ratio=1.0)
 Creates a new tracking wheel with a Rotation sensor.
 
double get ()
 Returns how far the wheel has traveled in inches.
 
double get_raw ()
 Returns the raw sensor value.
 
void distance_to_center_set (double input)
 Sets the distance to the center of the robot.
 
double distance_to_center_get ()
 Returns the distance to the center of the robot.
 
void distance_to_center_flip_set (bool input)
 Sets the distance to the center to be flipped to negative or not.
 
bool distance_to_center_flip_get ()
 Returns if the distance to center is flipped or not.
 
void reset ()
 Resets your sensor.
 
double ticks_per_inch ()
 Returns the constant for how many ticks is 1 inch.
 
void ticks_per_rev_set (double input)
 Sets the amount of ticks per revolution of your sensor.
 
double ticks_per_rev_get ()
 Returns the amount of ticks per revolution of your sensor.
 
void ratio_set (double input)
 Sets the gear ratio for your tracking wheel.
 
double ratio_get ()
 Returns the gear ratio for your tracking wheel.
 
void wheel_diameter_set (double input)
 Sets the diameter of your wheel.
 
double wheel_diameter_get ()
 Returns the diameter of your wheel.
 

Public Attributes

pros::adi::Encoder adi_encoder
 Backing ADI encoder (used when constructed from ADI ports).
 
pros::Rotation smart_encoder
 Backing Rotation sensor (used when constructed from a smart port).
 

Detailed Description

Single tracking wheel for odometry.

Construct from either an ADI encoder pair, an ADI encoder via a 3-wire expander, or a smart Rotation sensor. The class then reports distance traveled (inches) and exposes the offset to the robot center used by the odom kinematics.

Definition at line 30 of file tracking_wheel.hpp.

Constructor & Destructor Documentation

◆ tracking_wheel() [1/3]

light::tracking_wheel::tracking_wheel ( std::vector< int >  ports,
double  wheel_diameter,
double  distance_to_center = 0.0,
double  ratio = 1.0 
)

Creates a new tracking wheel with an ADI Encoder.

Parameters
ports{'A', 'B'}. make the encoder negative if reversed
wheel_diameterassumed inches, this is the diameter of your wheel
distance_to_centerthe distance to the center of your robot, this is used for tracking
ratiothe gear ratio of your tracking wheel. if it's not geared, this should be 1.0

◆ tracking_wheel() [2/3]

light::tracking_wheel::tracking_wheel ( int  smart_port,
std::vector< int >  ports,
double  wheel_diameter,
double  distance_to_center = 0.0,
double  ratio = 1.0 
)

Creates a new tracking wheel with an ADI Encoder plugged into a 3-wire expander.

Parameters
smart_portthe smart port your ADI Expander is plugged into
ports{'A', 'B'}. make the encoder negative if reversed
wheel_diameterassumed inches, this is the diameter of your wheel
distance_to_centerthe distance to the center of your robot, this is used for tracking
ratiothe gear ratio of your tracking wheel. if it's not geared, this should be 1.0

◆ tracking_wheel() [3/3]

light::tracking_wheel::tracking_wheel ( int  port,
double  wheel_diameter,
double  distance_to_center = 0.0,
double  ratio = 1.0 
)

Creates a new tracking wheel with a Rotation sensor.

Parameters
portthe port your Rotation sensor is plugged into, make this negative if reversed
wheel_diameterassumed inches, this is the diameter of your wheel
distance_to_centerthe distance to the center of your robot, this is used for tracking
ratiothe gear ratio of your tracking wheel. if it's not geared, this should be 1.0

Member Function Documentation

◆ distance_to_center_flip_get()

bool light::tracking_wheel::distance_to_center_flip_get ( )

Returns if the distance to center is flipped or not.

False is not, true is.

◆ distance_to_center_flip_set()

void light::tracking_wheel::distance_to_center_flip_set ( bool  input)

Sets the distance to the center to be flipped to negative or not.

Parameters
inputflips distance to center to negative. false leaves it alone, true flips it

◆ distance_to_center_get()

double light::tracking_wheel::distance_to_center_get ( )

Returns the distance to the center of the robot.

◆ distance_to_center_set()

void light::tracking_wheel::distance_to_center_set ( double  input)

Sets the distance to the center of the robot.

Parameters
inputdistance to the center of your robot in inches

◆ get()

double light::tracking_wheel::get ( )

Returns how far the wheel has traveled in inches.

◆ get_raw()

double light::tracking_wheel::get_raw ( )

Returns the raw sensor value.

◆ ratio_get()

double light::tracking_wheel::ratio_get ( )

Returns the gear ratio for your tracking wheel.

◆ ratio_set()

void light::tracking_wheel::ratio_set ( double  input)

Sets the gear ratio for your tracking wheel.

Parameters
inputgear ratio of tracking wheel

◆ reset()

void light::tracking_wheel::reset ( )

Resets your sensor.

◆ ticks_per_inch()

double light::tracking_wheel::ticks_per_inch ( )

Returns the constant for how many ticks is 1 inch.

◆ ticks_per_rev_get()

double light::tracking_wheel::ticks_per_rev_get ( )

Returns the amount of ticks per revolution of your sensor.

◆ ticks_per_rev_set()

void light::tracking_wheel::ticks_per_rev_set ( double  input)

Sets the amount of ticks per revolution of your sensor.

This is useful for custom encoders.

Parameters
inputticks per revolution

◆ wheel_diameter_get()

double light::tracking_wheel::wheel_diameter_get ( )

Returns the diameter of your wheel.

◆ wheel_diameter_set()

void light::tracking_wheel::wheel_diameter_set ( double  input)

Sets the diameter of your wheel.

Parameters
inputwheel diameter

Member Data Documentation

◆ adi_encoder

pros::adi::Encoder light::tracking_wheel::adi_encoder

Backing ADI encoder (used when constructed from ADI ports).

Definition at line 32 of file tracking_wheel.hpp.

◆ smart_encoder

pros::Rotation light::tracking_wheel::smart_encoder

Backing Rotation sensor (used when constructed from a smart port).

Definition at line 33 of file tracking_wheel.hpp.


The documentation for this class was generated from the following file: