generated from Spikes-2212-Programming-Guild/Plain-Robot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into gil-path-planner-swerve
- Loading branch information
Showing
20 changed files
with
855 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.commands.MoveGenericSubsystem; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.subsystems.Gripper; | ||
import java.util.function.Supplier; | ||
|
||
public class IntakeAlgae extends MoveGenericSubsystem { | ||
|
||
private static final RootNamespace NAMESPACE = new RootNamespace("intake algae"); | ||
private static final Supplier<Double> INTAKE_SPEED = NAMESPACE.addConstantDouble("intake speed", 0.9); | ||
private static final Supplier<Double> TIME_TO_INTAKE = NAMESPACE.addConstantDouble("time to intake", 0.2); | ||
|
||
private double startTime; | ||
|
||
public IntakeAlgae(Gripper gripper) { | ||
super(gripper, INTAKE_SPEED); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
startTime = Timer.getFPGATimestamp(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return super.isFinished() && Timer.getFPGATimestamp() - startTime >= TIME_TO_INTAKE.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.commands.MoveGenericSubsystem; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import frc.robot.subsystems.Storage; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class IntakeCoral extends MoveGenericSubsystem { | ||
|
||
private static final RootNamespace NAMESPACE = new RootNamespace("intake coral"); | ||
private static final Supplier<Double> INTAKE_SPEED = NAMESPACE.addConstantDouble("intake speed", 0.5); | ||
|
||
public IntakeCoral(Storage storage) { | ||
super(storage, INTAKE_SPEED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.commands.smartmotorcontrollergenericsubsystem. | ||
MoveSmartMotorControllerGenericSubsystem; | ||
import com.spikes2212.control.FeedForwardController; | ||
import com.spikes2212.control.FeedForwardSettings; | ||
import com.spikes2212.control.PIDSettings; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import com.spikes2212.util.UnifiedControlMode; | ||
import frc.robot.subsystems.Elevator; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class MoveToHeight extends MoveSmartMotorControllerGenericSubsystem { | ||
|
||
private static final RootNamespace namespace = new RootNamespace("move to height"); | ||
private static final PIDSettings pidSettings = namespace.addPIDNamespace("move to height"); | ||
private static final FeedForwardSettings feedForwardSettings = namespace.addFeedForwardNamespace("move to height", | ||
FeedForwardController.ControlMode.LINEAR_POSITION); | ||
|
||
private final Elevator elevator; | ||
|
||
public MoveToHeight(Elevator elevator, Supplier<Double> setpoint) { | ||
super(elevator, pidSettings, feedForwardSettings, UnifiedControlMode.POSITION, setpoint, true); | ||
this.elevator = elevator; | ||
} | ||
|
||
public MoveToHeight(Elevator elevator, Elevator.ElevatorLevel elevatorLevel) { | ||
this(elevator, () -> elevatorLevel.height); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (!isFinished()) { | ||
super.execute(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
double error = setpoint.get() - elevator.getPosition(); | ||
return super.isFinished() || !elevator.canMove(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.subsystems.AlgaeJoint; | ||
import frc.robot.subsystems.Elevator; | ||
import frc.robot.subsystems.Gripper; | ||
|
||
public class PickAlgaeFloar extends SequentialCommandGroup { | ||
|
||
public PickAlgaeFloar(Elevator elevator, AlgaeJoint algaeJoint, Gripper gripper) { | ||
addCommands(new ParallelCommandGroup(new MoveToHeight(elevator, Elevator.ElevatorLevel.BOTTOM), | ||
new RotateAlgaeJointToBottom(algaeJoint)), new IntakeAlgae(gripper)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.subsystems.CoralJoint; | ||
import frc.robot.subsystems.Elevator; | ||
import frc.robot.subsystems.Storage; | ||
|
||
public class PlaceOnReef extends SequentialCommandGroup { | ||
|
||
public PlaceOnReef(Elevator elevator, CoralJoint coralJoint, Storage storage, Elevator.ElevatorLevel level) { | ||
addCommands(new ParallelCommandGroup( | ||
new MoveToHeight(elevator, level), | ||
new RotateStorage(coralJoint, CoralJoint.StoragePose.PLACEMENT)), | ||
new ReleaseCoral(storage), new ParallelCommandGroup( | ||
new MoveToHeight(elevator, Elevator.ElevatorLevel.FEEDER), | ||
new RotateStorage(coralJoint, CoralJoint.StoragePose.INTAKE))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.commands.MoveGenericSubsystem; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.subsystems.Gripper; | ||
import java.util.function.Supplier; | ||
|
||
public class ReleaseAlgae extends MoveGenericSubsystem { | ||
|
||
private static final RootNamespace NAMESPACE = new RootNamespace("release algae"); | ||
private static final Supplier<Double> RELEASE_SPEED = NAMESPACE.addConstantDouble("release speed", -0.5); | ||
private static final Supplier<Double> TIME_TO_RELEASE = NAMESPACE.addConstantDouble("time to release", 0.5); | ||
|
||
private double startTime; | ||
|
||
public ReleaseAlgae(Gripper gripper) { | ||
super(gripper, RELEASE_SPEED); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
startTime = Timer.getFPGATimestamp(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return Timer.getFPGATimestamp() - startTime >= TIME_TO_RELEASE.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.commands.MoveGenericSubsystem; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.subsystems.Storage; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ReleaseCoral extends MoveGenericSubsystem { | ||
|
||
private static final RootNamespace NAMESPACE = new RootNamespace("release coral"); | ||
private static final Supplier<Double> TIME_TO_RELEASE = NAMESPACE.addConstantDouble("time to release", 0.5); | ||
private static final Supplier<Double> RELEASE_SPEED = NAMESPACE.addConstantDouble("release speed", -0.5); | ||
|
||
private double startTime; | ||
|
||
public ReleaseCoral(Storage storage) { | ||
super(storage, RELEASE_SPEED); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
startTime = Timer.getFPGATimestamp(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return Timer.getFPGATimestamp() - startTime >= TIME_TO_RELEASE.get(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/frc/robot/commands/RotateAlgaeJointToBottom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package frc.robot.commands; | ||
|
||
import com.spikes2212.command.genericsubsystem.GenericSubsystem; | ||
import com.spikes2212.command.genericsubsystem.commands.MoveGenericSubsystem; | ||
import com.spikes2212.dashboard.RootNamespace; | ||
import frc.robot.subsystems.AlgaeJoint; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class RotateAlgaeJointToBottom extends MoveGenericSubsystem { | ||
|
||
private static final RootNamespace NAMESPACE = new RootNamespace("rotate algae joint to bottom"); | ||
private static final Supplier<Double> SPEED = NAMESPACE.addConstantDouble("intake speed", -0.5); | ||
|
||
public RotateAlgaeJointToBottom(AlgaeJoint algaeJoint) { | ||
super(algaeJoint, SPEED); | ||
} | ||
} |
Oops, something went wrong.