-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCarousel.java
45 lines (38 loc) · 1.17 KB
/
Carousel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.CRServo;
public class Carousel
{
// Hardware Map
HardwareMap hardwareMap;
// Alliance
Utilities.Alliance alliance;
// Objects
private CRServo carouselMotor;
public Carousel(HardwareMap hardwareMap, Utilities.Alliance alliance)
{
this.hardwareMap = hardwareMap;
this.alliance = alliance;
// Motors
carouselMotor = hardwareMap.get(CRServo.class, "carousel");
}
/**
* Spins the carousel
* This method will know what alliance the robot is on and change the direction by default
* <p>
* @param speed to spin the carousel at.
*/
public void spinCarousel(int speed)
{
if (alliance == Utilities.Alliance.BLUE)
{
carouselMotor.setDirection(CRServo.Direction.FORWARD);
carouselMotor.setPower(Math.abs(speed));
}
else if (alliance == Utilities.Alliance.RED)
{
carouselMotor.setDirection(CRServo.Direction.REVERSE);
carouselMotor.setPower(Math.abs(speed));
}
}
}