13#include <yarp/os/Log.h>
14#include <yarp/math/Math.h>
15#include <yarp/math/SVD.h>
19using namespace yarp::os;
20using namespace yarp::sig;
21using namespace yarp::math;
27 const Matrix &_P,
const Matrix &_VN,
bool verb)
29 A = _A;
At =
A.transposed();
30 B = _B;
Bt =
B.transposed();
35 Ti =
new Matrix[1];
Ti[0].resize(1,1);
Ti[0].zero();
36 Li =
new Matrix[1];
Li[0].resize(1,1);
Li[0].zero();
44 yWarning(
"Riccati: problem defined, unsolved.");
61 yWarning(
"Riccati: DARE has not been solved yet.");
64 if(step>=0 && step>=
N)
67 yWarning(
"Riccati: Index for gain matrix out of bound.");
80 yError(
"Riccati: DARE has not been solved yet.");
86 yError(
"Riccati: Index for DARE matrix out of bound.");
95 const Matrix &_P,
const Matrix &_VN)
97 A = _A;
At =
A.transposed();
98 B = _B;
Bt =
B.transposed();
108 yWarning(
"Riccati: problem defined, unsolved.");
119 Ti =
new Matrix[steps+1];
120 Li =
new Matrix[steps];
121 for(i=0; i<=steps; i++)
122 Ti[i].resize(
VN.rows(),
VN.cols());
126 for(i=steps-1; i>=0; i--)
133 for(i=0;i<steps; i++)
140 yInfo(
"Riccati: DARE solved, matrices Li and Ti computed and stored.");
150 yError(
"Riccati: DARE has not been solved yet.");
154 if(step>=0 && step>
N)
157 yError(
"Riccati: Index for DARE matrix out of bound.");
161 return (
Li[step] * (-1.0*
x));
171 yError(
"Riccati: DARE has not been solved yet.");
174 else if(step>=0 && step>
N)
177 yError(
"Riccati: Index for DARE matrix out of bound.");
183 ret =
Li[step] * (-1.0*
x);
Riccati(const yarp::sig::Matrix &_A, const yarp::sig::Matrix &_B, const yarp::sig::Matrix &_V, const yarp::sig::Matrix &_P, const yarp::sig::Matrix &_VN, bool verb=false)
Constructor, with initialization of algebraic Riccati equation.
void setVerbose(bool verb=true)
Enable or disable verbose feedback (that is, printing additional information)
yarp::sig::Vector doLQcontrol(int step, const yarp::sig::Vector &x)
Compute the LQ feedback control, in the form: ret= - L(i) * x.
void solveRiccati(int steps)
Solve recursively discrete algebraic Riccati equation (DARE) and stores matrices Ti and Li,...
void setProblemData(const yarp::sig::Matrix &_A, const yarp::sig::Matrix &_B, const yarp::sig::Matrix &_V, const yarp::sig::Matrix &_P, const yarp::sig::Matrix &_VN)
Initialization of algebraic Riccati equation.
yarp::sig::Matrix L(int step)
Get stored L_i matrix; call this function only after solveRiccati()
yarp::sig::Matrix T(int step)
Get stored T_i matrix; call this function only after solveRiccati()