Robotc Bridge Scoring Auton mous


SUBMITTED BY: Guest

DATE: Jan. 26, 2014, 7:44 p.m.

FORMAT: Text only

SIZE: 4.0 kB

HITS: 1165

  1. #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
  2. #pragma config(Hubs, S2, HTMotor, HTMotor, none, none)
  3. #pragma config(Sensor, S1, , sensorI2CMuxController)
  4. #pragma config(Sensor, S2, , sensorI2CMuxController)
  5. #pragma config(Motor, motorA, , tmotorNXT, openLoop)
  6. #pragma config(Motor, motorB, , tmotorNXT, openLoop)
  7. #pragma config(Motor, mtr_S1_C1_1, lin1, tmotorTetrix, openLoop)
  8. #pragma config(Motor, mtr_S1_C1_2, lin2, tmotorTetrix, openLoop)
  9. #pragma config(Motor, mtr_S1_C2_1, motorD, tmotorTetrix, PIDControl, encoder)
  10. #pragma config(Motor, mtr_S1_C2_2, motorF, tmotorTetrix, PIDControl, encoder)
  11. #pragma config(Motor, mtr_S2_C1_1, motorE, tmotorTetrix, PIDControl, encoder)
  12. #pragma config(Motor, mtr_S2_C1_2, motorG, tmotorTetrix, PIDControl, encoder)
  13. #pragma config(Motor, mtr_S2_C2_1, lin3, tmotorTetrix, openLoop)
  14. #pragma config(Motor, mtr_S2_C2_2, lin4, tmotorTetrix, openLoop)
  15. #pragma config(Servo, srvo_S1_C3_1, servo1, tServoNone)
  16. #pragma config(Servo, srvo_S1_C3_2, servo2, tServoNone)
  17. #pragma config(Servo, srvo_S1_C3_3, servo3, tServoNone)
  18. #pragma config(Servo, srvo_S1_C3_4, servo4, tServoNone)
  19. #pragma config(Servo, srvo_S1_C3_5, servo5, tServoNone)
  20. #pragma config(Servo, srvo_S1_C3_6, servo6, tServoNone)
  21. //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
  22. #include "JoystickDriver.c";
  23. void initializeRobot(){
  24. nMotorEncoder(motorD) =0;
  25. nMotorEncoder(motorE) =0;
  26. nMotorEncoder(motorF) =0;
  27. nMotorEncoder(motorG) =0;
  28. return;
  29. }
  30. void move(int direction, float revs);
  31. void turn(int direction, float revs);
  32. int fullrev = 1440;
  33. task main()
  34. {
  35. initializeRobot(); //Prepares robot, communicates with Field control system.
  36. waitForStart(); // Wait for the beginning of autonomous phase.
  37. move(1,6);
  38. }
  39. //This function is for turning. The "int" is actually a boolean. Use 0 for a left turn, 1 for a right turn.
  40. void turn(int direction, float revs)
  41. {
  42. nMotorEncoder(motorD) =0;
  43. nMotorEncoder(motorE) =0;
  44. nMotorEncoder(motorF) =0;
  45. nMotorEncoder(motorG) =0;
  46. if (direction==0)
  47. {
  48. while(nMotorEncoder(motorD) > -(fullrev*revs) & nMotorEncoder(motorE) > -(fullrev*revs) & nMotorEncoder(motorF) > -(fullrev*revs) & nMotorEncoder(motorG) > -(fullrev*revs))
  49. {
  50. motor(motorD) = -60;
  51. motor(motorE) = -60;
  52. motor(motorF) = -60;
  53. motor(motorG) = -60;
  54. }
  55. }
  56. else
  57. {
  58. while(nMotorEncoder(motorD) < (fullrev*revs) & nMotorEncoder(motorE) < (fullrev*revs) & nMotorEncoder(motorF) < (fullrev*revs) & nMotorEncoder(motorG) < (fullrev*revs))
  59. {
  60. motor(motorD) = 60;
  61. motor(motorE) = 60;
  62. motor(motorF) = 60;
  63. motor(motorG) = 60;
  64. }
  65. }
  66. }
  67. //This function is for moving. The "int" is actually a boolean. Use 0 for forward, 1 for backward.
  68. void move(int direction, float revs)
  69. {
  70. nMotorEncoder(motorD) =0;
  71. nMotorEncoder(motorE) =0;
  72. nMotorEncoder(motorF) =0;
  73. nMotorEncoder(motorG) =0;
  74. if (direction==0)
  75. {
  76. while(nMotorEncoder(motorD) > -(fullrev*revs) & nMotorEncoder(motorE) < (fullrev*revs) & nMotorEncoder(motorF) > -(fullrev*revs) & nMotorEncoder(motorG) < (fullrev*revs))
  77. {
  78. motor(motorD) = -60;
  79. motor(motorE) = 60;
  80. motor(motorF) = -60;
  81. motor(motorG) = 60;
  82. }
  83. }
  84. else
  85. {
  86. while(nMotorEncoder(motorD) < (fullrev*revs) & nMotorEncoder(motorE) > -(fullrev*revs) & nMotorEncoder(motorF) < (fullrev*revs) & nMotorEncoder(motorG) > -(fullrev*revs))
  87. {
  88. motor(motorD) = 60;
  89. motor(motorE) = -60;
  90. motor(motorF) = 60;
  91. motor(motorG) = -60;
  92. }
  93. }
  94. }

comments powered by Disqus