[commands] Replace SysId hash map with if statements (#6209)

This is much more efficient.
This commit is contained in:
Tyler Veness
2024-01-12 12:36:59 -08:00
committed by GitHub
parent d181e353a0
commit b482321c0d
3 changed files with 25 additions and 18 deletions

View File

@@ -214,14 +214,16 @@ public class SysIdRoutine extends SysIdRoutineLog {
* @return A command to run the test.
*/
public Command quasistatic(Direction direction) {
Timer timer = new Timer();
double outputSign = direction == Direction.kForward ? 1.0 : -1.0;
State state =
Map.ofEntries(
entry(Direction.kForward, State.kQuasistaticForward),
entry(Direction.kReverse, State.kQuasistaticReverse))
.get(direction);
State state;
if (direction == Direction.kForward) {
state = State.kQuasistaticForward;
} else { // if (direction == Direction.kReverse) {
state = State.kQuasistaticReverse;
}
double outputSign = direction == Direction.kForward ? 1.0 : -1.0;
Timer timer = new Timer();
return m_mechanism
.m_subsystem
.runOnce(timer::start)