mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[commands] Remove deprecated TrapzoidProfileCommand api (#6547)
This commit is contained in:
@@ -22,7 +22,6 @@ public class TrapezoidProfileCommand extends Command {
|
||||
private final Consumer<State> m_output;
|
||||
private final Supplier<State> m_goal;
|
||||
private final Supplier<State> m_currentState;
|
||||
private final boolean m_newAPI; // TODO: Remove
|
||||
private final Timer m_timer = new Timer();
|
||||
|
||||
/**
|
||||
@@ -46,29 +45,6 @@ public class TrapezoidProfileCommand extends Command {
|
||||
m_output = requireNonNullParam(output, "output", "TrapezoidProfileCommand");
|
||||
m_goal = goal;
|
||||
m_currentState = currentState;
|
||||
m_newAPI = true;
|
||||
addRequirements(requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TrapezoidProfileCommand that will execute the given {@link TrapezoidProfile}.
|
||||
* Output will be piped to the provided consumer function.
|
||||
*
|
||||
* @param profile The motion profile to execute.
|
||||
* @param output The consumer for the profile output.
|
||||
* @param requirements The subsystems required by this command.
|
||||
* @deprecated The new constructor allows you to pass in a supplier for desired and current state.
|
||||
* This allows you to change goals at runtime.
|
||||
*/
|
||||
@Deprecated(since = "2024", forRemoval = true)
|
||||
@SuppressWarnings("this-escape")
|
||||
public TrapezoidProfileCommand(
|
||||
TrapezoidProfile profile, Consumer<State> output, Subsystem... requirements) {
|
||||
m_profile = requireNonNullParam(profile, "profile", "TrapezoidProfileCommand");
|
||||
m_output = requireNonNullParam(output, "output", "TrapezoidProfileCommand");
|
||||
m_newAPI = false;
|
||||
m_goal = null;
|
||||
m_currentState = null;
|
||||
addRequirements(requirements);
|
||||
}
|
||||
|
||||
@@ -80,11 +56,7 @@ public class TrapezoidProfileCommand extends Command {
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
public void execute() {
|
||||
if (m_newAPI) {
|
||||
m_output.accept(m_profile.calculate(m_timer.get(), m_currentState.get(), m_goal.get()));
|
||||
} else {
|
||||
m_output.accept(m_profile.calculate(m_timer.get()));
|
||||
}
|
||||
m_output.accept(m_profile.calculate(m_timer.get(), m_currentState.get(), m_goal.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,28 +52,6 @@ class TrapezoidProfileCommand
|
||||
m_goal(goal),
|
||||
m_currentState(currentState) {
|
||||
this->AddRequirements(requirements);
|
||||
m_newAPI = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TrapezoidProfileCommand that will execute the given
|
||||
* TrapezoidalProfile. Output will be piped to the provided consumer function.
|
||||
*
|
||||
* @param profile The motion profile to execute.
|
||||
* @param output The consumer for the profile output.
|
||||
* @param requirements The list of requirements.
|
||||
* @deprecated The new constructor allows you to pass in a supplier for
|
||||
* desired and current state. This allows you to change goals at runtime.
|
||||
*/
|
||||
[[deprecated(
|
||||
"The new constructor allows you to pass in a supplier for desired and "
|
||||
"current state. This allows you to change goals at runtime.")]]
|
||||
TrapezoidProfileCommand(frc::TrapezoidProfile<Distance> profile,
|
||||
std::function<void(State)> output,
|
||||
Requirements requirements = {})
|
||||
: m_profile(profile), m_output(output) {
|
||||
this->AddRequirements(requirements);
|
||||
m_newAPI = false;
|
||||
}
|
||||
|
||||
void Initialize() override { m_timer.Restart(); }
|
||||
@@ -93,7 +71,6 @@ class TrapezoidProfileCommand
|
||||
std::function<void(State)> m_output;
|
||||
std::function<State()> m_goal;
|
||||
std::function<State()> m_currentState;
|
||||
bool m_newAPI; // TODO: Remove
|
||||
frc::Timer m_timer;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user