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

Adds osqp and qpOASES solver interfaces #40

Conversation

arocchi
Copy link
Contributor

@arocchi arocchi commented Nov 9, 2018

Adds osqp and qpOASES in the list of available solvers.
Automatically runs all tests that use a convex solver with all the list of solvers detected as available on the machine.
Disabled test calling solver with a non positive semi-definite matrix.
Please notice this needs a good refactor to simplify code in common between osqp and qpOASES solver, but at the moment there are issues with memory alignment that can cause weird errors whenever a serious refactor is attempted. All Eigen instances possibly causing alignment issues in the tesseract/trajopt stack should be reviewed.

Please review @Levi-Armstrong.

Notice that while this change seems trivial, it actually causes tests to pass.
Since bpmpd interface is quite brittle, it was the case that using it as a third option
in tests caused some of them to fail. This means the order of execution of tests
has an influence on the solver, which is a bad sign.
@Levi-Armstrong
Copy link
Contributor

@arocchi This is awesome and thank you for the contribution. I am on vacation next week and will try to get it reviewed this weekend.

@Levi-Armstrong
Copy link
Contributor

Also I submitted PR #42 that should fix the eigen aligned issues. For some reason I thought this was no longer need. It is possible that I did not catch all the places where it is need. I am unable to recreate the issue @mpowelson was having with the examples.

@Levi-Armstrong
Copy link
Contributor

I gave it a brief glance. I always hate asking because it seems nitpicky, but I plan to eventually migrate the style to using the ros cpp sytle guide so with new addition I would like to follow the ros style guide if that is not to painful. To help with formatting the repository has s a clang file.

Also I notice the use of raw pointers a few places would it be good to replace them with shared pointers?

@arocchi
Copy link
Contributor Author

arocchi commented Nov 10, 2018

perfect, I'm on it!

Notice this should be reviewed after bpmpd is removed and all memory
alignment problems are resolved. In fact, right now the solver is
occasionally instantiated twice in each solve cycle: this makes
test pass.
@arocchi
Copy link
Contributor Author

arocchi commented Nov 11, 2018

refactored to take into account clang & roscpp guidelines. Doxygen is still lacking, but after we fix memory alignment issues and the solvers are refactored, cleanup + doxygen will follow

@Levi-Armstrong
Copy link
Contributor

@arocchi In search for the Eigen Issues I did some cleaning in trajopt packages and found one more structure without the Eigen Macro. I am unable to recreate the issue on my machine but let me know if you still have the issue if you test with PR #43.

@arocchi
Copy link
Contributor Author

arocchi commented Nov 16, 2018

Thanks @Levi-Armstrong - I will check it later today and get back to you.

@arocchi
Copy link
Contributor Author

arocchi commented Nov 20, 2018

Tried code on new tesseract and trajopt, and find the issue (on my side that was causing the problem)
The new solver_utils work and I am in the process of refactoring the osqp and qpoases solver interfaces using them

@arocchi
Copy link
Contributor Author

arocchi commented Nov 22, 2018

@Levi-Armstrong @bhaskara @mpowelson please review. This refactors the new solvers using a shared set of solver_utils which is fairly clean, tested and allows to quickly add new solvers beyond qpOASES and osqp. Notice it contains #43.

@Levi-Armstrong
Copy link
Contributor

@arocchi Do you mind re-basing on the latest and I will review it tomorrow?

@arocchi
Copy link
Contributor Author

arocchi commented Nov 28, 2018

will do!

@arocchi
Copy link
Contributor Author

arocchi commented Nov 28, 2018

@Levi-Armstrong I merged instead of rebasing, hope this is ok. Let me know otherwise! It is good to review. I added a new functionality to specify a solver in JSONs / ProblemConstructionInfo, I think this should need more testing. Please go ahead with the review, I will address comments and come up with more unit testing for this feature as I receive the review.

@Levi-Armstrong
Copy link
Contributor

There still appears to be conflicts.

@arocchi
Copy link
Contributor Author

arocchi commented Nov 29, 2018

As new branches are merged, conflicts appear. In particular, the last one was over new-lines. Fixed now.

trajopt_sco/include/trajopt_sco/expr_ops.hpp Show resolved Hide resolved
trajopt_sco/src/osqp_interface.cpp Show resolved Hide resolved
trajopt_sco/src/osqp_interface.cpp Show resolved Hide resolved
trajopt_sco/src/solver_interface.cpp Show resolved Hide resolved
trajopt_utils/src/logging.cpp Show resolved Hide resolved
trajopt_sco/include/trajopt_sco/osqp_interface.hpp Outdated Show resolved Hide resolved
trajopt_sco/include/trajopt_sco/osqp_interface.hpp Outdated Show resolved Hide resolved
trajopt_sco/include/trajopt_sco/qpoases_interface.hpp Outdated Show resolved Hide resolved
trajopt_sco/include/trajopt_sco/qpoases_interface.hpp Outdated Show resolved Hide resolved
@Levi-Armstrong
Copy link
Contributor

I am also looking into if we should use Factory style approach for the solvers.

@Levi-Armstrong
Copy link
Contributor

Overall looks great just a few minor things.

Copy link

@bhaskara bhaskara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of high level comments, which feel free to ignore as I'm not very familiar with this codebase.

trajopt_sco/src/osqp_interface.cpp Outdated Show resolved Hide resolved
@@ -148,5 +149,53 @@ std::ostream& operator<<(std::ostream&, const Cnt&);
std::ostream& operator<<(std::ostream&, const AffExpr&);
std::ostream& operator<<(std::ostream&, const QuadExpr&);

ModelPtr createModel();
class ConvexSolver

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need a whole class for this given that it seems to just wrap an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a solution I came up to have a place to easily manage conversions from string and to string, for logging and loading of the enum from json (strings are more readable than ints!).
I am open for suggestions in case we can make it more elegant!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to look at something similar to what is shown here but this can be done in a separate PR.

@arocchi
Copy link
Contributor Author

arocchi commented Dec 6, 2018

@Levi-Armstrong bump

@Levi-Armstrong
Copy link
Contributor

@arocchi Then only think left is the discussion around naming of enum to ModelType.

@arocchi
Copy link
Contributor Author

arocchi commented Dec 6, 2018

@Levi-Armstrong I renamed ConvexSolver into ModelType, let me know your thoughts about it so that we can proceed with the PR

@Levi-Armstrong
Copy link
Contributor

@arocchi It is saying there are conflicts with the base branch. Do yo mind rebasing and then I will merge?

@arocchi
Copy link
Contributor Author

arocchi commented Dec 7, 2018

@Levi-Armstrong latest commit from kinetic-devel has been merged in e369b4b - and on my side github does not mention conflicts, but it still mentions a "Changes requested" from your review...

@Levi-Armstrong
Copy link
Contributor

@arocchi It will not let me merge it. It says This branch cannot be rebased due to conflicts but it does not give me any indication what the conflict is.

@Levi-Armstrong Levi-Armstrong merged commit e96e303 into tesseract-robotics:kinetic-devel Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants