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

Handle solver failures like TrajOpt does #369

Merged
merged 8 commits into from
Dec 6, 2023

Conversation

rjoomen
Copy link
Contributor

@rjoomen rjoomen commented Nov 28, 2023

  • Added max_qp_solver_failures parameter and the logic of TrajOpt to handle solver failures
  • Added updateBounds() call after each box size modification
  • Moved setVariables() call after a solver failure to solveQPProblem()
  • Renamed SQPStatus::TIME_LIMIT to SQPStatus::OPT_TIME_LIMIT because of a name collision with OSQP (in tesseract_planning)

Closes #368

@rjoomen
Copy link
Contributor Author

rjoomen commented Nov 28, 2023

I'm not entirely sure about removing the setVariables, what do you think, @Levi-Armstrong?

The calls to updateBounds() seems necessary to me, as box size changes do modify the bounds here.

@Levi-Armstrong
Copy link
Contributor

I'm not entirely sure about removing the setVariables, what do you think, @Levi-Armstrong?

The calls to updateBounds() seems necessary to me, as box size changes do modify the bounds here.

Yea, the set variables need to stay because it need to set them back to the previous iterations values.

if (status_ != SQPStatus::RUNNING)
{
qp_problem->setVariables(results_.best_var_vals.data());
Copy link
Contributor

Choose a reason for hiding this comment

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

This just needs to be added back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why here exactly? Wouldn't adding it to solveQPProblem() upon failure (in the else block) be more logical?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that would work since it would need to be set before convexify is called in stepSQPSolver. I think we might be able to move into that method but I would want to do a lot of testing to make sure everything aligns with the legacy version before making a change like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't this equivalent? In the previous version solveQPProblem() is called, and if qp_solver->solve() failed and hence solveQPProblem() failed setVariables is called from withing runTrustRegionLoop(). Now I moved this line to solveQPProblem(), still to be called if qp_solver->solve() failed. It's just clearer now, as solveQPProblem() either sets the variables to new_var_vals and back to best_var_vals if succeeded and immediately to best_var_vals if failed. See line 386 in my PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know the numerical ik has difference on Jammy because on one interaction it returns iteration limit instead of approximate solution but focal produces identical results. I am currently running focal so let me know if you want me to compare since I think you are running jammy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, I'm running in that issue exactly! But I've also access to focal (I'm using WSL), so I'll run it there tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I could tell both hit the iteration limit but because of slight numerical differences focal picks approximate solution and jammy pick iteration limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm, I'm seeing other differences on Focal. And Focal and Jammy do not match. Would you mind taking a look?

Copy link
Contributor

Choose a reason for hiding this comment

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

I will take a look

@rjoomen
Copy link
Contributor Author

rjoomen commented Nov 28, 2023

Unstable/jammy fails due to clang-tidy-14. It needs a more extensive clang-tidy config, I think. Ubuntu/jammy succeeds, as no clang-tidy is found.

@Levi-Armstrong
Copy link
Contributor

Unstable/jammy fails due to clang-tidy-14. It needs a more extensive clang-tidy config, I think. Ubuntu/jammy succeeds, as no clang-tidy is found.

Lets try for CI to install the same version of clang-tidy that is used on focal for now until we have time to go through and upgrade to the latest version of clang-tidy.

…handle solver failures

- Added updateBounds() call after each box size modification
- Removed setVariables() call after a solver failure
- Renamed SQPStatus::TIME_LIMIT to SQPStatus::OPT_TIME_LIMIT because of a name collision with OSQP (in tesseract_planning)
@Levi-Armstrong
Copy link
Contributor

I compared trajopt_sqp numerical ik output between this branch and master with no differences found. I think your changes are good.

@Levi-Armstrong
Copy link
Contributor

@rjoomen You good with me squash merging this?

@rjoomen
Copy link
Contributor Author

rjoomen commented Dec 6, 2023

Go ahead! Thanks for checking

@Levi-Armstrong Levi-Armstrong merged commit 713cc9d into tesseract-robotics:master Dec 6, 2023
7 of 8 checks passed
@rjoomen rjoomen deleted the maxsolverfailures branch December 8, 2023 06:51
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.

TrajOptIfopt lacks max_qp_solver_failures parameter and logic
2 participants