Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 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.  
  68. Servo ServoBrat;
  69.  
  70. double power=0.5;
  71. double tpower=0.25;
  72. double spower=0.9;
  73. double servoposition=0.0;
  74. double powerbrat=20;
  75. @Override
  76. public void runOpMode() {
  77. telemetry.addData("Status", "Initialized");
  78. telemetry.update();
  79.  
  80. leftMotor=hardwareMap.dcMotor.get("Left_Motor");
  81. rightMotor=hardwareMap.dcMotor.get("Right_Motor");
  82. MotorPrindere=hardwareMap.dcMotor.get("Motor_Prindere");
  83. MotorBrat=hardwareMap.dcMotor.get("Motor_Brat");
  84. ServoBrat=hardwareMap.servo.get("Servo_Brat");
  85. leftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
  86.  
  87.  
  88. // Wait for the game to start (driver presses PLAY)
  89. waitForStart();
  90. runtime.reset();
  91.  
  92. ServoBrat.setPosition(servoposition);
  93.  
  94. // run until the end of the match (driver presses STOP)
  95. while (opModeIsActive()) {
  96. telemetry.addData("Status", "Run Time: " + runtime.toString());
  97. telemetry.update();
  98. if(gamepad1.right_bumper&&gamepad1.a)
  99. {leftMotor.setPower(power+spower);
  100. rightMotor.setPower(power+spower);
  101.  
  102. }
  103.  
  104. else
  105. {leftMotor.setPower(0.0);
  106. rightMotor.setPower(0.0);
  107.  
  108. }
  109.  
  110. if(gamepad1.right_bumper&&gamepad1.a==false)
  111. { leftMotor.setPower(power);
  112. rightMotor.setPower(power);
  113.  
  114. }
  115.  
  116.  
  117.  
  118. else
  119. {leftMotor.setPower(0.0);
  120. rightMotor.setPower(0.0);
  121.  
  122. }
  123.  
  124. if(gamepad1.left_bumper&&gamepad1.a)
  125. {leftMotor.setPower(-power-spower);
  126. rightMotor.setPower(-power-spower);
  127.  
  128. }
  129.  
  130. else
  131. {leftMotor.setPower(0.0);
  132. rightMotor.setPower(0.0);
  133.  
  134. }
  135. if(gamepad1.left_bumper&&gamepad1.a==false)
  136. {
  137. leftMotor.setPower(-power);
  138. rightMotor.setPower(-power);
  139. }
  140.  
  141. else
  142. {leftMotor.setPower(0.0);
  143. rightMotor.setPower(0.0);
  144.  
  145. }
  146.  
  147. if(gamepad1.dpad_right)
  148. {leftMotor.setPower(tpower);
  149. rightMotor.setPower(-tpower);
  150.  
  151. }
  152. else
  153. {leftMotor.setPower(0.0);
  154. rightMotor.setPower(0.0);
  155.  
  156. }
  157.  
  158. if(gamepad1.dpad_left)
  159. {leftMotor.setPower(-tpower);
  160. rightMotor.setPower(tpower);
  161.  
  162. }
  163.  
  164. else
  165. {leftMotor.setPower(0.0);
  166. rightMotor.setPower(0.0);
  167.  
  168. }
  169.  
  170. if(gamepad2.right_bumper) MotorPrindere.setPower(power);
  171. else MotorPrindere.setPower(0.0);
  172.  
  173. if(gamepad2.left_bumper) MotorPrindere.setPower(-power);
  174. else MotorPrindere.setPower(0.0);
  175.  
  176.  
  177.  
  178. if(gamepad2.dpad_up) {
  179. MotorBrat.setDirection(DcMotorSimple.Direction.FORWARD);
  180. MotorBrat.setPower(powerbrat);
  181.  
  182. }
  183.  
  184. else MotorBrat.setPower(0.0);
  185.  
  186. if(gamepad2.dpad_down) {
  187. MotorBrat.setDirection(DcMotorSimple.Direction.REVERSE);
  188. MotorBrat.setPower(powerbrat);
  189.  
  190. }
  191. else MotorBrat.setPower(0.0);
  192.  
  193. if(gamepad2.b)
  194. {
  195. servoposition = 1.0;
  196. ServoBrat.setPosition(servoposition);
  197. }
  198.  
  199. if(gamepad2.x)
  200. {servoposition=0.0;
  201. ServoBrat.setPosition(servoposition);
  202. }
  203.  
  204.  
  205. }
  206. }
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement