-
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.
add static current characterization routines
- Loading branch information
1 parent
017d723
commit a5655f7
Showing
6 changed files
with
126 additions
and
41 deletions.
There are no files selected for viewing
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
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
48 changes: 48 additions & 0 deletions
48
src/main/java/frc/robot/arm/ArmStaticCharacterization.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,48 @@ | ||
package frc.robot.arm; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.lib.LoggedTunableNumber; | ||
import java.util.function.DoubleConsumer; | ||
import java.util.function.DoubleSupplier; | ||
|
||
public class ArmStaticCharacterization extends Command { | ||
private static final LoggedTunableNumber currentRampFactor = | ||
new LoggedTunableNumber("StaticCharacterization/CurrentRampPerSec", 1.0); | ||
private static final LoggedTunableNumber minVelocity = | ||
new LoggedTunableNumber("StaticCharacterization/MinStaticVelocity", 0.1); | ||
|
||
private final DoubleConsumer m_inputConsumer; | ||
private final DoubleSupplier m_velocitySupplier; | ||
private final Timer m_timer = new Timer(); | ||
private double m_currentInput = 0.0; | ||
|
||
public ArmStaticCharacterization( | ||
Arm arm, DoubleConsumer characterizationInputConsumer, DoubleSupplier velocitySupplier) { | ||
m_inputConsumer = characterizationInputConsumer; | ||
this.m_velocitySupplier = velocitySupplier; | ||
addRequirements(arm); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
m_timer.restart(); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
m_currentInput = m_timer.get() * currentRampFactor.get(); | ||
m_inputConsumer.accept(m_currentInput); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return m_velocitySupplier.getAsDouble() >= minVelocity.get(); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
System.out.println("Static Characterization output: " + m_currentInput + " amps"); | ||
m_inputConsumer.accept(0); | ||
} | ||
} |
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