14 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
21 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
26 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
32 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
35 this->
backend_->setInitialGuess(initialGuess);
38 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
46 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
49 if (!this->
backend_->isInitialized())
50 throw std::runtime_error(
"iLQR is not initialized!");
53 throw std::runtime_error(
"iLQR is not configured!");
58 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
61 int K = this->
backend_->getNumSteps();
63 bool debugPrint = this->
backend_->getSettings().debugPrint;
66 if (this->
backend_->iteration() == 0)
68 if (!this->
backend_->nominalRollout())
69 throw std::runtime_error(
"Rollout failed. System became unstable");
74 #ifdef MATLAB_FULL_LOG 75 if (this->
backend_->iteration() == 0)
79 auto start = std::chrono::steady_clock::now();
80 auto startEntire = start;
83 this->
backend_->setBoxConstraintsForLQOCProblem();
84 this->
backend_->computeLQApproximation(0, K - 1);
85 auto end = std::chrono::steady_clock::now();
86 auto diff = end - start;
88 std::cout <<
"[iLQR]: Computing LQ approximation took " 89 << std::chrono::duration<double, std::milli>(diff).
count() <<
" ms" << std::endl;
91 end = std::chrono::steady_clock::now();
92 diff = end - startEntire;
94 std::cout <<
"[iLQR]: Forward pass took " << std::chrono::duration<double, std::milli>(diff).
count() <<
" ms" 98 std::cout <<
"[iLQR]: #2 Solve LQOC Problem" << std::endl;
100 start = std::chrono::steady_clock::now();
101 this->
backend_->solveFullLQProblem();
102 end = std::chrono::steady_clock::now();
105 std::cout <<
"[iLQR]: Solving LQOC problem took " << std::chrono::duration<double, std::milli>(diff).
count()
106 <<
" ms" << std::endl;
110 std::cout <<
"[iLQR]: #3 LineSearch" << std::endl;
112 start = std::chrono::steady_clock::now();
113 bool foundBetter = this->
backend_->lineSearch();
114 end = std::chrono::steady_clock::now();
117 std::cout <<
"[iLQR]: Line search took " << std::chrono::duration<double, std::milli>(diff).
count() <<
" ms" 120 diff = end - startEntire;
122 std::cout <<
"[iLQR]: finishIteration took " << std::chrono::duration<double, std::milli>(diff).
count() <<
" ms" 127 #ifdef MATLAB_FULL_LOG 136 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
142 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
Definition: NLOCAlgorithm.hpp:19
virtual void setInitialGuess(const Policy_t &initialGuess) override
set an initial guess
Definition: iLQR-impl.hpp:33
virtual bool finishIteration() override
Definition: iLQR-impl.hpp:59
std::shared_ptr< Backend_t > backend_
Definition: NLOCAlgorithm.hpp:47
virtual bool finishMPCIteration() override
Definition: iLQR-impl.hpp:143
Settings for the NLOptCon algorithm.
Definition: NLOptConSettings.hpp:145
iLQR(std::shared_ptr< Backend_t > &backend_, const Settings_t &settings)
constructor
Definition: iLQR-impl.hpp:15
virtual void configure(const Settings_t &settings) override
configure the solver
Definition: iLQR-impl.hpp:27
virtual void prepareMPCIteration() override
Definition: iLQR-impl.hpp:137
virtual bool runIteration() override
runIteration combines prepareIteration and finishIteration
Definition: iLQR-impl.hpp:39
virtual ~iLQR()
destructor
Definition: iLQR-impl.hpp:22
virtual void prepareIteration() override
Definition: iLQR-impl.hpp:47
Base::Policy_t Policy_t
Definition: iLQR.hpp:31