mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[wpimath] Add setters to Feedforward gains (#7784)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <wpi/MathExtras.h>
|
||||
#include <wpi/SymbolExports.h>
|
||||
|
||||
@@ -249,6 +251,13 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
*/
|
||||
constexpr units::volt_t GetKs() const { return kS; }
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @param kS The static gain.
|
||||
*/
|
||||
constexpr void SetKs(units::volt_t kS) { this->kS = kS; }
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
@@ -256,6 +265,13 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
*/
|
||||
constexpr units::volt_t GetKg() const { return kG; }
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
* @param kG The gravity gain.
|
||||
*/
|
||||
constexpr void SetKg(units::volt_t kG) { this->kG = kG; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
@@ -263,6 +279,13 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<kv_unit> GetKv() const { return kV; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @param kV The velocity gain.
|
||||
*/
|
||||
constexpr void SetKv(units::unit_t<kv_unit> kV) { this->kV = kV; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
@@ -270,6 +293,13 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<ka_unit> GetKa() const { return kA; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @param kA The acceleration gain.
|
||||
*/
|
||||
constexpr void SetKa(units::unit_t<ka_unit> kA) { this->kA = kA; }
|
||||
|
||||
private:
|
||||
/// The static gain, in volts.
|
||||
units::volt_t kS;
|
||||
|
||||
@@ -223,6 +223,13 @@ class ElevatorFeedforward {
|
||||
*/
|
||||
constexpr units::volt_t GetKs() const { return kS; }
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @param kS The static gain.
|
||||
*/
|
||||
constexpr void SetKs(units::volt_t kS) { this->kS = kS; }
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
@@ -230,6 +237,13 @@ class ElevatorFeedforward {
|
||||
*/
|
||||
constexpr units::volt_t GetKg() const { return kG; }
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
* @param kG The gravity gain.
|
||||
*/
|
||||
constexpr void SetKg(units::volt_t kG) { this->kG = kG; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
@@ -237,6 +251,13 @@ class ElevatorFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<kv_unit> GetKv() const { return kV; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @param kV The velocity gain.
|
||||
*/
|
||||
constexpr void SetKv(units::unit_t<kv_unit> kV) { this->kV = kV; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
@@ -244,6 +265,13 @@ class ElevatorFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<ka_unit> GetKa() const { return kA; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @param kA The acceleration gain.
|
||||
*/
|
||||
constexpr void SetKa(units::unit_t<ka_unit> kA) { this->kA = kA; }
|
||||
|
||||
private:
|
||||
/// The static gain.
|
||||
units::volt_t kS;
|
||||
|
||||
@@ -201,6 +201,13 @@ class SimpleMotorFeedforward {
|
||||
*/
|
||||
constexpr units::volt_t GetKs() const { return kS; }
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @param kS The static gain.
|
||||
*/
|
||||
constexpr void SetKs(units::volt_t kS) { this->kS = kS; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
@@ -208,6 +215,13 @@ class SimpleMotorFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<kv_unit> GetKv() const { return kV; }
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @param kV The velocity gain.
|
||||
*/
|
||||
constexpr void SetKv(units::unit_t<kv_unit> kV) { this->kV = kV; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
@@ -215,6 +229,13 @@ class SimpleMotorFeedforward {
|
||||
*/
|
||||
constexpr units::unit_t<ka_unit> GetKa() const { return kA; }
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @param kA The acceleration gain.
|
||||
*/
|
||||
constexpr void SetKa(units::unit_t<ka_unit> kA) { this->kA = kA; }
|
||||
|
||||
/**
|
||||
* Returns the period.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user