Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. /*---------------------------------------------------------------------------*/
  2. /* */
  3. /* Description: Competition template for VEX EDR */
  4. /* */
  5. /*---------------------------------------------------------------------------*/
  6.  
  7. // This code is for the VEX cortex platform
  8. #pragma platform(VEX2)
  9.  
  10. // Select Download method as "competition"
  11. #pragma competitionControl(Competition)
  12.  
  13. //Main competition background code...do not modify!
  14. #include "Vex_Competition_Includes.c"
  15.  
  16. /*---------------------------------------------------------------------------*/
  17. /* Pre-Autonomous Functions */
  18. /* */
  19. /* You may want to perform some actions before the competition starts. */
  20. /* Do them in the following function. You must return from this function */
  21. /* or the autonomous and usercontrol tasks will not be started. This */
  22. /* function is only called once after the cortex has been powered on and */
  23. /* not every time that the robot is disabled. */
  24. /*---------------------------------------------------------------------------*/
  25. /*
  26. void setdrive(int leftvalue, int rightvalue){
  27. motor[port1] = leftdrive;
  28. motor[port2] = leftdrive;
  29. motor[port9] = rightdrive;
  30. motor[port10] = rightdrive;
  31. }
  32. */
  33. void pre_auton()
  34. {
  35. // Set bStopTasksBetweenModes to false if you want to keep user created tasks
  36. // running between Autonomous and Driver controlled modes. You will need to
  37. // manage all user created tasks if set to false.
  38. bStopTasksBetweenModes = true;
  39.  
  40. // Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
  41. // used by the competition include file, for example, you might want
  42. // to display your team name on the LCD in this function.
  43. // bDisplayCompetitionStatusOnLcd = false;
  44.  
  45. // All activities that occur before the competition starts
  46. // Example: clearing encoders, setting servo positions, ...
  47. }
  48.  
  49. /*---------------------------------------------------------------------------*/
  50. /* */
  51. /* Autonomous Task */
  52. /* */
  53. /* This task is used to control your robot during the autonomous phase of */
  54. /* a VEX Competition. */
  55. /* */
  56. /* You must modify the code to add your own robot specific commands here. */
  57. /*---------------------------------------------------------------------------*/
  58.  
  59. task autonomous()
  60. {
  61. // ..........................................................................
  62. // Insert user code here.
  63. // ..........................................................................
  64.  
  65. // Remove this function call once you have "real" code.
  66. AutonomousCodePlaceholderForTesting();
  67. }
  68.  
  69. /*---------------------------------------------------------------------------*/
  70. /* */
  71. /* User Control Task */
  72. /* */
  73. /* This task is used to control your robot during the user control phase of */
  74. /* a VEX Competition. */
  75. /* */
  76. /* You must modify the code to add your own robot specific commands here. */
  77. /*---------------------------------------------------------------------------*/
  78.  
  79. task usercontrol()
  80. {
  81. // User control code here, inside the loop
  82. int leftdrive;
  83. int rightdrive;
  84.  
  85. while (true)
  86. {
  87. int stickleft = getJoystickValue(Ch3);
  88. int stickright = getJoystickValue(Ch2);
  89. leftdrive = stickleft * stickleft * stickleft / 16129;
  90. rightdrive = -1 * stickright * stickright * stickright / 16129;
  91. motor[port1] = leftdrive;
  92. motor[port2] = leftdrive;
  93. motor[port9] = rightdrive;
  94. motor[port10] = rightdrive;
  95.  
  96. if(getJoystickValue(Btn6U) == 1){
  97. motor[port3] = 127;
  98. motor[port8] = -127;
  99. }
  100. else if(getJoystickValue(Btn6D) == 1){
  101. motor[port3] = -127;
  102. motor[port8] = 127;
  103. }
  104. else{
  105. motor[port3] = 0;
  106. motor[port8] = 0;
  107. }
  108.  
  109. if(getJoystickValue(Btn5U) == 1){
  110. motor[port4] = 127;
  111. motor[port7] = -127;
  112. }
  113. else if(getJoystickValue(Btn5D) == 1){
  114. motor[port4] = -127;
  115. motor[port7] = 127;
  116. }
  117. else{
  118. motor[port4] = 0;
  119. motor[port7] = 0;
  120. }
  121.  
  122. if(getJoystickValue(Btn7U) == 1) {motor[port5] = 127;}
  123. else if(getJoystickValue(Btn7L) == 1) {motor[port5] = -127;}
  124. else {motor[port5] = 0;}
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement