diff --git a/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h index a4fec0028d..b44aee5626 100644 --- a/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h @@ -88,7 +88,7 @@ class LinearSystemSim { */ void SetInput(const Vectord& u) { m_u = ClampInput(u); } - /* + /** * Sets the system inputs. * * @param row The row in the input matrix to set. @@ -99,6 +99,21 @@ class LinearSystemSim { ClampInput(m_u); } + /** + * Returns the current input of the plant. + * + * @return The current input of the plant. + */ + const Vectord& GetInput() const { return m_u; } + + /** + * Returns an element of the current input of the plant. + * + * @param row The row to return. + * @return An element of the current input of the plant. + */ + double GetInput(int row) const { return m_u(row); } + /** * Sets the system state. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java index cc4db9cb2e..8207bb556f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java @@ -137,6 +137,26 @@ public class LinearSystemSim(new SimpleMatrix(m_u.getNumRows(), 1, true, u)); + m_u = clampInput(m_u); + } + + /** + * Returns the current input of the plant. + * + * @return The current input of the plant. + */ + public Matrix getInput() { + return m_u; + } + + /** + * Returns an element of the current input of the plant. + * + * @param row The row to return. + * @return An element of the current input of the plant. + */ + public double getInput(int row) { + return m_u.get(row, 0); } /**