mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Make public final values in feedforwards private and add getters (#6851)
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. */
|
||||
public final double ks;
|
||||
private final double ks;
|
||||
|
||||
/** The gravity gain, in volts. */
|
||||
public final double kg;
|
||||
private final double kg;
|
||||
|
||||
/** The velocity gain, in volt seconds per radian. */
|
||||
public final double kv;
|
||||
/** The velocity gain, in V/(rad/s). */
|
||||
private final double kv;
|
||||
|
||||
/** The acceleration gain, in volt seconds² per radian. */
|
||||
public final double ka;
|
||||
/** The acceleration gain, in V/(rad/s²). */
|
||||
private final double ka;
|
||||
|
||||
/** Arm feedforward protobuf for serialization. */
|
||||
public static final ArmFeedforwardProto proto = new ArmFeedforwardProto();
|
||||
@@ -69,6 +69,42 @@ public class ArmFeedforward implements ProtobufSerializable, StructSerializable
|
||||
this(ks, kg, kv, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @return The static gain, in volts.
|
||||
*/
|
||||
public double getKs() {
|
||||
return ks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
* @return The gravity gain, in volts.
|
||||
*/
|
||||
public double getKg() {
|
||||
return kg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @return The velocity gain, in V/(rad/s).
|
||||
*/
|
||||
public double getKv() {
|
||||
return kv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @return The acceleration gain, in V/(rad/s²).
|
||||
*/
|
||||
public double getKa() {
|
||||
return ka;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoints.
|
||||
*
|
||||
|
||||
@@ -18,16 +18,16 @@ import edu.wpi.first.util.struct.StructSerializable;
|
||||
*/
|
||||
public class ElevatorFeedforward implements ProtobufSerializable, StructSerializable {
|
||||
/** The static gain. */
|
||||
public final double ks;
|
||||
private final double ks;
|
||||
|
||||
/** The gravity gain. */
|
||||
public final double kg;
|
||||
private final double kg;
|
||||
|
||||
/** The velocity gain. */
|
||||
public final double kv;
|
||||
private final double kv;
|
||||
|
||||
/** The acceleration gain. */
|
||||
public final double ka;
|
||||
private final double ka;
|
||||
|
||||
/** ElevatorFeedforward protobuf for serialization. */
|
||||
public static final ElevatorFeedforwardProto proto = new ElevatorFeedforwardProto();
|
||||
@@ -71,6 +71,42 @@ public class ElevatorFeedforward implements ProtobufSerializable, StructSerializ
|
||||
this(ks, kg, kv, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @return The static gain.
|
||||
*/
|
||||
public double getKs() {
|
||||
return ks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the gravity gain.
|
||||
*
|
||||
* @return The gravity gain.
|
||||
*/
|
||||
public double getKg() {
|
||||
return kg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @return The velocity gain.
|
||||
*/
|
||||
public double getKv() {
|
||||
return kv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @return The acceleration gain.
|
||||
*/
|
||||
public double getKa() {
|
||||
return ka;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoints.
|
||||
*
|
||||
|
||||
@@ -14,16 +14,16 @@ import edu.wpi.first.units.Voltage;
|
||||
/** A helper class that computes feedforward outputs for a simple permanent-magnet DC motor. */
|
||||
public class SimpleMotorFeedforward {
|
||||
/** The static gain. */
|
||||
public final double ks;
|
||||
private final double ks;
|
||||
|
||||
/** The velocity gain. */
|
||||
public final double kv;
|
||||
private final double kv;
|
||||
|
||||
/** The acceleration gain. */
|
||||
public final double ka;
|
||||
private final double ka;
|
||||
|
||||
/** The period. */
|
||||
private double m_dt;
|
||||
private final double m_dt;
|
||||
|
||||
/**
|
||||
* Creates a new SimpleMotorFeedforward with the specified gains and period. Units of the gain
|
||||
@@ -80,6 +80,42 @@ public class SimpleMotorFeedforward {
|
||||
this(ks, kv, 0, 0.020);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the static gain.
|
||||
*
|
||||
* @return The static gain.
|
||||
*/
|
||||
public double getKs() {
|
||||
return ks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity gain.
|
||||
*
|
||||
* @return The velocity gain.
|
||||
*/
|
||||
public double getKv() {
|
||||
return kv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the acceleration gain.
|
||||
*
|
||||
* @return The acceleration gain.
|
||||
*/
|
||||
public double getKa() {
|
||||
return ka;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the period.
|
||||
*
|
||||
* @return The period in seconds.
|
||||
*/
|
||||
public double getDt() {
|
||||
return m_dt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoints.
|
||||
*
|
||||
|
||||
@@ -32,9 +32,9 @@ public class ArmFeedforwardProto implements Protobuf<ArmFeedforward, ProtobufArm
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufArmFeedforward msg, ArmFeedforward value) {
|
||||
msg.setKs(value.ks);
|
||||
msg.setKg(value.kg);
|
||||
msg.setKv(value.kv);
|
||||
msg.setKa(value.ka);
|
||||
msg.setKs(value.getKs());
|
||||
msg.setKg(value.getKg());
|
||||
msg.setKv(value.getKv());
|
||||
msg.setKa(value.getKa());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class ElevatorFeedforwardProto
|
||||
|
||||
@Override
|
||||
public void pack(ProtobufElevatorFeedforward msg, ElevatorFeedforward value) {
|
||||
msg.setKs(value.ks);
|
||||
msg.setKg(value.kg);
|
||||
msg.setKv(value.kv);
|
||||
msg.setKa(value.ka);
|
||||
msg.setKs(value.getKs());
|
||||
msg.setKg(value.getKg());
|
||||
msg.setKv(value.getKv());
|
||||
msg.setKa(value.getKa());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ArmFeedforwardStruct implements Struct<ArmFeedforward> {
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, ArmFeedforward value) {
|
||||
bb.putDouble(value.ks);
|
||||
bb.putDouble(value.kg);
|
||||
bb.putDouble(value.kv);
|
||||
bb.putDouble(value.ka);
|
||||
bb.putDouble(value.getKs());
|
||||
bb.putDouble(value.getKg());
|
||||
bb.putDouble(value.getKv());
|
||||
bb.putDouble(value.getKa());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ElevatorFeedforwardStruct implements Struct<ElevatorFeedforward> {
|
||||
|
||||
@Override
|
||||
public void pack(ByteBuffer bb, ElevatorFeedforward value) {
|
||||
bb.putDouble(value.ks);
|
||||
bb.putDouble(value.kg);
|
||||
bb.putDouble(value.kv);
|
||||
bb.putDouble(value.ka);
|
||||
bb.putDouble(value.getKs());
|
||||
bb.putDouble(value.getKg());
|
||||
bb.putDouble(value.getKv());
|
||||
bb.putDouble(value.getKa());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user