-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement Continuous algebraic Riccati equation function #157
Conversation
68157ad
to
010b452
Compare
src/Math/include/BipedalLocomotion/Math/AlgebraicRiccatiEquation.h
Outdated
Show resolved
Hide resolved
constexpr double symmetricTolerance = 1e-8; | ||
if (!Q.isApprox(Q.transpose(), symmetricTolerance)) | ||
{ | ||
std::cerr << errorPrefix << "The matrix Q must be symmetric." << std::endl; | ||
result.first = false; | ||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could possibly be an utility function which could be used in other instances for debugging (for example also in estimators library). What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symmetricTolerance
parameter could be a generic defnition across the framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it might be time-consuming. Consider having a way to skip that, like putting it into an assert.
hI, @S-Dafarra I was trying to transform the function into a class but I've several doubts. I was thinking to organize it as bool initialize(std::weak_ptr<ParametersHandler::IParametersHandler> handler);
bool setMatrices(Eigen::Ref<const Eigen::MatrixXd> A,
Eigen::Ref<const Eigen::MatrixXd> B,
Eigen::Ref<const Eigen::MatrixXd> Q,
Eigen::Ref<const Eigen::MatrixXd> R);
Solution getSolution();
bool getSolution(Eigen::Ref<Eigen::MatrixXd> S); however, I don't know how to split the code. For instance, in For instance this code will run the algorithm 4 times. CARE care();
care.setMatrices(A,B,Q,R);
CARE::Solution sol = care.getSolution();
sol = care.getSolution();
sol = care.getSolution();
sol = care.getSolution();
sol = care.getSolution(); So the question is: shall we compute the solution while setting Eigen::MatrixXd Z = H;
Eigen::MatrixXd Z_old; Indeed every time we set new matrices |
I think you can add a |
I like it |
Hi @S-Dafarra and @prashanthr05 I completely restructure the code. Let me know what you think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also clarified the previous doubt of the Hamiltonian matrix's subblock sign differences from Wikipedia. Turns out the choice used here is also a Hamiltonian matrix because it respects the identity
(the requirement of off-diagonal elements being symmetric and the sum of diagonal elements equal to zero is the property).
For me the changes look neat. However, I will also incorporate @S-Dafarra suggestions.
/** | ||
* Initialize the continuous algebraic riccati equation solver. | ||
* @param handler pointer to the parameter handler. | ||
* @note The following parameters are required by the class: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this note needs to be changed since the parameters are optional, rather, the method itself is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3c6176d
@S-Dafarra let me know if you're fine with the modifications |
Yes, feel free to merge as soon as the CI passes. |
This PR implements an algorithm to solve the Continuous algebraic Riccati equation.
The main idea has been taken from
drake
.cc @Giulero