Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use suppliers for constraints in superstructure #221

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ private void configureButtonBindings() {
})
.andThen(
superstructure.setGoalWithConstraintsCommand(
Superstructure.Goal.AMP, Arm.smoothProfileConstraints.get()))));
Superstructure.Goal.AMP, Arm.smoothConstraints))));
driver
.rightTrigger()
.and(driver.b())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public static Command trapSequence(
.withTimeout(5.0)
.alongWith(
superstructure.setGoalWithConstraintsCommand(
Superstructure.Goal.PREPARE_CLIMB,
Arm.prepareClimbProfileConstraints.get()),
Superstructure.Goal.PREPARE_CLIMB, Arm.prepareClimbConstraints),
rollers.setGoalCommand(Rollers.Goal.SHUFFLE_BACKPACK)),

// Allow driver to line up and climb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import java.util.function.Supplier;
import lombok.Getter;
import org.littletonrobotics.frc2024.subsystems.superstructure.arm.Arm;
import org.littletonrobotics.frc2024.subsystems.superstructure.backpackactuator.BackpackActuator;
Expand Down Expand Up @@ -211,10 +212,10 @@ public Command setGoalCommand(Goal goal) {

/** Command to set goal of superstructure with additional profile constraints on arm */
public Command setGoalWithConstraintsCommand(
Goal goal, TrapezoidProfile.Constraints armProfileConstraints) {
Goal goal, Supplier<TrapezoidProfile.Constraints> armProfileConstraints) {
return setGoalCommand(goal)
.beforeStarting(() -> arm.setProfileConstraints(armProfileConstraints))
.finallyDo(() -> arm.setProfileConstraints(Arm.maxProfileConstraints.get()));
.beforeStarting(() -> arm.setProfileConstraints(armProfileConstraints.get()))
.finallyDo(() -> arm.setProfileConstraints(Arm.maxConstraints.get()));
}

/** Command to aim the superstructure with a compensation value in degrees */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class Arm {
private static final LoggedTunableNumber upperLimitDegrees =
new LoggedTunableNumber("Arm/UpperLimitDegrees", maxAngle.getDegrees());
// Profile constraints
public static final Supplier<TrapezoidProfile.Constraints> maxProfileConstraints =
public static final Supplier<TrapezoidProfile.Constraints> maxConstraints =
() -> new TrapezoidProfile.Constraints(maxVelocity.get(), maxAcceleration.get());
public static final Supplier<TrapezoidProfile.Constraints> smoothProfileConstraints =
public static final Supplier<TrapezoidProfile.Constraints> smoothConstraints =
() -> new TrapezoidProfile.Constraints(smoothVelocity.get(), smoothAcceleration.get());
public static final Supplier<TrapezoidProfile.Constraints> prepareClimbProfileConstraints =
public static final Supplier<TrapezoidProfile.Constraints> prepareClimbConstraints =
() ->
new TrapezoidProfile.Constraints(
prepareClimbVelocity.get(), prepareClimbAcceleration.get());
Expand Down Expand Up @@ -103,7 +103,7 @@ private double getRads() {
private final ArmIOInputsAutoLogged inputs = new ArmIOInputsAutoLogged();

@AutoLogOutput @Setter private double currentCompensation = 0.0;
private TrapezoidProfile.Constraints currentConstraints = maxProfileConstraints.get();
private TrapezoidProfile.Constraints currentConstraints = maxConstraints.get();
private TrapezoidProfile profile;
private TrapezoidProfile.State setpointState = new TrapezoidProfile.State();
private ArmFeedforward ff;
Expand Down
Loading