|
ART v1.0-alpha
A Robot Template that raises the floor for VRC teams
|
A Simple TankDrive class. More...
#include <TankDrive.h>
Public Member Functions | |
| TankDrive (vex::motor_group left, vex::motor_group right) | |
| Construct a new Tank Drive object. | |
| void | arcade (double x, double y, double rot) |
| Commands the TankDrive using arcade inputs. | |
| void | arcade (double drive, double rot) |
| Commands the TankDrive using Tank-only arcade inputs. | |
| void | tank (double left, double right) |
| Commands the TankDrive using tank inputs. | |
| void | LeftSplitArcade (const vex::controller &cont) |
| Commands the TankDrive using arcade inputs directly from a controller. | |
| void | LeftSplitArcadeCurved (const vex::controller &cont) |
| Commands the TankDrive using arcade inputs directly from a controller. | |
| void | update () |
| Uses the stored commands to command the motors. | |
Protected Attributes | |
| SimpleMotorGroup | m_left |
| a SimpleMotorGroup for the left side | |
| SimpleMotorGroup | m_right |
| a SimpleMotorGroup for the right side | |
| double | m_cmdX {0} |
| The Stored command for the X-direction. | |
| double | m_cmdY {0} |
| The Stored command for the Y-direction. | |
| double | m_cmdRot {0} |
| The Stored command for rotation. | |
A Simple TankDrive class.
The aim of the TankDrive class is to package low-level tank controls to be called both during directly to drive and by other classes to allow for more complex functions. The SmartDrive class for example, expands on the functionality of the TankDrive by using the basic functions to perform more complex maneuvers.
The TankDrive can be commanded through several different functions. These commands are stored and used to command the motors. However, the benefit of storing these commands rather than directly commanding the motors is that 1) they can be accessed later and 2) they don't cap out at a maximum value. This gives the ability to pass whatever commands you wish as when the motor commands are calculated, one of the commands can be overwritten if the other is more significant. For example, if a small turn input is paired with a large drive input (greater than 100), the drive input can cause the rotation input to be insignificant.
Commands are percentages of the max voltage(12). The left of the robot takes the sum of the drive and turn inputs, while the right takes the difference. Thus, the motor command can exceed 100(or -100), which would just make the motor move at 100 percent. Commanding more than that doesn't change anything, but because the commands are added, commanding more than a 100 percent means that the command can remain past 100 even after adding the turn command.
add a way to enable speedMode
add a method to retain proportionality between inputs
add getters for stuff
add curvature control scheme
provide several other preset control schemes
Definition at line 54 of file TankDrive.h.
| art::TankDrive::TankDrive | ( | vex::motor_group | left, |
| vex::motor_group | right ) |
Construct a new Tank Drive object.
| left | a motor_group for the left side |
| right | a motor_group for the right side |
The TankDrive class requires 2 vex::motor_groups, one for each side.
Definition at line 20 of file TankDrive.cpp.
| void art::TankDrive::arcade | ( | double | drive, |
| double | rot ) |
Commands the TankDrive using Tank-only arcade inputs.
| drive | the command for the Y-direcction(driving) |
| rot | the command for rotation(turning |
A modified arcade method to remove the ignored x-input.
Definition at line 29 of file TankDrive.cpp.
| void art::TankDrive::arcade | ( | double | x, |
| double | y, | ||
| double | rot ) |
Commands the TankDrive using arcade inputs.
| x | the command for the X-direction(the TankDrive ignores this input) |
| y | the command for the Y-direcction(driving) |
| rot | the command for rotation(turning) |
Because TankDrives don't have wheels powered in the X-direction, the X-input is ignored. The reason this function still accepts it is because there were originally plans to include several other drive types, but were never fully fleshed out, leaving an extra input that is currently unused.
Definition at line 22 of file TankDrive.cpp.
| void art::TankDrive::LeftSplitArcade | ( | const vex::controller & | cont | ) |
Commands the TankDrive using arcade inputs directly from a controller.
| cont | a refrence to a controller object |
This method simply provides a pre-set control scheme using a controller as an input. The commands are passed directly from the joysticks to the arcade function.
The Left Joystick's vertical axis(Axis3) is mapped to driving and the Right Joystick's horizontal Axis(Axis1) is mapped to turning.
Definition at line 41 of file TankDrive.cpp.
| void art::TankDrive::LeftSplitArcadeCurved | ( | const vex::controller & | cont | ) |
Commands the TankDrive using arcade inputs directly from a controller.
| cont | a refrence to a controller object |
This method simply provides a pre-set control scheme using a controller as an input. The commands from the joysticks are cubed and divided by 10,000 before being passed to the arcade function. This results in an input curve that decreases lower values, decreasing the sensitivity of inputs and making it easier to drive slow.
The Left Joystick's vertical axis(Axis3) is mapped to driving and the Right Joystick's horizontal Axis(Axis1) is mapped to turning.
For example, an input of 80 from the controller only leads to an output of ~50 percent. While an input of 50 leads to an output of only ~12 percent.
Definition at line 46 of file TankDrive.cpp.
| void art::TankDrive::tank | ( | double | left, |
| double | right ) |
Commands the TankDrive using tank inputs.
| left | the command for the left motors |
| right | the command for the right motors |
Internally, the 2 inputs are simply used to calculate the y and rot commands. The notes on commands past 100 in the class description remains true for these calculated inputs.
Definition at line 35 of file TankDrive.cpp.
| void art::TankDrive::update | ( | ) |
Uses the stored commands to command the motors.
Originally, this had use to actually command the motors, but now each method internally calls update, so this just remains here, as it was part of a shared interface between periodically updating objects. Essentially, it does nothing notable and should be ignored.
Definition at line 52 of file TankDrive.cpp.
|
protected |
The Stored command for rotation.
The command is a positive or negative percentage, but can exceed 100 as well. Doing so will make the command more significant in calculations with the other commands.
Definition at line 201 of file TankDrive.h.
|
protected |
The Stored command for the X-direction.
The command is a positive or negative percentage, but can exceed 100 as well. Doing so will make the command more significant in calculations with the other commands.
Because TankDrives can't drive in the X-direction, this command is ignored.
Definition at line 185 of file TankDrive.h.
|
protected |
The Stored command for the Y-direction.
The command is a positive or negative percentage, but can exceed 100 as well. Doing so will make the command more significant in calculations with the other commands.
Definition at line 193 of file TankDrive.h.
|
protected |
a SimpleMotorGroup for the left side
Currently, there is no way to access this SimpleMotorGroup using the TankDrive object. However, you can still use methods on the vex::motor_groups you used to contruct the TankDrive object. Telling those motor groups to spin will likely cause undefined behaviour though.
Definition at line 164 of file TankDrive.h.
|
protected |
a SimpleMotorGroup for the right side
Currently, there is no way to access this SimpleMotorGroup using the TankDrive object. However, you can still use methods on the vex::motor_groups you used to contruct the TankDrive object. Telling those motor groups to spin will likely cause undefined behaviour though.
Definition at line 174 of file TankDrive.h.