Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. /* Copyright (c) 2017 FIRST. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted (subject to the limitations in the disclaimer below) provided that
  5. * the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice, this list
  8. * of conditions and the following disclaimer.
  9. *
  10. * Redistributions in binary form must reproduce the above copyright notice, this
  11. * list of conditions and the following disclaimer in the documentation and/or
  12. * other materials provided with the distribution.
  13. *
  14. * Neither the name of FIRST nor the names of its contributors may be used to endorse or
  15. * promote products derived from this software without specific prior written permission.
  16. *
  17. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
  18. * LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  20. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29.  
  30. package org.firstinspires.ftc.teamcode;
  31.  
  32. import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
  33. import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
  34. import com.qualcomm.robotcore.hardware.DcMotor;
  35. import com.qualcomm.robotcore.hardware.DcMotorSimple;
  36. import com.qualcomm.robotcore.hardware.Servo;
  37. import com.qualcomm.robotcore.util.ElapsedTime;
  38.  
  39.  
  40. /**
  41. * This file contains an minimal example of a Linear "OpMode". An OpMode is a 'program' that runs in either
  42. * the autonomous or the teleop period of an FTC match. The names of OpModes appear on the menu
  43. * of the FTC Driver Station. When an selection is made from the menu, the corresponding OpMode
  44. * class is instantiated on the Robot Controller and executed.
  45. *
  46. * This particular OpMode just executes a basic Tank Drive Teleop for a two wheeled robot
  47. * It includes all the skeletal structure that all linear OpModes contain.
  48. *
  49. * Use Android Studios to Copy this Class, and Paste it into your team's code folder with a new name.
  50. * Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list
  51. */
  52.  
  53. @TeleOp(name="GamepadCuSprint", group="Linear Opmode")
  54. //@Disabled
  55. public class GamepadCuSprint extends LinearOpMode {
  56.  
  57. // Declare OpMode members.
  58. private ElapsedTime runtime = new ElapsedTime();
  59.  
  60. DcMotor leftMotor;
  61. DcMotor rightMotor;
  62.  
  63. DcMotor MotorPrindere;
  64.  
  65. DcMotor MotorBrat;
  66.  
  67. Servo ServoMarker;
  68.  
  69.  
  70. Servo ServoBrat;
  71.  
  72. double power=0.5;
  73. double tpower=0.5;
  74. double spower=0.9;
  75. double servoposition=0.0;
  76. double powerbrat=20;
  77. @Override
  78. public void runOpMode() {
  79. telemetry.addData("Status", "Initialized");
  80. telemetry.update();
  81.  
  82. leftMotor=hardwareMap.dcMotor.get("Left_Motor");
  83. rightMotor=hardwareMap.dcMotor.get("Right_Motor");
  84. MotorPrindere=hardwareMap.dcMotor.get("Motor_Prindere");
  85. MotorBrat=hardwareMap.dcMotor.get("Motor_Brat");
  86. ServoBrat=hardwareMap.servo.get("Servo_Brat");
  87. ServoMarker=hardwareMap.servo.get("Servo_Marker");
  88. leftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
  89.  
  90.  
  91. // Wait for the game to start (driver presses PLAY)
  92. waitForStart();
  93. runtime.reset();
  94.  
  95. ServoBrat.setPosition(servoposition);
  96. ServoMarker.setPosition(0.0);
  97.  
  98. // run until the end of the match (driver presses STOP)
  99. while (opModeIsActive()) {
  100. telemetry.addData("Status", "Run Time: " + runtime.toString());
  101. telemetry.update();
  102. if(gamepad1.right_bumper&&gamepad1.a)
  103. {leftMotor.setPower(power+spower);
  104. rightMotor.setPower(power+spower);
  105.  
  106. }
  107.  
  108. else
  109. {leftMotor.setPower(0.0);
  110. rightMotor.setPower(0.0);
  111.  
  112. }
  113.  
  114. if(gamepad1.right_bumper&&gamepad1.a==false)
  115. { leftMotor.setPower(power);
  116. rightMotor.setPower(power);
  117.  
  118. }
  119.  
  120.  
  121.  
  122. else
  123. {leftMotor.setPower(0.0);
  124. rightMotor.setPower(0.0);
  125.  
  126. }
  127.  
  128. if(gamepad1.left_bumper&&gamepad1.a)
  129. {leftMotor.setPower(-power-spower);
  130. rightMotor.setPower(-power-spower);
  131.  
  132. }
  133.  
  134. else
  135. {leftMotor.setPower(0.0);
  136. rightMotor.setPower(0.0);
  137.  
  138. }
  139. if(gamepad1.left_bumper&&gamepad1.a==false)
  140. {
  141. leftMotor.setPower(-power);
  142. rightMotor.setPower(-power);
  143. }
  144.  
  145. else
  146. {leftMotor.setPower(0.0);
  147. rightMotor.setPower(0.0);
  148.  
  149. }
  150.  
  151. if(gamepad1.dpad_right)
  152. {leftMotor.setPower(tpower);
  153. rightMotor.setPower(-tpower);
  154.  
  155. }
  156. else
  157. {leftMotor.setPower(0.0);
  158. rightMotor.setPower(0.0);
  159.  
  160. }
  161.  
  162. if(gamepad1.dpad_left)
  163. {leftMotor.setPower(-tpower);
  164. rightMotor.setPower(tpower);
  165.  
  166. }
  167.  
  168. else
  169. {leftMotor.setPower(0.0);
  170. rightMotor.setPower(0.0);
  171.  
  172. }
  173.  
  174. if(gamepad2.right_bumper) MotorPrindere.setPower(power);
  175. else MotorPrindere.setPower(0.0);
  176.  
  177. if(gamepad2.left_bumper) MotorPrindere.setPower(-power);
  178. else MotorPrindere.setPower(0.0);
  179.  
  180.  
  181.  
  182. if(gamepad2.dpad_up) {
  183. MotorBrat.setDirection(DcMotorSimple.Direction.FORWARD);
  184. MotorBrat.setPower(powerbrat);
  185.  
  186. }
  187.  
  188. else MotorBrat.setPower(0.0);
  189.  
  190. if(gamepad2.dpad_down) {
  191. MotorBrat.setDirection(DcMotorSimple.Direction.REVERSE);
  192. MotorBrat.setPower(powerbrat);
  193.  
  194. }
  195. else MotorBrat.setPower(0.0);
  196.  
  197. if(gamepad2.b)
  198. {
  199. servoposition = 1.0;
  200. ServoBrat.setPosition(servoposition);
  201. }
  202.  
  203. if(gamepad2.x)
  204. {servoposition=0.0;
  205. ServoBrat.setPosition(servoposition);
  206. }
  207.  
  208. if(gamepad2.y) ServoMarker.setPosition(0.5);
  209.  
  210. if(gamepad2.a) ServoMarker.setPosition(0.0);
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217. }
  218. }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement