Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 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.Autonomous;
  33. import com.qualcomm.robotcore.eventloop.opmode.Disabled;
  34. import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
  35. import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
  36. import com.qualcomm.robotcore.hardware.DcMotor;
  37. import com.qualcomm.robotcore.hardware.DcMotorSimple;
  38. import com.qualcomm.robotcore.hardware.Servo;
  39. import com.qualcomm.robotcore.util.ElapsedTime;
  40. import com.qualcomm.robotcore.util.Range;
  41.  
  42.  
  43.  
  44.  
  45. @Autonomous(name="Autonomie", group="Linear Opmode")
  46. //@Disabled
  47. public class Autonomie extends LinearOpMode {
  48.  
  49. // Declare OpMode members.
  50. private ElapsedTime runtime = new ElapsedTime();
  51.  
  52.  
  53. DcMotor MotorPrindere;
  54.  
  55. DcMotor leftMotor;
  56. DcMotor rightMotor;
  57.  
  58. DcMotor MotorBrat;
  59.  
  60. Servo ServoMarker;
  61.  
  62.  
  63.  
  64.  
  65. double power = 1.0;
  66. double lungime=0.0;
  67.  
  68. @Override
  69. public void runOpMode() {
  70. telemetry.addData("Status", "Initialized");
  71. telemetry.update();
  72.  
  73. MotorPrindere=hardwareMap.dcMotor.get("Motor_Prindere");
  74. leftMotor=hardwareMap.dcMotor.get("Left_Motor");
  75. rightMotor=hardwareMap.dcMotor.get("Right_Motor");
  76. ServoMarker=hardwareMap.servo.get("Servo_Marker");
  77. MotorBrat=hardwareMap.dcMotor.get("Motor_Brat");
  78. leftMotor.setDirection(DcMotorSimple.Direction.REVERSE);
  79.  
  80. waitForStart();
  81. runtime.reset();
  82.  
  83.  
  84.  
  85. MotorPrindere.setPower(-power);
  86. sleep(2500);
  87.  
  88. MotorPrindere.setPower(0.0);
  89.  
  90.  
  91. leftMotor.setPower(-power);
  92. rightMotor.setPower(-power);
  93. sleep(70);
  94.  
  95. leftMotor.setPower(0.0);
  96. rightMotor.setPower(0.0);
  97.  
  98. sleep(500);
  99.  
  100. rightMotor.setPower(0.0);
  101. leftMotor.setPower(power);
  102.  
  103. sleep(1800);
  104.  
  105. leftMotor.setPower(0.0);
  106. rightMotor.setPower(0.0);
  107. sleep(500);
  108.  
  109. leftMotor.setPower(-power);
  110. rightMotor.setPower(-power);
  111. sleep(1000);
  112.  
  113.  
  114. leftMotor.setPower(0.0);
  115. rightMotor.setPower(0.0);
  116. sleep(500);
  117.  
  118. rightMotor.setPower(0.0);
  119. leftMotor.setPower(power);
  120. sleep(800);
  121.  
  122. leftMotor.setPower(0.0);
  123. rightMotor.setPower(0.0);
  124.  
  125. leftMotor.setPower(-power);
  126. rightMotor.setPower(-power);
  127. sleep(85);
  128.  
  129. leftMotor.setPower(0.0);
  130. rightMotor.setPower(0.0);
  131. sleep(500);
  132.  
  133.  
  134. ServoMarker.setPosition(0.5);
  135. sleep(500);
  136. ServoMarker.setPosition(0.0);
  137. sleep(500);
  138.  
  139. leftMotor.setPower(0.0);
  140. rightMotor.setPower(0.0);
  141. sleep(500);
  142.  
  143.  
  144. leftMotor.setPower(0.0);
  145. rightMotor.setPower(power);
  146. sleep(200);
  147.  
  148. rightMotor.setPower(0.0);
  149. leftMotor.setPower(0.0);
  150. sleep(500);
  151.  
  152. leftMotor.setPower(power);
  153. rightMotor.setPower(power);
  154. sleep(1700);
  155.  
  156. leftMotor.setPower(0.0);
  157. rightMotor.setPower(0.0);
  158. sleep(500);
  159.  
  160. MotorBrat.setPower(power);
  161. sleep(1500);
  162.  
  163. MotorBrat.setPower(0.0);
  164. sleep(500);
  165.  
  166. while (opModeIsActive()) {
  167. telemetry.addData("Status", "Run Time: " + runtime.toString());
  168. telemetry.update();
  169. }
  170.  
  171.  
  172. }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement