Robotc 4-wheel Omniwheel Joystick Test


SUBMITTED BY: Guest

DATE: Dec. 24, 2013, 11:33 p.m.

FORMAT: Text only

SIZE: 2.8 kB

HITS: 1125

  1. #include "JoystickDriver.c"
  2. task main()
  3. {
  4. while(true)
  5. {
  6. getJoystickSettings(joystick);
  7. if(joystick.joy1_y1>10)//if the joystick is pressed backward
  8. {
  9. if(joystick.joy1_x1<-80)
  10. {
  11. //go 315 degrees
  12. motor(motorD) = 60;
  13. motor(motorE) = 0;
  14. motor(motorF) = 0;
  15. motor(motorG) = -60;
  16. }
  17. else
  18. {
  19. if(joystick.joy1_x1>80)
  20. {
  21. //go 45 degrees
  22. motor(motorD) = -60;
  23. motor(motorE) = 0;
  24. motor(motorF) = 0;
  25. motor(motorG) = 60;
  26. }
  27. else
  28. {
  29. //go backward
  30. motor(motorD) = -60;
  31. motor(motorE) = 60;
  32. motor(motorF) = -60;
  33. motor(motorG) = 60;
  34. }
  35. }
  36. }
  37. else
  38. {
  39. if(joystick.joy1_y1<-10)
  40. //if joystick is pressed forwards
  41. {
  42. if(joystick.joy1_x1<-80)
  43. {
  44. //go 225 degrees
  45. motor(motorD) = 0;
  46. motor(motorE) = 60;
  47. motor(motorF) = -60;
  48. motor(motorG) = 0;
  49. }
  50. else
  51. {
  52. if(joystick.joy1_x1>80)
  53. {
  54. //go 135 degrees
  55. motor(motorD) = 0;
  56. motor(motorE) = -60;
  57. motor(motorF) = 60;
  58. motor(motorG) = 0;
  59. }
  60. else
  61. {
  62. //go forwards
  63. motor(motorD) = 60;
  64. motor(motorE) = -60;
  65. motor(motorF) = 60;
  66. motor(motorG) = -60;
  67. }
  68. }
  69. }
  70. else
  71. {
  72. if(joystick.joy1_x1<-100)
  73. //joystick pressed to the left
  74. {
  75. //go left
  76. motor(motorD) = 60;
  77. motor(motorE) = 60;
  78. motor(motorF) = -60;
  79. motor(motorG) = -60;
  80. }
  81. else
  82. {
  83. if(joystick.joy1_x1>100)
  84. //joystick pressed to the right
  85. {
  86. //go right
  87. motor(motorD) = -60;
  88. motor(motorE) = -60;
  89. motor(motorF) = 60;
  90. motor(motorG) = 60;
  91. }
  92. else
  93. {
  94. //currently not working
  95. if(joystick.joy2_x2<-100)
  96. //if right joystick is pressed to the left
  97. {
  98. //rotate left
  99. motor(motorD) = 60;
  100. motor(motorE) = 60;
  101. motor(motorF) = 60;
  102. motor(motorG) = 60;
  103. }
  104. else
  105. {
  106. if(joystick.joy2_x2>100)
  107. //if right joystick is pressed to the right
  108. {
  109. //rotate right
  110. motor(motorD) = -60;
  111. motor(motorE) = -60;
  112. motor(motorF) = -60;
  113. motor(motorG) = -60;
  114. }
  115. else
  116. {
  117. //stay still
  118. motor(motorD) = 0;
  119. motor(motorE) = 0;
  120. motor(motorF) = 0;
  121. motor(motorG) = 0;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }

comments powered by Disqus