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 drive to voltage. Sets mode to ez::DISABLE
.
left
an integer between -127 and 127
right
an integer between -127 and 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()
Sets brake mode for all drive motors.
brake_type
takes either MOTOR_BRAKE_COAST
, MOTOR_BRAKE_BRAKE
, and MOTOR_BRAKE_HOLD
as parameters
- 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 mA limit to the drive. Default is 2500.
mA
input miliamps
- Prototype
- Example
void initialize() {
drive_brake_set_mode(1000);
}
void drive_current_limit_set(int mA);
drive_imu_scaler_set()
Sets a scaler for the imu. This number is multiplied by the imu so users can tune what a "degree" is.
scaler
a small double
- 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()
Returns right sensor value, either integrated encoder or external encoder.
- 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()
Returns integrated encoder velocity.
- 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()
Returns current mA being used.
- 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()
Returns true
when the motor is pulling too many amps.
- 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()
Returns left sensor value, either integrated encoder or external encoder.
- 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()
Returns integrated encoder velocity.
- 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()
Returns current mA being used.
- 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()
Returns true
when the motor is pulling too many amps.
- 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()
Resets integrated encoders and trackers if applicable.
- Prototype
- Example
void initialize() {
chassis.drive_sensor_reset();
}
void drive_sensor_reset();
drive_imu_reset()
Sets current gyro position to parameter, defaulted to 0.
- Prototype
- Example
void initialize() {
chassis.drive_imu_reset();
}
void drive_imu_reset(double new_heading = 0);
drive_imu_get()
Gets IMU sensor, value is 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()
Gets imu x + y acceleration. This is (optionally) used internally as the secondary sensor for velocity exiting.
- 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 IMU, and vibrates the controller after a successful calibration.
- Prototype
- Example
void initialize() {
chassis.drive_imu_calibrate();
}
bool drive_imu_calibrate();
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()
Gets the scaler for the imu. This number is multiplied by the imu so users can tune what a "degree" is.
- 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();