-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElevatorSequenceCommand.java
More file actions
55 lines (46 loc) · 1.93 KB
/
ElevatorSequenceCommand.java
File metadata and controls
55 lines (46 loc) · 1.93 KB
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
46
47
48
49
50
51
52
53
54
55
package frc.robot.commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import frc.robot.ElevatorLevel;
import frc.robot.subsystems.Elevator;
/**
* An autonomous command that sequentially raises the elevator to each level
* and then returns it to the initial position.
*/
public class ElevatorSequenceCommand extends SequentialCommandGroup {
/**
* Creates a new ElevatorSequenceCommand.
* This command will:
* 1. Move the elevator to LOW
* 2. Move the elevator to MED
* 3. Move the elevator to HIGH
* 4. Move the elevator to EXTRA_HIGH
* 5. Return to the initial position (LOW)
*
* @param elevator The elevator subsystem to control
*/
public ElevatorSequenceCommand(Elevator elevator) {
// Set the subsystem requirements
addRequirements(elevator);
// Define delay between movements to make it move slowly
final double DELAY_SECONDS = 2.0;
// Add commands to the sequence
addCommands(
// Move to LOW level first
new InstantCommand(() -> elevator.setTarget(ElevatorLevel.LOW)),
new WaitCommand(DELAY_SECONDS),
// Move to MED level
new InstantCommand(() -> elevator.setTarget(ElevatorLevel.MED)),
new WaitCommand(DELAY_SECONDS),
// Move to HIGH level
new InstantCommand(() -> elevator.setTarget(ElevatorLevel.HIGH)),
new WaitCommand(DELAY_SECONDS),
// Move to EXTRA_HIGH level
new InstantCommand(() -> elevator.setTarget(ElevatorLevel.EXTRA_HIGH)),
new WaitCommand(DELAY_SECONDS),
// Return to initial position (LOW)
new InstantCommand(() -> elevator.setTarget(ElevatorLevel.LOW))
);
}
}