Tracking Wheels
Constructors​
Rotation Sensor​
Creates a new tracking wheel with a Rotation sensor.
port
the port your Rotation sensor is plugged into
wheel_diameter
assumed inches, this is the diameter of your wheel
distance_to_center
the distance to the center of your robot, this is used for tracking
ratio
the gear ratio of your tracking wheel. if it's not geared, this should be 1.0
- Prototype
- Example
tracking_wheel(int port, double wheel_diameter, double distance_to_center = 0.0, double ratio = 1.0);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
ADI Encoder​
Creates a new tracking wheel with an ADI Encoder.
ports
{'A', 'B'}
make the encoder negative if reversed
wheel_diameter
assumed inches, this is the diameter of your wheel
distance_to_center
the distance to the center of your robot, this is used for tracking
ratio
the gear ratio of your tracking wheel. if it's not geared, this should be 1.0
- Prototype
- Example
tracking_wheel(std::vector<int> ports, double wheel_diameter, double distance_to_center = 0.0, double ratio = 1.0);
ez::tracking_wheel right_tracker({-'A', -'B'}, 2.75, 4.0);
ADI Encoder 3-wire Expander​
Creates a new tracking wheel with an ADI Encoder plugged into a 3-wire expander.
smart_port
the smart port your ADI Expander is plugged into
ports
{'A', 'B'}
make the encoder negative if reversed
wheel_diameter
assumed inches, this is the diameter of your wheel
distance_to_center
the distance to the center of your robot, this is used for tracking
ratio
the gear ratio of your tracking wheel. if it's not geared, this should be 1.0
- Prototype
- Example
tracking_wheel(int smart_port, std::vector<int> ports, double wheel_diameter, double distance_to_center = 0.0, double ratio = 1.0);
ez::tracking_wheel right_tracker(1, {'C', 'D'}, 2.75, 4.0);
Getters​
get()​
Returns how far the wheel has traveled in inches.
- Prototype
- Example
double get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
get_raw()​
Returns the raw sensor value.
- Prototype
- Example
double get_raw();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.get_raw()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
distance_to_center_get()​
Returns the distance to the center of the robot.
- Prototype
- Example
double distance_to_center_get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.distance_to_center_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
distance_to_center_flip_get()​
Returns if the distance to center is flipped or not. False is not, true is.
- Prototype
- Example
double distance_to_center_flip_get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.distance_to_center_flip_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
ticks_per_inch()​
Returns the constant for how many ticks is 1 inch.
- Prototype
- Example
double ticks_per_inch();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.ticks_per_inch()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
ticks_per_rev_get()​
Returns the amount of ticks per revolution of your sensor.
- Prototype
- Example
double ticks_per_rev_get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.ticks_per_rev_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
ratio_get()​
Returns the gear ratio for your tracking wheel.
- Prototype
- Example
double ratio_get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.ratio_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
wheel_diameter_get()​
Returns the diameter of your wheel.
- Prototype
- Example
double wheel_diameter_get();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.wheel_diameter_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
Setters​
reset()​
Returns the diameter of your wheel.
- Prototype
- Example
void reset();
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void initialize() {
right_tracker.reset();
}
distance_to_center_set()​
Sets the distance to the center of the robot.
input
distance to center of your robot in inches
- Prototype
- Example
void distance_to_center_set(double input);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
right_tracker.distance_to_center_set(2.0); // Update center distance
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.distance_to_center_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
distance_to_center_flip_set()​
Sets the distance to the center to be flipped to negative or not.
input
flips distance to center to negative. false leaves it alone, true flips it
- Prototype
- Example
void distance_to_center_flip_set(bool input);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
right_tracker.distance_to_center_flip_set(true); // Make center distance negative
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.wheel_diameter_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
ticks_per_rev_set()​
Sets the amount of ticks per revolution of your sensor.
This is useful for custom encoders.
input
ticks per revolution
- Prototype
- Example
void ticks_per_rev_set(double input);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
right_tracker.ticks_per_rev_set(36000); // Set ticks per rev to 36000
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.ticks_per_rev_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
ratio_set()​
Sets the gear ratio for your tracking wheel.
input
gear ratio of tracking wheel
- Prototype
- Example
void ratio_set(double input);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
right_tracker.ratio_set(2.0); // Set ratio to 2:1
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.ratio_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
wheel_diameter_set()​
Sets the diameter of your wheel.
input
wheel diameter
- Prototype
- Example
void wheel_diameter_set(double input);
ez::tracking_wheel right_tracker(1, 2.75, 4.0);
void opcontrol() {
right_tracker.wheel_diameter_set(3.25); // Update wheel diameter
while (true) {
chassis.opcontrol_tank(); // Tank control
if (ez::as::page_blank_is_on(0)) {
ez::screen_print(to_string(right_tracker.wheel_diameter_get()), 1);
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}