added velocity control

This commit is contained in:
Aarav
2023-03-01 16:45:57 -07:00
parent 1fa95bbacb
commit 3cdf5e65fe
2 changed files with 15 additions and 0 deletions
@@ -110,6 +110,8 @@ public final class Constants {
public static final double MAX_ARM_LEN = 2;
public static final double ARM_HEIGHT = 1;
public static final double CURVE_POWER = 2;
public static final double TELE_TICKS_PER_SECOND = (-5);
public static final double PIVOT_FORWARD_SOFT_LIMIT = -1.0; // TODO: find actual value
public static final double PIVOT_REVERSE_SOFT_LIMIT = -1.0; // TODO: find actual value
@@ -46,6 +46,14 @@ public class Arm extends SubsystemBase {
this(pivot, tele, encoder, false);
}
public void setRotVel(double vel) {
m_pivot.set(ControlMode.Velocity, vel);
}
public void setTeleVel(double vel) {
m_tele.set(ControlMode.Velocity, vel);
}
public void armSetRotation(double rot) {
if (rot > 1 || rot < 0) return;
// Move arm code
@@ -71,6 +79,11 @@ public class Arm extends SubsystemBase {
(ArmConstants.TELE_REVERSE_SOFT_LIMIT - ArmConstants.TELE_FORWARD_SOFT_LIMIT);
}
public double getArmRotation() {
return (m_pivotEncoder.getAbsolutePosition() - ArmConstants.PIVOT_FORWARD_SOFT_LIMIT) /
(ArmConstants.PIVOT_REVERSE_SOFT_LIMIT - ArmConstants.PIVOT_FORWARD_SOFT_LIMIT);
}
public void runPivotTele(double pivot, double tele) {
var rot = 0;