WPID Library 5
|
An Tank chassis class that inherits from the Chassis virtual class. Contains functions for moving forwards and backwards, and on the spot turns. Utilizes PID for all motion. More...
#include <Tank.h>
Public Member Functions | |
Tank (float track_width, float wheel_radius, vex::motor_group left, vex::motor_group right, float drive_gear_ratio) | |
Construct a new Tank object. | |
void | setStraightPID (PID pid) override |
Sets the straight PID object. | |
void | setTurnPID (PID pid) override |
Sets the turning PID constants. | |
void | spin (int left_velocity, int right_velocity) |
Spin the entire chassis by specified velocities for each side of the chassis. Negative values spin the wheel backwards. | |
void | spin (int velocity) |
Spin the entire chassis by specified velocities for both sides. | |
void | straight (float distance, int max_speed) override |
Move the chassis forward a specific distance with PID. Chassis will always stay at or below the maximum speed. | |
void | straightAsync (float distance, int max_speed) override |
Move the chassis forward asynchronously a specific distance with PID. Chassis will always stay at or below the maximum speed. | |
void | turn (int target_angle, int max_speed) override |
Turn the chassis on the spot with PID. Chassis will always stay at or below the maximum speed. | |
void | turnAsync (float target_angle, int max_speed) override |
Turn the chassis on the spot asynchronously with PID. Chassis will always stay at or below the maximum speed. | |
void | stop () override |
Stops the chassis using the default brake mode. | |
void | waitUntilSettled () override |
Waits for the robot to finish a motion. | |
float | getLeftPosition (vex::rotationUnits units) override |
Gets the current position of the left side of the chassis. | |
float | getRightPosition (vex::rotationUnits units) override |
Gets the current position of the right side of the chassis. | |
void | resetPosition () override |
Reset the left and right encoders to 0. | |
void | setBrakeType (vex::brakeType type) override |
Sets the brake type of the chassis by passing a brake type as a parameter. | |
void | setMaxAcceleration (float max_accel) |
Set the max acceleration of the chassis. Every time the PID loop executes, it increments the speed of the mechanism by this value until the mechanism reaches it's maximum speed. Increase the value if the robot is ramping too slow, or decrease if it causes too much jerk. | |
void | setOffset (float straight, float turn) |
Set the offset for the straight and turn functions. This value is in inches, and will add to the input of each movement function. | |
void | setTimeout (int timeout) |
Set the timeout to use for PID movement. If the timeout is exceeded, the system will stop regardless of the current error or speed. A value of -1 will disable timeouts. | |
void | setMeasurementUnits (Conversion::measurement preferred_units) |
Set the measurement units for chassis values. | |
Additional Inherited Members | |
![]() | |
float | track_width |
float | wheel_circumference |
Mechanism * | left |
Mechanism * | right |
PID | pidStraight |
PID | pidTurn |
float | straight_offset = 0 |
float | turn_offset = 0 |
Conversion::measurement | measure_units = Conversion::measurement::in |
An Tank chassis class that inherits from the Chassis virtual class. Contains functions for moving forwards and backwards, and on the spot turns. Utilizes PID for all motion.
Tank::Tank | ( | float | track_width, |
float | wheel_radius, | ||
vex::motor_group | left, | ||
vex::motor_group | right, | ||
float | drive_gear_ratio | ||
) |
Construct a new Tank object.
track_width | the width between left and right |
wheel_base | the distance from front to back of the wheel |
wheel_radius | radius of the wheel |
left | motor group |
right | motor group |
|
overridevirtual |
Gets the current position of the left side of the chassis.
units | typically using rotationUnits::deg |
Implements wpid::Chassis.
|
overridevirtual |
Gets the current position of the right side of the chassis.
units | typically using rotationUnits::deg |
Implements wpid::Chassis.
|
overridevirtual |
Reset the left and right encoders to 0.
Implements wpid::Chassis.
|
overridevirtual |
Sets the brake type of the chassis by passing a brake type as a parameter.
type | The brake type can be set to coast, brake, or hold. |
Implements wpid::Chassis.
void Tank::setMaxAcceleration | ( | float | max_accel | ) |
Set the max acceleration of the chassis. Every time the PID loop executes, it increments the speed of the mechanism by this value until the mechanism reaches it's maximum speed. Increase the value if the robot is ramping too slow, or decrease if it causes too much jerk.
max_accel | a value to increment to ramp the speed up in velocityUnits::pct |
|
virtual |
Set the measurement units for chassis values.
preferred_units | the user's measurement system |
Implements wpid::Chassis.
void Tank::setOffset | ( | float | straight, |
float | turn | ||
) |
Set the offset for the straight and turn functions. This value is in inches, and will add to the input of each movement function.
straight | the distance to offset straight motion in distance units |
turn | the angle to offset turns in degrees |
|
overridevirtual |
Sets the straight PID object.
pid | a PID object holding the constants for driving straight |
Implements wpid::Chassis.
void Tank::setTimeout | ( | int | timeout | ) |
Set the timeout to use for PID movement. If the timeout is exceeded, the system will stop regardless of the current error or speed. A value of -1 will disable timeouts.
timeout | in milliseconds |
|
overridevirtual |
Sets the turning PID constants.
pid | a PID object holding the constants for turning on the spot |
Implements wpid::Chassis.
void Tank::spin | ( | int | left_velocity, |
int | right_velocity | ||
) |
Spin the entire chassis by specified velocities for each side of the chassis. Negative values spin the wheel backwards.
left_velocity | the left side velocity in percent units |
right_velocity | the right side velocity in percent units |
void Tank::spin | ( | int | velocity | ) |
Spin the entire chassis by specified velocities for both sides.
velocity | the velocity in percent units |
|
overridevirtual |
Stops the chassis using the default brake mode.
Implements wpid::Chassis.
|
overridevirtual |
Move the chassis forward a specific distance with PID. Chassis will always stay at or below the maximum speed.
distance | the distance in inches |
max_speed | the maximum speed the robot will travel in percent units |
Implements wpid::Chassis.
|
overridevirtual |
Move the chassis forward asynchronously a specific distance with PID. Chassis will always stay at or below the maximum speed.
distance | the distance in inches |
max_speed | the maximum speed the robot will travel in percent units |
Implements wpid::Chassis.
|
overridevirtual |
Turn the chassis on the spot with PID. Chassis will always stay at or below the maximum speed.
target_angle | the target angle in degrees |
max_speed | the maximum speed in percent units |
Implements wpid::Chassis.
|
overridevirtual |
Turn the chassis on the spot asynchronously with PID. Chassis will always stay at or below the maximum speed.
target_angle | the target angle in degrees |
max_speed | the maximum speed in percent units |
Implements wpid::Chassis.
|
overridevirtual |
Waits for the robot to finish a motion.
Implements wpid::Chassis.