Drive and Telemetry
Initialize Drive
initialize()
Runs opcontrol_curve_sd_initialize() and drive_imu_calibrate().
run_loading_animation false skips the loading animation on the brain screen while the IMU calibrates
- Prototype
- Example
void initialize() {
chassis.initialize();
}
void Drive::initialize(bool run_loading_animation = true);
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() {
chassis.drive_set(127, 127);
pros::delay(1000); // Wait 1 second
chassis.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() {
chassis.drive_brake_set(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 milliamps
- Prototype
- Example
void initialize() {
chassis.drive_current_limit_set(1000);
}
void drive_current_limit_set(int mA);
drive_imu_scaler_3600_set()
Calibrates the imu's scale using a physical turn.
Physically turn the robot 3600 degrees (10 full rotations) and pass in what the imu reported for that turn. Internally, this is used to divide the imu's raw reading so it reports the true 3600. A value under 100 is rejected and the previous scale is kept. See the IMU Scaling tutorial for the full calibration walkthrough.
imu_value_after_3600 what the imu reads after physically turning the robot 3600 degrees
- Prototype
- Example
void initialize() {
chassis.initialize();
// After physically turning the robot 3600 degrees and reading what the
// imu reported, pass that value in here.
chassis.drive_imu_scaler_3600_set(3625.42);
}
void drive_imu_scaler_3600_set(double imu_value_after_3600);
drive_imus_scalers_3600_set()
Calibrates the scale of all IMUs using a physical turn, for drives built with the redundant IMU constructor.
Physically turn the robot 3600 degrees (10 full rotations) and pass in what each imu reported for that turn. A value under 100 is rejected and that imu's previous scale is kept.
imu_values_after_3600 what each imu reads after physically turning the robot 3600 degrees, input {3550, 3625...}, in the same order as the IMU ports passed to the constructor
- Prototype
- Example
void initialize() {
chassis.initialize();
// After physically turning the robot 3600 degrees and reading what each
// imu reported, pass those values in here, in the same order as the imu
// ports passed to the constructor.
chassis.drive_imus_scalers_3600_set({3550.0, 3625.0});
}
void drive_imus_scalers_3600_set(std::vector<double> imu_values_after_3600);
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: %f \n", chassis.drive_sensor_right());
pros::delay(ez::util::DELAY_TIME);
}
}
double 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 current draw of the first right motor, in milliamps.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Right mA: %f \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: %f \n", chassis.drive_sensor_left());
pros::delay(ez::util::DELAY_TIME);
}
}
double 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 current draw of the first left motor, in milliamps.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Left mA: %f \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 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 heading 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 size of the imu's acceleration in the x-y plane, sqrt(x^2 + y^2), so it is never negative. Returns 0 if there is no imu.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
printf("Accel: %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_scaler_3600_get()
Returns the imu value after a 3600 degree turn that produces the imu's current scale.
- Prototype
- Example
void initialize() {
chassis.initialize();
chassis.drive_imu_scaler_3600_set(3625.42);
printf("%.2f\n", chassis.drive_imu_scaler_3600_get()); // Prints 3625.42
}
double drive_imu_scaler_3600_get();
drive_imus_scalers_3600_get()
Returns the imu value after a 3600 degree turn that produces each imu's current scale, keyed by port, for drives built with the redundant IMU constructor.
- Prototype
- Example
chassis.drive_imus_scalers_3600_set({3550.0, 3625.0});
for (auto& [port, value] : chassis.drive_imus_scalers_3600_get())
printf("port %i: %.2f\n", port, value);
std::map<int, double> drive_imus_scalers_3600_get();
drive_angle_get()
Returns the angle of the robot, from whichever IMU is currently focused. On a redundant IMU drive, this is the one to read instead of talking to an individual pros::Imu directly, since it stays correct across a failover.
- Prototype
- Example
printf("%.2f\n", chassis.drive_angle_get());
double drive_angle_get();
drive_imu_calibrated()
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();