#include <tank_drive.h>
|
| TankDrive (motor_group &left_motors, motor_group &right_motors, robot_specs_t &config, OdometryBase *odom=NULL) |
|
void | stop () |
|
void | drive_tank (double left, double right, int power=1, BrakeType bt=BrakeType::None) |
|
void | drive_tank_raw (double left, double right) |
|
void | drive_arcade (double forward_back, double left_right, int power=1, BrakeType bt=BrakeType::None) |
|
bool | drive_forward (double inches, directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0) |
|
bool | drive_forward (double inches, directionType dir, double max_speed=1, double end_speed=0) |
|
bool | turn_degrees (double degrees, Feedback &feedback, double max_speed=1, double end_speed=0) |
|
bool | turn_degrees (double degrees, double max_speed=1, double end_speed=0) |
|
bool | drive_to_point (double x, double y, vex::directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0) |
|
bool | drive_to_point (double x, double y, vex::directionType dir, double max_speed=1, double end_speed=0) |
|
bool | turn_to_heading (double heading_deg, Feedback &feedback, double max_speed=1, double end_speed=0) |
|
bool | turn_to_heading (double heading_deg, double max_speed=1, double end_speed=0) |
|
void | reset_auto () |
|
bool | pure_pursuit (PurePursuit::Path path, directionType dir, Feedback &feedback, double max_speed=1, double end_speed=0) |
|
bool | pure_pursuit (PurePursuit::Path path, directionType dir, double max_speed=1, double end_speed=0) |
|
TankDrive is a class to run a tank drive system. A tank drive system, sometimes called differential drive, has a motor (or group of synchronized motors) on the left and right side
◆ BrakeType
Enumerator |
---|
None | just send 0 volts to the motors
|
ZeroVelocity | try to bring the robot to rest. But don't try to hold position
|
Smart | bring the robot to rest and once it's stopped, try to hold that position
|
◆ TankDrive()
TankDrive::TankDrive |
( |
motor_group & | left_motors, |
|
|
motor_group & | right_motors, |
|
|
robot_specs_t & | config, |
|
|
OdometryBase * | odom = NULL ) |
Create the TankDrive object
- Parameters
-
left_motors | left side drive motors |
right_motors | right side drive motors |
config | the configuration specification defining physical dimensions about the robot. See robot_specs_t for more info |
odom | an odometry system to track position and rotation. this is necessary to execute autonomous paths |
◆ drive_arcade()
Drive the robot using arcade style controls. forward_back controls the linear motion, left_right controls the turning.
forward_back and left_right are in "percent": -1.0 -> 1.0
- Parameters
-
forward_back | the percent to move forward or backward |
left_right | the percent to turn left or right |
power | modifies the input velocities left^power, right^power |
bt | breaktype. What to do if the driver lets go of the sticks |
Drive the robot using arcade style controls. forward_back controls the linear motion, left_right controls the turning.
left_motors and right_motors are in "percent": -1.0 -> 1.0
◆ drive_forward() [1/2]
bool TankDrive::drive_forward |
( |
double | inches, |
|
|
directionType | dir, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Autonomously drive the robot forward a certain distance
- Parameters
-
inches | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
dir | the direction we want to travel forward and backward |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Autonomously drive the robot forward a certain distance
- Parameters
-
inches | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
dir | the direction we want to travel forward and backward |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have finished driving to our point
◆ drive_forward() [2/2]
bool TankDrive::drive_forward |
( |
double | inches, |
|
|
directionType | dir, |
|
|
Feedback & | feedback, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Use odometry to drive forward a certain distance using a custom feedback controller
Returns whether or not the robot has reached it's destination.
- Parameters
-
inches | the distance to drive forward |
dir | the direction we want to travel forward and backward |
feedback | the custom feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true when we have reached our target distance
Use odometry to drive forward a certain distance using a custom feedback controller
Returns whether or not the robot has reached it's destination.
- Parameters
-
inches | the distance to drive forward |
dir | the direction we want to travel forward and backward |
feedback | the custom feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
◆ drive_tank()
Drive the robot using differential style controls. left_motors controls the left motors, right_motors controls the right motors.
left_motors and right_motors are in "percent": -1.0 -> 1.0
- Parameters
-
left | the percent to run the left motors |
right | the percent to run the right motors |
power | modifies the input velocities left^power, right^power |
bt | breaktype. What to do if the driver lets go of the sticks |
◆ drive_tank_raw()
void TankDrive::drive_tank_raw |
( |
double | left, |
|
|
double | right ) |
Drive the robot raw-ly
- Parameters
-
left | the percent to run the left motors (-1, 1) |
right | the percent to run the right motors (-1, 1) |
◆ drive_to_point() [1/2]
bool TankDrive::drive_to_point |
( |
double | x, |
|
|
double | y, |
|
|
vex::directionType | dir, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Use odometry to automatically drive the robot to a point on the field. X and Y is the final point we want the robot. Here we use the default feedback controller from the drive_sys
Returns whether or not the robot has reached it's destination.
- Parameters
-
x | the x position of the target |
y | the y position of the target |
dir | the direction we want to travel forward and backward |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Use odometry to automatically drive the robot to a point on the field. X and Y is the final point we want the robot. Here we use the default feedback controller from the drive_sys
Returns whether or not the robot has reached it's destination.
- Parameters
-
x | the x position of the target |
y | the y position of the target |
dir | the direction we want to travel forward and backward |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have reached our target point
◆ drive_to_point() [2/2]
bool TankDrive::drive_to_point |
( |
double | x, |
|
|
double | y, |
|
|
vex::directionType | dir, |
|
|
Feedback & | feedback, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Use odometry to automatically drive the robot to a point on the field. X and Y is the final point we want the robot.
Returns whether or not the robot has reached it's destination.
- Parameters
-
x | the x position of the target |
y | the y position of the target |
dir | the direction we want to travel forward and backward |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Use odometry to automatically drive the robot to a point on the field. X and Y is the final point we want the robot.
Returns whether or not the robot has reached it's destination.
- Parameters
-
x | the x position of the target |
y | the y position of the target |
dir | the direction we want to travel forward and backward |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have reached our target point
◆ modify_inputs()
double TankDrive::modify_inputs |
( |
double | input, |
|
|
int | power = 2 ) |
|
static |
Create a curve for the inputs, so that drivers have more control at lower speeds. Curves are exponential, with the default being squaring the inputs.
- Parameters
-
input | the input before modification |
power | the power to raise input to |
- Returns
- input ^ power (accounts for negative inputs and odd numbered powers)
Modify the inputs from the controller by squaring / cubing, etc Allows for better control of the robot at slower speeds
- Parameters
-
input | the input signal -1 -> 1 |
power | the power to raise the signal to |
- Returns
- input^power accounting for any sign issues that would arise with this naive solution
◆ pure_pursuit() [1/2]
bool TankDrive::pure_pursuit |
( |
PurePursuit::Path | path, |
|
|
directionType | dir, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Drive the robot autonomously using a pure-pursuit algorithm - Input path with a set of waypoints - the robot will attempt to follow the points while cutting corners (radius) to save time (compared to stop / turn / start)
Use the default drive feedback
- Parameters
-
path | The list of coordinates to follow, in order |
dir | Run the bot forwards or backwards |
max_speed | Limit the speed of the robot (for pid / pidff feedbacks) |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- True when the path is complete
Drive the robot autonomously using a pure-pursuit algorithm - Input path with a set of waypoints - the robot will attempt to follow the points while cutting corners (radius) to save time (compared to stop / turn / start)
Use the default drive feedback
- Parameters
-
path | The list of coordinates to follow, in order |
dir | Run the bot forwards or backwards |
max_speed | Limit the speed of the robot (for pid / pidff feedbacks) |
- Returns
- True when the path is complete
◆ pure_pursuit() [2/2]
bool TankDrive::pure_pursuit |
( |
PurePursuit::Path | path, |
|
|
directionType | dir, |
|
|
Feedback & | feedback, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Drive the robot autonomously using a pure-pursuit algorithm - Input path with a set of waypoints - the robot will attempt to follow the points while cutting corners (radius) to save time (compared to stop / turn / start)
- Parameters
-
path | The list of coordinates to follow, in order |
dir | Run the bot forwards or backwards |
feedback | The feedback controller determining speed |
max_speed | Limit the speed of the robot (for pid / pidff feedbacks) |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- True when the path is complete
Drive the robot autonomously using a pure-pursuit algorithm - Input path with a set of waypoints - the robot will attempt to follow the points while cutting corners (radius) to save time (compared to stop / turn / start)
- Parameters
-
path | The list of coordinates to follow, in order |
dir | Run the bot forwards or backwards |
feedback | The feedback controller determining speed |
max_speed | Limit the speed of the robot (for pid / pidff feedbacks) |
- Returns
- True when the path is complete
◆ reset_auto()
void TankDrive::reset_auto |
( |
| ) |
|
Reset the initialization for autonomous drive functions
◆ stop()
Stops rotation of all the motors using their "brake mode"
◆ turn_degrees() [1/2]
bool TankDrive::turn_degrees |
( |
double | degrees, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Autonomously turn the robot X degrees to counterclockwise (negative for clockwise), with a maximum motor speed of percent_speed (-1.0 -> 1.0)
Uses the defualt turning feedback of the drive system.
- Parameters
-
degrees | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Autonomously turn the robot X degrees to counterclockwise (negative for clockwise), with a maximum motor speed of percent_speed (-1.0 -> 1.0)
Uses the defualt turning feedback of the drive system.
- Parameters
-
degrees | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we turned te target number of degrees
◆ turn_degrees() [2/2]
bool TankDrive::turn_degrees |
( |
double | degrees, |
|
|
Feedback & | feedback, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Autonomously turn the robot X degrees counterclockwise (negative for clockwise), with a maximum motor speed of percent_speed (-1.0 -> 1.0)
Uses PID + Feedforward for it's control.
- Parameters
-
degrees | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
Autonomously turn the robot X degrees to counterclockwise (negative for clockwise), with a maximum motor speed of percent_speed (-1.0 -> 1.0)
Uses the specified feedback for it's control.
- Parameters
-
degrees | degrees by which we will turn relative to the robot (+) turns ccw, (-) turns cw |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have turned our target number of degrees
◆ turn_to_heading() [1/2]
bool TankDrive::turn_to_heading |
( |
double | heading_deg, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Turn the robot in place to an exact heading relative to the field. 0 is forward. Uses the defualt turn feedback of the drive system
- Parameters
-
heading_deg | the heading to which we will turn |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Turn the robot in place to an exact heading relative to the field. 0 is forward. Uses the defualt turn feedback of the drive system
- Parameters
-
heading_deg | the heading to which we will turn |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have reached our target heading
◆ turn_to_heading() [2/2]
bool TankDrive::turn_to_heading |
( |
double | heading_deg, |
|
|
Feedback & | feedback, |
|
|
double | max_speed = 1, |
|
|
double | end_speed = 0 ) |
Turn the robot in place to an exact heading relative to the field. 0 is forward.
- Parameters
-
heading_deg | the heading to which we will turn |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
Turn the robot in place to an exact heading relative to the field. 0 is forward.
- Parameters
-
heading_deg | the heading to which we will turn |
feedback | the feedback controller we will use to travel. controls the rate at which we accelerate and drive. |
max_speed | the maximum percentage of robot speed at which the robot will travel. 1 = full power |
end_speed | the movement profile will attempt to reach this velocity by its completion |
- Returns
- true if we have reached our target heading
The documentation for this class was generated from the following files: