Drive and Telemetry
Initialize Drive​
initialize()​
Runs opcontrol_curve_sd_initialize()
and drive_imu_calibrate()
.
- Prototype
- Example
void initialize() {
chassis.initialize();
}
void Drive::initialize();
Set Drive​
drive_set()​
Sets the chassis to voltage.
Disables PID when called.
left
voltage for left side, -127 to 127
right
voltage for right side, -127 to 127
- Prototype
- Example
void autonomous() {
drive_set(127, 127);
pros::delay(1000); // Wait 1 second
drive_set(0, 0);
}
void drive_set(int left, int right);
drive_brake_set()​
Changes the way the drive behaves when it is not under active user control.
brake_type
the 'brake mode' of the motor e.g. 'pros::E_MOTOR_BRAKE_COAST' 'pros::E_MOTOR_BRAKE_BRAKE' 'pros::E_MOTOR_BRAKE_HOLD'
- Prototype
- Example
void initialize() {
drive_brake_set_mode(MOTOR_BRAKE_COAST);
}
void drive_brake_set(pros::motor_brake_mode_e_t brake_type);
drive_current_limit_set()​
Sets the limit for the current on the drive.
mA
input in miliamps
- Prototype
- Example
void initialize() {
drive_brake_set_mode(1000);
}
void drive_current_limit_set(int mA);
drive_imu_scaler_set()​
Sets a new imu scaling factor.
This value is multiplied by the imu to change its output.
scaler
factor to scale the imu by
- Prototype
- Example
void turn_example() {
chassis.drive_imu_scaler_set(2);
// This will now turn to 45 real degrees
chassis.pid_turn_set(90_deg, TURN_SPEED);
chassis.pid_wait();
// This will turn to 22.5 real degrees
chassis.pid_turn_set(45_deg, TURN_SPEED);
chassis.pid_wait();
chassis.pid_turn_set(0_deg, TURN_SPEED);
chassis.pid_wait();
}
void drive_imu_scaler_set(double scaler);
Telemetry​
drive_sensor_right()​
The position of the right sensor in inches.
If you have two parallel tracking wheels, this will return tracking wheel position. Otherwise this returns motor position.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Right Sensor: %i \n", chassis.drive_sensor_right());
pros::delay(ez::util::DELAY_TIME);
}
}
int drive_sensor_right();
drive_velocity_right()​
The velocity of the right motor.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Right Velocity: %i \n", chassis.drive_velocity_right());
pros::delay(ez::util::DELAY_TIME);
}
}
int drive_velocity_right();
drive_mA_right()​
The watts of the right motor.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Right mA: %i \n", chassis.drive_mA_right());
pros::delay(ez::util::DELAY_TIME);
}
}
double drive_mA_right();
drive_current_right_over()​
Return true when the motor is over current.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Right Over Current: %i \n", chassis.drive_current_right_over());
pros::delay(ez::util::DELAY_TIME);
}
}
bool drive_current_right_over();
drive_sensor_left()​
The position of the left sensor in inches.
If you have two parallel tracking wheels, this will return tracking wheel position. Otherwise this returns motor position.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Left Sensor: %i \n", chassis.drive_sensor_left());
pros::delay(ez::util::DELAY_TIME);
}
}
int drive_sensor_left();
drive_velocity_left()​
The velocity of the left motor.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Left Velocity: %i \n", chassis.drive_velocity_left());
pros::delay(ez::util::DELAY_TIME);
}
}
int drive_velocity_left();
drive_mA_left()​
The watts of the left motor.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Left mA: %i \n", chassis.drive_mA_left());
pros::delay(ez::util::DELAY_TIME);
}
}
double drive_mA_left();
drive_current_left_over()​
Return true when the motor is over current.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Left Over Current: %i \n", chassis.drive_current_left_over());
pros::delay(ez::util::DELAY_TIME);
}
}
bool drive_current_left_over();
drive_sensor_reset()​
Reset all the chassis motors and tracking wheels, recommended to run at the start of your autonomous routine.
- Prototype
- Example
void initialize() {
chassis.drive_sensor_reset();
}
void drive_sensor_reset();
drive_imu_reset()​
Resets the current imu value. Defaults to 0, recommended to run at the start of your autonomous routine.
new_heading_value
new heading value
- Prototype
- Example
void initialize() {
chassis.drive_imu_reset();
}
void drive_imu_reset(double new_heading = 0);
drive_imu_get()​
Returns the current imu rotation value in degrees.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Gyro: %f \n", chassis.drive_imu_get());
pros::delay(ez::util::DELAY_TIME);
}
}
double drive_imu_get();
drive_imu_accel_get()​
Returns the current imu accel x + accel y value.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Accel x + y: %f \n", chassis.drive_imu_accel_get());
pros::delay(ez::util::DELAY_TIME);
}
}
double drive_imu_accel_get();
drive_imu_calibrate()​
Calibrates the IMU, recommended to run in initialize().
run_loading_animation
true runs the animation, false doesn't
- Prototype
- Example
void initialize() {
chassis.drive_imu_calibrate();
}
bool drive_imu_calibrate(bool run_loading_animation = true);
drive_imu_get()​
Gets IMU sensor scaler. This number is multiplied by the imu so users can tune what a "degree" means.
- Prototype
- Example
...
double drive_imu_scaler_get();
drive_imu_scaler_get()​
Returns the current imu scaling factor.
- Prototype
- Example
void turn_example() {
chassis.drive_imu_scaler_set(2);
printf("%.2f\n", chassis.drive_imu_scaler_get()); // Prints 2
// This will now turn to 45 real degrees
chassis.pid_turn_set(90_deg, TURN_SPEED);
chassis.pid_wait();
// This will turn to 22.5 real degrees
chassis.pid_turn_set(45_deg, TURN_SPEED);
chassis.pid_wait();
chassis.pid_turn_set(0_deg, TURN_SPEED);
chassis.pid_wait();
}
double drive_imu_scaler_get();
drive_imu_scaler_get()​
Checks if the imu calibrated successfully or if it took longer than expected.
Returns true if calibrated successfully, and false if unsuccessful.
- Prototype
- Example
void initialize() {
// Print our branding over your terminal :D
ez::ez_template_print();
pros::delay(500); // Stop the user from doing anything while legacy ports configure
// Initialize chassis and auton selector
chassis.initialize();
ez::as::initialize();
master.rumble(chassis.drive_imu_calibrated() ? "." : "---");
}
bool drive_imu_calibrated();