This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
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.
refactor: Add single jointed arm feedforward.
- Loading branch information
1 parent
c8795ef
commit 17b17f7
Showing
3 changed files
with
39 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.lib; | ||
|
||
import edu.wpi.first.math.controller.ArmFeedforward; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
|
||
public class SingleJointedArmFeedforward { | ||
|
||
private final ArmFeedforward feedforward; | ||
|
||
public SingleJointedArmFeedforward(double ks, double kg, double kv) { | ||
feedforward = new ArmFeedforward(ks, kg, kv); | ||
} | ||
|
||
public SingleJointedArmFeedforward(double ks, double kg, double kv, double ka) { | ||
feedforward = new ArmFeedforward(ks, kg, kv, ka); | ||
} | ||
|
||
public double calculate(Rotation2d position) { | ||
return feedforward.calculate(position.getRadians(), 0); | ||
} | ||
|
||
public double calculate(Rotation2d position, double velocity) { | ||
return feedforward.calculate(position.getRadians(), velocity); | ||
} | ||
|
||
public double calculate(Rotation2d position, double velocity, double acceleration) { | ||
return feedforward.calculate(position.getRadians(), velocity, acceleration); | ||
} | ||
|
||
} |
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