ilqr_solver.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019, University of Edinburgh
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_ILQR_SOLVER_ILQR_SOLVER_H_
31 #define EXOTICA_ILQR_SOLVER_ILQR_SOLVER_H_
32 
35 #include <exotica_core/server.h>
36 
37 #include <exotica_ilqr_solver/ilqr_solver_initializer.h>
38 
39 namespace exotica
40 {
41 // This code is based on:
42 // W. Li, E. Todorov, Iterative Linear Quadratic Regulator Design for Nonlinear Biological Movement Systems
43 // https://homes.cs.washington.edu/~todorov/papers/LiICINCO04.pdf
44 class ILQRSolver : public FeedbackMotionSolver, public Instantiable<ILQRSolverInitializer>
45 {
46 public:
49  void Solve(Eigen::MatrixXd& solution) override;
50 
54  void SpecifyProblem(PlanningProblemPtr pointer) override;
55 
56  Eigen::VectorXd GetFeedbackControl(Eigen::VectorXdRefConst x, int t) const override;
57 
58 private:
61  std::vector<Eigen::MatrixXd> K_gains_, Ku_gains_, Kv_gains_, vk_gains_;
62 
63  Eigen::MatrixXd best_ref_x_, best_ref_u_;
64 
67  void BackwardPass();
68 
74  double ForwardPass(const double alpha, Eigen::MatrixXdRefConst ref_x, Eigen::MatrixXdRefConst ref_u);
75 };
76 } // namespace exotica
77 
78 #endif // EXOTICA_ILQR_SOLVER_ILQR_SOLVER_H_
double ForwardPass(const double alpha, Eigen::MatrixXdRefConst ref_x, Eigen::MatrixXdRefConst ref_u)
Forward simulates the dynamics using the gains computed in the last BackwardPass;.
std::vector< Eigen::MatrixXd > Kv_gains_
Definition: ilqr_solver.h:61
Eigen::MatrixXd best_ref_u_
Definition: ilqr_solver.h:63
DynamicTimeIndexedShootingProblemPtr prob_
Definition: ilqr_solver.h:59
std::shared_ptr< exotica::DynamicsSolver > DynamicsSolverPtr
const Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
std::vector< Eigen::MatrixXd > K_gains_
!< Shared pointer to the dynamics solver.
Definition: ilqr_solver.h:61
Eigen::MatrixXd best_ref_x_
!< Control gains.
Definition: ilqr_solver.h:63
void Solve(Eigen::MatrixXd &solution) override
Solves the problem.
void SpecifyProblem(PlanningProblemPtr pointer) override
Binds the solver to a specific problem which must be pre-initalised.
Definition: ilqr_solver.cpp:36
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Eigen::VectorXd GetFeedbackControl(Eigen::VectorXdRefConst x, int t) const override
std::shared_ptr< exotica::DynamicTimeIndexedShootingProblem > DynamicTimeIndexedShootingProblemPtr
std::shared_ptr< PlanningProblem > PlanningProblemPtr
void BackwardPass()
!< Reference trajectory for feedback control.
Definition: ilqr_solver.cpp:47
std::vector< Eigen::MatrixXd > Ku_gains_
Definition: ilqr_solver.h:61
DynamicsSolverPtr dynamics_solver_
!< Shared pointer to the planning problem.
Definition: ilqr_solver.h:60
double x
std::vector< Eigen::MatrixXd > vk_gains_
Definition: ilqr_solver.h:61


exotica_ilqr_solver
Author(s): Traiko Dinev
autogenerated on Sat Apr 10 2021 02:36:33