Skip to main content
Version: 4.0.0-beta.3

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

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

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'

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

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

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

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.

double drive_sensor_right();

drive_velocity_right()​

The velocity of the right motor.

int drive_velocity_right();

drive_mA_right()​

The current draw of the first right motor, in milliamps.

double drive_mA_right();

drive_current_right_over()​

Return true when the motor is over current.

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.

double drive_sensor_left();

drive_velocity_left()​

The velocity of the left motor.

int drive_velocity_left();

drive_mA_left()​

The current draw of the first left motor, in milliamps.

double drive_mA_left();

drive_current_left_over()​

Return true when the motor is over current.

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.

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

void drive_imu_reset(double new_heading = 0);

drive_imu_get()​

Returns the current imu heading rotation value in degrees.

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.

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

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.

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.

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.

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.

bool drive_imu_calibrated();