#include <mecanum_drive.h>
|
| MecanumDrive (vex::motor &left_front, vex::motor &right_front, vex::motor &left_rear, vex::motor &right_rear, vex::rotation *lateral_wheel=NULL, vex::inertial *imu=NULL, mecanumdrive_config_t *config=NULL) |
|
void | drive_raw (double direction_deg, double magnitude, double rotation) |
|
void | drive (double left_y, double left_x, double right_x, int power=2) |
|
bool | auto_drive (double inches, double direction, double speed, bool gyro_correction=true) |
|
bool | auto_turn (double degrees, double speed, bool ignore_imu=false) |
|
A class representing the Mecanum drivetrain. Contains 4 motors, a possible IMU (intertial), and a possible undriven perpendicular wheel.
◆ MecanumDrive()
MecanumDrive::MecanumDrive |
( |
vex::motor & | left_front, |
|
|
vex::motor & | right_front, |
|
|
vex::motor & | left_rear, |
|
|
vex::motor & | right_rear, |
|
|
vex::rotation * | lateral_wheel = NULL, |
|
|
vex::inertial * | imu = NULL, |
|
|
mecanumdrive_config_t * | config = NULL ) |
Create the Mecanum drivetrain object
◆ auto_drive()
bool MecanumDrive::auto_drive |
( |
double | inches, |
|
|
double | direction, |
|
|
double | speed, |
|
|
bool | gyro_correction = true ) |
Drive the robot in a straight line automatically. If the inertial was declared in the constructor, use it to correct while driving. If the lateral wheel was declared in the constructor, use it for more accurate positioning while strafing.
- Parameters
-
inches | How far the robot should drive, in inches |
direction | What direction the robot should travel in, in degrees. 0 is forward, +/-180 is reverse, clockwise is positive. |
speed | The maximum speed the robot should travel, in percent: -1.0->+1.0 |
gyro_correction | =true Whether or not to use the gyro to help correct while driving. Will always be false if no gyro was declared in the constructor. |
Drive the robot in a straight line automatically. If the inertial was declared in the constructor, use it to correct while driving. If the lateral wheel was declared in the constructor, use it for more accurate positioning while strafing.
- Parameters
-
inches | How far the robot should drive, in inches |
direction | What direction the robot should travel in, in degrees. 0 is forward, +/-180 is reverse, clockwise is positive. |
speed | The maximum speed the robot should travel, in percent: -1.0->+1.0 |
gyro_correction | = true Whether or not to use the gyro to help correct while driving. Will always be false if no gyro was declared in the constructor. |
- Returns
- Whether or not the maneuver is complete.
◆ auto_turn()
bool MecanumDrive::auto_turn |
( |
double | degrees, |
|
|
double | speed, |
|
|
bool | ignore_imu = false ) |
Autonomously turn the robot X degrees over it's center point. Uses a closed loop for control.
- Parameters
-
degrees | How many degrees to rotate the robot. Clockwise postive. |
speed | What percentage to run the motors at: 0.0 -> 1.0 |
ignore_imu | =false Whether or not to use the Inertial for determining angle. Will instead use circumference formula + robot's wheelbase + encoders to determine. |
- Returns
- whether or not the robot has finished the maneuver
Autonomously turn the robot X degrees over it's center point. Uses a closed loop for control.
- Parameters
-
degrees | How many degrees to rotate the robot. Clockwise postive. |
speed | What percentage to run the motors at: 0.0 -> 1.0 |
ignore_imu | = false Whether or not to use the Inertial for determining angle. Will instead use circumference formula + robot's wheelbase + encoders to determine. |
- Returns
- whether or not the robot has finished the maneuver
◆ drive()
void MecanumDrive::drive |
( |
double | left_y, |
|
|
double | left_x, |
|
|
double | right_x, |
|
|
int | power = 2 ) |
Drive the robot with a mecanum-style / arcade drive. Inputs are in percent (-100.0 -> 100.0) straight from the controller. Controls are mixed, so the robot can drive forward / strafe / rotate all at the same time.
- Parameters
-
left_y | left joystick, Y axis (forward / backwards) |
left_x | left joystick, X axis (strafe left / right) |
right_x | right joystick, X axis (rotation left / right) |
power | =2 how much of a "curve" there should be on drive controls; better for low speed maneuvers. Leave blank for a default curve of 2 (higher means more fidelity) |
Drive the robot with a mecanum-style / arcade drive. Inputs are in percent (-100.0 -> 100.0) straight from the controller. Controls are mixed, so the robot can drive forward / strafe / rotate all at the same time.
- Parameters
-
left_y | left joystick, Y axis (forward / backwards) |
left_x | left joystick, X axis (strafe left / right) |
right_x | right joystick, X axis (rotation left / right) |
power | = 2 how much of a "curve" there should be on drive controls; better for low speed maneuvers. Leave blank for a default curve of 2 (higher means more fidelity) |
◆ drive_raw()
void MecanumDrive::drive_raw |
( |
double | direction_deg, |
|
|
double | magnitude, |
|
|
double | rotation ) |
Drive the robot using vectors. This handles all the math required for mecanum control.
- Parameters
-
direction_deg | the direction to drive the robot, in degrees. 0 is forward, 180 is back, clockwise is positive, counterclockwise is negative. |
magnitude | How fast the robot should drive, in percent: 0.0->1.0 |
rotation | How fast the robot should rotate, in percent: -1.0->+1.0 |
The documentation for this class was generated from the following files: