Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Overloaded drive method to allow for no input (drive until hit wall), one input (inches), or two inputs (inches and power)
- void Drive() {
- reset();
- left_motor.SetPercent(MOTOR_CORRECTION*DEFAULT_MOTOR_POWER);
- right_motor.SetPercent(DEFAULT_MOTOR_POWER);
- //using large number for isStall since there is no set distance
- while((top_right_micro.Value() || top_left_micro.Value()) && !isStall(10000)) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
- void Drive(float inches) {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(MOTOR_CORRECTION*DEFAULT_MOTOR_POWER);
- right_motor.SetPercent(DEFAULT_MOTOR_POWER);
- while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 10 && !isStall(DRIVE_CORRECTION * COUNTS_PER_INCH * inches)) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
- void Drive(int inches, int motorPower) {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(MOTOR_CORRECTION * motorPower);
- right_motor.SetPercent(motorPower);
- while (right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 5 && !isStall(DRIVE_CORRECTION * COUNTS_PER_INCH * inches)) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement