Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. //Overloaded reverse method to allow for no input (reverse until hit wall), one input (inches), or two inputs (inches and power)
  2.  
  3. void Reverse() {
  4. reset();
  5. float start = TimeNow();
  6. left_motor.SetPercent(-1*MOTOR_CORRECTION*DEFAULT_MOTOR_POWER);
  7. right_motor.SetPercent(-1*DEFAULT_MOTOR_POWER);
  8.  
  9. const char* titles[] = { "Left Encoder: ", "Right Encoder: " };
  10. while(bottom_right_micro.Value() || bottom_left_micro.Value() && TimeNow() - start < 5) {
  11. LCD.WriteRC(left_encoder.Counts(), 4, 5);
  12. LCD.WriteRC(right_encoder.Counts(), 5, 5);
  13. }
  14. reset();
  15. }
  16.  
  17. void Reverse(int inches) {
  18. reset();
  19. float start = TimeNow();
  20. left_motor.SetPercent(-1 * MOTOR_CORRECTION * DEFAULT_MOTOR_POWER);
  21. right_motor.SetPercent(-1 * DEFAULT_MOTOR_POWER);
  22. while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 5) {
  23. LCD.WriteRC(left_encoder.Counts(), 4, 5);
  24. LCD.WriteRC(right_encoder.Counts(), 5, 5);
  25. }
  26. reset();
  27. }
  28.  
  29. void Reverse(int inches, int motorPower) {
  30. reset();
  31. float start = TimeNow();
  32. left_motor.SetPercent(-1 * motorPower * MOTOR_CORRECTION);
  33. right_motor.SetPercent(-1 * motorPower);
  34. while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 5) {
  35. LCD.WriteRC(left_encoder.Counts(), 4, 5);
  36. LCD.WriteRC(right_encoder.Counts(), 5, 5);
  37. }
  38. reset();
  39. }
  40.  
  41. void ReverseSlant(int inches, int motorPower) {
  42. reset();
  43. float start = TimeNow();
  44. left_motor.SetPercent(-1 * MOTOR_CORRECTION * motorPower * 0.96);
  45. right_motor.SetPercent(-1 * motorPower);
  46. while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 10) {
  47. LCD.WriteRC(left_encoder.Counts(), 4, 5);
  48. LCD.WriteRC(right_encoder.Counts(), 5, 5);
  49. }
  50. reset();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement