Advertisement
Faerie-

RoboCodo

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