Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpilib] Add missing clamp function and getInput() to LinearSystemSim #6493

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class LinearSystemSim {
*/
void SetInput(const Vectord<Inputs>& u) { m_u = ClampInput(u); }

/*
/**
* Sets the system inputs.
*
* @param row The row in the input matrix to set.
Expand All @@ -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<Inputs>& 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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ public void setInput(double... u) {
"Malformed input! Got " + u.length + " elements instead of " + m_u.getNumRows());
}
m_u = new Matrix<>(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<Inputs, N1> 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);
}

/**
Expand Down
Loading