mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Fix and deprecate TrapezoidProfileCommand (#6722)
This commit is contained in:
@@ -8,7 +8,6 @@ import static edu.wpi.first.math.trajectory.TrapezoidProfile.State;
|
||||
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
|
||||
|
||||
import edu.wpi.first.math.trajectory.TrapezoidProfile;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -17,12 +16,12 @@ import java.util.function.Supplier;
|
||||
*
|
||||
* <p>This class is provided by the NewCommands VendorDep
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public class TrapezoidProfileCommand extends Command {
|
||||
private final TrapezoidProfile m_profile;
|
||||
private final Consumer<State> m_output;
|
||||
private final Supplier<State> m_goal;
|
||||
private final Supplier<State> m_currentState;
|
||||
private final Timer m_timer = new Timer();
|
||||
|
||||
/**
|
||||
* Creates a new TrapezoidProfileCommand that will execute the given {@link TrapezoidProfile}.
|
||||
@@ -49,23 +48,19 @@ public class TrapezoidProfileCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
m_timer.restart();
|
||||
}
|
||||
public void initialize() {}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
public void execute() {
|
||||
m_output.accept(m_profile.calculate(m_timer.get(), m_currentState.get(), m_goal.get()));
|
||||
m_output.accept(m_profile.calculate(0.02, m_currentState.get(), m_goal.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
m_timer.stop();
|
||||
}
|
||||
public void end(boolean interrupted) {}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return m_timer.hasElapsed(m_profile.totalTime());
|
||||
return m_profile.isFinished(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user