Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 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.  
  33. import com.qualcomm.robotcore.hardware.DcMotor;
  34. import com.qualcomm.robotcore.hardware.HardwareMap;
  35. import com.qualcomm.robotcore.util.ElapsedTime;
  36. import com.qualcomm.robotcore.hardware.Servo;
  37.  
  38. public class Hardware {
  39.  
  40. public DcMotor BackLeftMotor = null;
  41. public DcMotor FrontRightMotor = null;
  42. public DcMotor FrontLeftMotor = null;
  43. public DcMotor BackRightMotor = null;
  44. public DcMotor HookMotor1 = null;
  45. public DcMotor HookMotor2 = null;
  46.  
  47. HardwareMap HardMap = null;
  48.  
  49.  
  50. public Hardware() {}
  51.  
  52. public void init(HardwareMap PHP) {
  53. // Save reference to Hardware map
  54. HardMap = PHP;
  55.  
  56. // Define and Initialize Motors
  57. BackLeftMotor = HardMap.get(DcMotor.class, "Left_Back");
  58. FrontRightMotor = HardMap.get(DcMotor.class, "Right_Front");
  59. FrontLeftMotor = HardMap.get(DcMotor.class, "Left_Front");
  60. BackRightMotor = HardMap.get(DcMotor.class, "Right_Back");
  61. HookMotor1 = HardMap.get(DcMotor.class, "Hook_Motor_1");
  62. HookMotor2 = HardMap.get(DcMotor.class, "Hook_Motor_2");
  63.  
  64.  
  65. BackLeftMotor.setDirection(DcMotor.Direction.FORWARD);
  66. FrontRightMotor.setDirection(DcMotor.Direction.REVERSE);
  67. FrontLeftMotor.setDirection(DcMotor.Direction.FORWARD);
  68. BackRightMotor.setDirection(DcMotor.Direction.REVERSE);
  69. HookMotor1.setDirection(DcMotor.Direction.FORWARD);
  70. HookMotor2.setDirection(DcMotor.Direction.FORWARD);
  71.  
  72. BackLeftMotor.setPower(0);
  73. FrontRightMotor.setPower(0);
  74. FrontLeftMotor.setPower(0);
  75. BackRightMotor.setPower(0);
  76. HookMotor1.setPower(0);
  77. HookMotor2.setPower(0);
  78.  
  79. BackLeftMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  80. FrontRightMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  81. FrontLeftMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  82. BackRightMotor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  83. HookMotor1.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  84. HookMotor2.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
  85.  
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement