Advertisement
Faerie-

FTCcode2

Jan 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. package org.usfirst.ftc.exampleteam.yourcodehere;
  2.  
  3. import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
  4. import com.qualcomm.robotcore.hardware.DcMotor;
  5. import com.qualcomm.robotcore.hardware.Servo;
  6.  
  7. import org.swerverobotics.library.SynchronousOpMode;
  8.  
  9. /**
  10. * A skeletal example of a do-nothing first OpMode. Go ahead and change this code
  11. * to suit your needs, or create sibling OpModes adjacent to this one in the same
  12. * Java package.
  13. */
  14. @TeleOp(name = "My First OpMode")
  15. public class MyFirstOpMode extends SynchronousOpMode {
  16. /* Declare here any fields you might find useful. */
  17. public DcMotor motorLeft = null;
  18. public DcMotor motorRight = null;
  19. public DcMotor slide1 = null;
  20. public DcMotor slide2 = null;
  21.  
  22. public Servo pusher = null;
  23. public Servo P1 = null;
  24. public Servo P2 = null;
  25.  
  26. @Override
  27. public void main() throws InterruptedException {
  28. /* Initialize our hardware variables. Note that the strings used here as parameters
  29. * to 'get' must correspond to the names you assigned during the robot configuration
  30. * step you did in the FTC Robot Controller app on the phone.
  31. */
  32. motorLeft = this.hardwareMap.dcMotor.get("motorLeft");
  33. motorRight = this.hardwareMap.dcMotor.get("motorRight");
  34. pusher = hardwareMap.servo.get("pusher");
  35. slide1 = hardwareMap.dcMotor.get("slide1");
  36. slide2 = hardwareMap.dcMotor.get("slide2");
  37. P1 = hardwareMap.servo.get("P1");
  38. P2 = hardwareMap.servo.get("P2");
  39. motorRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  40. motorLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  41. slide1.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  42. slide2.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  43.  
  44. waitForStart();
  45.  
  46. // Go go gadget robot!
  47. while (opModeIsActive()) {
  48. double powerRight = 0;
  49. double powerLeft = 0;
  50. if (updateGamepads()) {
  51. powerLeft = gamepad1.left_stick_y * 0.7;
  52. powerRight = gamepad1.right_stick_y * 0.7;
  53. this.motorLeft.setPower(powerLeft);
  54. this.motorRight.setPower(-powerRight);
  55.  
  56. if (gamepad1.dpad_up) {
  57. pusher.setPosition(100);
  58. }
  59. else if (gamepad1.dpad_down) {
  60. pusher.setPosition(0.5);
  61. }
  62. // lower slide bar
  63. if (gamepad1.right_bumper) {
  64. slide1.setPower(25);
  65. } else if (gamepad1.right_trigger > 0) {
  66. slide1.setPower(-25);
  67. } else {
  68. slide1.setPower(0);
  69. }
  70.  
  71. //higher slide bar
  72. if (gamepad1.left_bumper) {
  73. slide2.setPower(-25);
  74. } else if (gamepad1.left_trigger > 0) {
  75. slide2.setPower(25);
  76. } else {
  77. slide2.setPower(0);
  78. }
  79.  
  80. //pincers
  81. if(gamepad1.a){
  82. P1.setPosition(0);
  83. P2.setPosition(1);
  84. }
  85. if(gamepad1.b){
  86. P1.setPosition(1);
  87. P2.setPosition(0);
  88. }
  89.  
  90. }
  91.  
  92. telemetry.update();
  93. idle();
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement