qp_solver_unconstraint_fast.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018-2021 The Autoware Foundation
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "mpc_lateral_controller/qp_solver/qp_solver_unconstraint_fast.hpp"
  15. #include <Eigen/Dense>
  16. namespace autoware::motion::control::mpc_lateral_controller
  17. {
  18. QPSolverEigenLeastSquareLLT::QPSolverEigenLeastSquareLLT()
  19. {
  20. }
  21. bool QPSolverEigenLeastSquareLLT::solve(
  22. const Eigen::MatrixXd & h_mat, const Eigen::MatrixXd & f_vec, const Eigen::MatrixXd & /*a*/,
  23. const Eigen::VectorXd & /*lb*/, const Eigen::VectorXd & /*ub*/, const Eigen::VectorXd & /*lb_a*/,
  24. const Eigen::VectorXd & /*ub_a*/, Eigen::VectorXd & u)
  25. {
  26. if (std::fabs(h_mat.determinant()) < 1.0E-9) {
  27. return false;
  28. }
  29. u = -h_mat.llt().solve(f_vec);
  30. return true;
  31. }
  32. } // namespace autoware::motion::control::mpc_lateral_controller