Skip to content

Commit e07710e

Browse files
authored
created the statemachine's layout (#12)
* created the statemachine I made the "shell" of the statemachine based of the given list for the states, and our drive states from on season. * created the outline for all commands
1 parent 213fb94 commit e07710e

34 files changed

+1827
-11
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ public static boolean isRedAlliance() {
237237
public static final Pose2d WORKSHOP_STARTING_POSE = new Pose2d(5.98, 2.60, new Rotation2d(0));
238238
}
239239

240+
public static class constElevator {
241+
242+
public static final Distance CORAL_L1_HEIGHT = Units.Inches.of(0);
243+
public static final Distance CORAL_L2_HEIGHT = Units.Inches.of(0);
244+
public static final Distance CORAL_L3_HEIGHT = Units.Inches.of(0);
245+
public static final Distance CORAL_L4_HEIGHT = Units.Inches.of(0);
246+
247+
}
248+
240249
public static class constVision {
241250
/**
242251
* <p>

src/main/java/frc/robot/RobotContainer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public class RobotContainer {
2525
private final SN_XboxController conDriver = new SN_XboxController(mapControllers.DRIVER_USB);
2626

2727
private final Drivetrain subDrivetrain = new Drivetrain();
28-
private final StateMachine subStateMachine = new StateMachine(subDrivetrain);
28+
private final Intake subIntake = new Intake();
29+
private final Climber subClimber = new Climber();
30+
private final Elevator subElevator = new Elevator();
31+
private final StateMachine subStateMachine = new StateMachine(subDrivetrain, subIntake, subClimber, subElevator);
2932
private final RobotPoses robotPose = new RobotPoses(subDrivetrain);
3033

3134
Command TRY_NONE = Commands.deferredProxy(

src/main/java/frc/robot/commands/States/None.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// Open Source Software; you can modify and/or share it under the terms of
33
// the WPILib BSD license file in the root directory of this project.
44

5-
package frc.robot.commands.states;
5+
package frc.robot.commands.States;
66

7+
import frc.robot.subsystems.StateMachine.RobotState;
78
import edu.wpi.first.wpilibj2.command.Command;
89
import frc.robot.subsystems.*;
910

@@ -22,7 +23,7 @@ public None(StateMachine globalStateMachine) {
2223
// Called when the command is initially scheduled.
2324
@Override
2425
public void initialize() {
25-
globalStateMachine.setRobotState(StateMachine.RobotState.NONE);
26+
globalStateMachine.setRobotState(RobotState.NONE);
2627
}
2728

2829
// Called every time the scheduler runs while the command is scheduled.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.climbing;
6+
7+
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.subsystems.Elevator;
9+
import frc.robot.subsystems.StateMachine;
10+
import frc.robot.subsystems.StateMachine.RobotState;
11+
12+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
13+
public class Climbing extends Command {
14+
StateMachine globalStateMachine;
15+
16+
public Climbing(StateMachine globalStateMachine, Elevator subElevator) {
17+
// Use addRequirements() here to declare subsystem dependencies.
18+
this.globalStateMachine = globalStateMachine;
19+
addRequirements(globalStateMachine);
20+
}
21+
22+
// Called when the command is initially scheduled.
23+
@Override
24+
public void initialize() {
25+
globalStateMachine.setRobotState(RobotState.CLIMBING);
26+
}
27+
28+
// Called every time the scheduler runs while the command is scheduled.
29+
@Override
30+
public void execute() {
31+
}
32+
33+
// Called once the command ends or is interrupted.
34+
@Override
35+
public void end(boolean interrupted) {
36+
}
37+
38+
// Returns true when the command should end.
39+
@Override
40+
public boolean isFinished() {
41+
return false;
42+
}
43+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
// Copyright (c) FIRST and other WPILib contributors.
3+
// Open Source Software; you can modify and/or share it under the terms of
4+
// the WPILib BSD license file in the root directory of this project.
5+
6+
package frc.robot.commands.States.climbing;
7+
8+
import edu.wpi.first.wpilibj2.command.Command;
9+
import frc.robot.subsystems.Climber;
10+
import frc.robot.subsystems.Elevator;
11+
import frc.robot.subsystems.Intake;
12+
import frc.robot.subsystems.StateMachine;
13+
import frc.robot.subsystems.StateMachine.RobotState;
14+
15+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
16+
public class PrepClimb extends Command {
17+
/** Creates a new PrepClimb. */
18+
StateMachine globalStateMachine;
19+
20+
public PrepClimb(StateMachine globalStateMachine, Climber subClimber, Intake subIntake, Elevator subElevator) {
21+
// Use addRequirements() here to declare subsystem dependencies.
22+
this.globalStateMachine = globalStateMachine;
23+
addRequirements(globalStateMachine);
24+
}
25+
26+
// Called when the command is initially scheduled.
27+
@Override
28+
public void initialize() {
29+
globalStateMachine.setRobotState(RobotState.PREP_CLIMB);
30+
}
31+
32+
// Called every time the scheduler runs while the command is scheduled.
33+
@Override
34+
public void execute() {
35+
}
36+
37+
// Called once the command ends or is interrupted.
38+
@Override
39+
public void end(boolean interrupted) {
40+
}
41+
42+
// Returns true when the command should end.
43+
@Override
44+
public boolean isFinished() {
45+
return false;
46+
}
47+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.climbing;
6+
7+
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.subsystems.Climber;
9+
import frc.robot.subsystems.StateMachine;
10+
import frc.robot.subsystems.StateMachine.RobotState;
11+
12+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
13+
public class RetractingClimber extends Command {
14+
StateMachine globalStateMachine;
15+
16+
public RetractingClimber(StateMachine globalStateMachine, Climber subClimber) {
17+
// Use addRequirements() here to declare subsystem dependencies.
18+
this.globalStateMachine = globalStateMachine;
19+
addRequirements(globalStateMachine);
20+
}
21+
22+
// Called when the command is initially scheduled.
23+
@Override
24+
public void initialize() {
25+
globalStateMachine.setRobotState(RobotState.RETRACTING_CLIMBER);
26+
}
27+
28+
// Called every time the scheduler runs while the command is scheduled.
29+
@Override
30+
public void execute() {
31+
}
32+
33+
// Called once the command ends or is interrupted.
34+
@Override
35+
public void end(boolean interrupted) {
36+
}
37+
38+
// Returns true when the command should end.
39+
@Override
40+
public boolean isFinished() {
41+
return false;
42+
}
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.first_scoring_element;
6+
7+
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.subsystems.StateMachine;
9+
import frc.robot.subsystems.StateMachine.RobotState;
10+
11+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
12+
public class CleanHigh extends Command {
13+
StateMachine globalStateMachine;
14+
15+
public CleanHigh(StateMachine globalStateMachine) {
16+
// Use addRequirements() here to declare subsystem dependencies.
17+
this.globalStateMachine = globalStateMachine;
18+
addRequirements(globalStateMachine);
19+
}
20+
21+
// Called when the command is initially scheduled.
22+
@Override
23+
public void initialize() {
24+
globalStateMachine.setRobotState(RobotState.CLEAN_HIGH);
25+
}
26+
27+
// Called every time the scheduler runs while the command is scheduled.
28+
@Override
29+
public void execute() {
30+
}
31+
32+
// Called once the command ends or is interrupted.
33+
@Override
34+
public void end(boolean interrupted) {
35+
}
36+
37+
// Returns true when the command should end.
38+
@Override
39+
public boolean isFinished() {
40+
return false;
41+
}
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.first_scoring_element;
6+
7+
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.subsystems.StateMachine;
9+
import frc.robot.subsystems.StateMachine.RobotState;
10+
11+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
12+
public class CleanLow extends Command {
13+
StateMachine globalStateMachine;
14+
15+
public CleanLow(StateMachine globalStateMachine) {
16+
// Use addRequirements() here to declare subsystem dependencies.
17+
this.globalStateMachine = globalStateMachine;
18+
addRequirements(globalStateMachine);
19+
}
20+
21+
// Called when the command is initially scheduled.
22+
@Override
23+
public void initialize() {
24+
globalStateMachine.setRobotState(RobotState.CLEAN_LOW);
25+
}
26+
27+
// Called every time the scheduler runs while the command is scheduled.
28+
@Override
29+
public void execute() {
30+
}
31+
32+
// Called once the command ends or is interrupted.
33+
@Override
34+
public void end(boolean interrupted) {
35+
}
36+
37+
// Returns true when the command should end.
38+
@Override
39+
public boolean isFinished() {
40+
return false;
41+
}
42+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.first_scoring_element;
6+
7+
import frc.robot.subsystems.StateMachine.RobotState;
8+
import edu.wpi.first.wpilibj2.command.Command;
9+
import frc.robot.subsystems.StateMachine;
10+
11+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
12+
public class IntakeAlgaeGround extends Command {
13+
/** Creates a new IntakeAlgaeGround. */
14+
StateMachine globalStateMachine;
15+
16+
public IntakeAlgaeGround(StateMachine globalStateMachine) {
17+
// Use addRequirements() here to declare subsystem dependencies.
18+
this.globalStateMachine = globalStateMachine;
19+
addRequirements(globalStateMachine);
20+
}
21+
22+
// Called when the command is initially scheduled.
23+
@Override
24+
public void initialize() {
25+
globalStateMachine.setRobotState(RobotState.INTAKE_ALGAE_GROUND);
26+
}
27+
28+
// Called every time the scheduler runs while the command is scheduled.
29+
@Override
30+
public void execute() {
31+
}
32+
33+
// Called once the command ends or is interrupted.
34+
@Override
35+
public void end(boolean interrupted) {
36+
}
37+
38+
// Returns true when the command should end.
39+
@Override
40+
public boolean isFinished() {
41+
return false;
42+
}
43+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands.States.first_scoring_element;
6+
7+
import frc.robot.subsystems.StateMachine.RobotState;
8+
import edu.wpi.first.wpilibj2.command.Command;
9+
import frc.robot.subsystems.StateMachine;
10+
11+
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
12+
public class IntakeCoralGround extends Command {
13+
StateMachine globalStateMachine;
14+
15+
public IntakeCoralGround(StateMachine globalStateMachine) {
16+
// Use addRequirements() here to declare subsystem dependencies.
17+
this.globalStateMachine = globalStateMachine;
18+
addRequirements(globalStateMachine);
19+
}
20+
21+
// Called when the command is initially scheduled.
22+
@Override
23+
public void initialize() {
24+
globalStateMachine.setRobotState(RobotState.INTAKE_CORAL_GROUND);
25+
}
26+
27+
// Called every time the scheduler runs while the command is scheduled.
28+
@Override
29+
public void execute() {
30+
}
31+
32+
// Called once the command ends or is interrupted.
33+
@Override
34+
public void end(boolean interrupted) {
35+
}
36+
37+
// Returns true when the command should end.
38+
@Override
39+
public boolean isFinished() {
40+
return false;
41+
}
42+
}

0 commit comments

Comments
 (0)