Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. /*----------------------------------------------------------------------------*/
  2. /* */
  3. /* Module: main.cpp */
  4. /* Author: C:\Users\knsv_.KANDULA-3 */
  5. /* Created: Sat Jul 31 2021 */
  6. /* Description: V5 project */
  7. /* */
  8. /*----------------------------------------------------------------------------*/
  9.  
  10. // ---- START VEXCODE CONFIGURED DEVICES ----
  11. // Robot Configuration:
  12. // [Name] [Type] [Port(s)]
  13. // left_front motor 1
  14. // left_back motor 2
  15. // right_front motor 3
  16. // right_back motor 4
  17. // Controller1 controller
  18. // Inertial20 inertial 20
  19. // ---- END VEXCODE CONFIGURED DEVICES ----
  20.  
  21. #include "vex.h"
  22. #include "move.h"
  23. #include "turn.h"
  24.  
  25. using namespace vex;
  26. //global competition instance
  27. competition Competition;
  28.  
  29. int aside = -1;
  30. int auton = 2;
  31.  
  32. /****************************************************************************************************************/
  33. void set_auton() {
  34. if (Brain.Screen.xPosition() < 120 || Brain.Screen.xPosition() > 360) {
  35. Brain.Screen.setPenWidth(4);
  36. Brain.Screen.setFillColor(transparent);
  37. Brain.Screen.setPenColor(black);
  38. Brain.Screen.drawRectangle(182-180*aside, 2+60*auton, 114, 54);
  39. Brain.Screen.setPenColor(white);
  40. if (Brain.Screen.xPosition() < 120)
  41. aside = 1;
  42. else
  43. aside = -1;
  44. if (Brain.Screen.yPosition() < 60)
  45. auton = 0;
  46. else if (Brain.Screen.yPosition() < 120)
  47. auton = 1;
  48. else if (Brain.Screen.yPosition() < 180)
  49. auton = 2;
  50. else
  51. auton = 3;
  52. Brain.Screen.drawRectangle(182-180*aside, 2+60*auton, 114, 54);
  53. }
  54. }
  55. /****************************************************************************************************************/
  56.  
  57. void pre_auton(void)
  58. {
  59. vexcodeInit();
  60.  
  61. left_front.setStopping(hold);
  62. left_front.setVelocity(0, percent);
  63. left_front.setMaxTorque(100, percent);
  64. left_back.setStopping(hold);
  65. left_back.setVelocity(0, percent);
  66. left_back.setMaxTorque(100, percent);
  67. right_front.setStopping(hold);
  68. right_front.setVelocity(0, percent);
  69. right_front.setMaxTorque(100, percent);
  70. right_back.setStopping(hold);
  71. right_back.setVelocity(0, percent);
  72. right_back.setMaxTorque(100, percent);
  73. }
  74.  
  75. void autonomous(void)
  76. {
  77. move::moveBot(10,20);
  78. }
  79.  
  80. void usercontrol(void)
  81. {
  82. while(true)
  83. {
  84.  
  85. //Program for setting axis postition relative to controller and wheel
  86. left_front.setVelocity(Controller1.Axis3.position(percent), percent);
  87. left_back.setVelocity(Controller1.Axis3.position(percent), percent);
  88. right_front.setVelocity(Controller1.Axis2.position(percent), percent);
  89. right_back.setVelocity(Controller1.Axis2.position(percent), percent);
  90.  
  91. //code here
  92. }
  93. }
  94.  
  95. int main()
  96. {
  97. vexcodeInit();
  98. // Set up callbacks for autonomous and driver control periods.
  99. Competition.autonomous(autonomous);
  100. Competition.drivercontrol(usercontrol);
  101.  
  102. // Run the pre-autonomous function.
  103. pre_auton();
  104.  
  105. while (true) {
  106. wait(100, msec);
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement