[wpimath] Add setters to Feedforward gains (#7784)

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
This commit is contained in:
Jade
2025-02-14 13:09:28 +08:00
committed by GitHub
parent e22f76ce73
commit 4d126b158c
6 changed files with 189 additions and 11 deletions

View File

@@ -16,16 +16,16 @@ import edu.wpi.first.util.struct.StructSerializable;
*/
public class ArmFeedforward implements ProtobufSerializable, StructSerializable {
/** The static gain, in volts. */
private final double ks;
private double ks;
/** The gravity gain, in volts. */
private final double kg;
private double kg;
/** The velocity gain, in V/(rad/s). */
private final double kv;
private double kv;
/** The acceleration gain, in V/(rad/s²). */
private final double ka;
private double ka;
/** The period, in seconds. */
private final double m_dt;
@@ -95,6 +95,15 @@ public class ArmFeedforward implements ProtobufSerializable, StructSerializable
return ks;
}
/**
* Sets the static gain.
*
* @param ks The static gain in volts.
*/
public void setKs(double ks) {
this.ks = ks;
}
/**
* Returns the gravity gain in volts.
*
@@ -104,6 +113,15 @@ public class ArmFeedforward implements ProtobufSerializable, StructSerializable
return kg;
}
/**
* Sets the gravity gain.
*
* @param kg The gravity gain in volts.
*/
public void setKg(double kg) {
this.kg = kg;
}
/**
* Returns the velocity gain in V/(rad/s).
*
@@ -113,6 +131,15 @@ public class ArmFeedforward implements ProtobufSerializable, StructSerializable
return kv;
}
/**
* Sets the velocity gain.
*
* @param kv The velocity gain in V/(rad/s).
*/
public void setKv(double kv) {
this.kv = kv;
}
/**
* Returns the acceleration gain in V/(rad/s²).
*
@@ -122,6 +149,15 @@ public class ArmFeedforward implements ProtobufSerializable, StructSerializable
return ka;
}
/**
* Sets the acceleration gain.
*
* @param ka The acceleration gain in V/(rad/2²).
*/
public void setKa(double ka) {
this.ka = ka;
}
/**
* Returns the period in seconds.
*

View File

@@ -15,16 +15,16 @@ import edu.wpi.first.util.struct.StructSerializable;
*/
public class ElevatorFeedforward implements ProtobufSerializable, StructSerializable {
/** The static gain, in volts. */
private final double ks;
private double ks;
/** The gravity gain, in volts. */
private final double kg;
private double kg;
/** The velocity gain, in V/(m/s). */
private final double kv;
private double kv;
/** The acceleration gain, in V/(m/s²). */
private final double ka;
private double ka;
/** The period, in seconds. */
private final double m_dt;
@@ -95,6 +95,15 @@ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializ
return ks;
}
/**
* Sets the static gain.
*
* @param ks The static gain in volts.
*/
public void setKs(double ks) {
this.ks = ks;
}
/**
* Returns the gravity gain in volts.
*
@@ -104,6 +113,15 @@ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializ
return kg;
}
/**
* Sets the gravity gain.
*
* @param kg The gravity gain in volts.
*/
public void setKg(double kg) {
this.kg = kg;
}
/**
* Returns the velocity gain in V/(m/s).
*
@@ -113,6 +131,15 @@ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializ
return kv;
}
/**
* Sets the velocity gain.
*
* @param kv The velocity gain in V/(rad/s).
*/
public void setKv(double kv) {
this.kv = kv;
}
/**
* Returns the acceleration gain in V/(m/s²).
*
@@ -122,6 +149,15 @@ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializ
return ka;
}
/**
* Sets the acceleration gain.
*
* @param ka The acceleration gain in V/(rad/2²).
*/
public void setKa(double ka) {
this.ka = ka;
}
/**
* Returns the period in seconds.
*

View File

@@ -12,13 +12,13 @@ import edu.wpi.first.util.struct.StructSerializable;
/** A helper class that computes feedforward outputs for a simple permanent-magnet DC motor. */
public class SimpleMotorFeedforward implements ProtobufSerializable, StructSerializable {
/** The static gain, in volts. */
private final double ks;
private double ks;
/** The velocity gain, in V/(units/s). */
private final double kv;
private double kv;
/** The acceleration gain, in V/(units/s²). */
private final double ka;
private double ka;
/** The period, in seconds. */
private final double m_dt;
@@ -92,6 +92,15 @@ public class SimpleMotorFeedforward implements ProtobufSerializable, StructSeria
return ks;
}
/**
* Sets the static gain.
*
* @param ks The static gain in volts.
*/
public void setKs(double ks) {
this.ks = ks;
}
/**
* Returns the velocity gain in V/(units/s).
*
@@ -103,6 +112,15 @@ public class SimpleMotorFeedforward implements ProtobufSerializable, StructSeria
return kv;
}
/**
* Sets the velocity gain.
*
* @param kv The velocity gain in V/(rad/s).
*/
public void setKv(double kv) {
this.kv = kv;
}
/**
* Returns the acceleration gain in V/(units/s²).
*
@@ -114,6 +132,15 @@ public class SimpleMotorFeedforward implements ProtobufSerializable, StructSeria
return ka;
}
/**
* Sets the acceleration gain.
*
* @param ka The acceleration gain in V/(rad/2²).
*/
public void setKa(double ka) {
this.ka = ka;
}
/**
* Returns the period in seconds.
*