11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
20 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
29 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
38 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
40 const std::string& termName,
46 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
58 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
64 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
72 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
74 const Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM>& Q,
75 const Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM>& R)
82 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
89 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
96 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
103 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
110 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
120 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
122 const Eigen::Matrix<SCALAR, STATE_DIM, 1>&
x,
123 const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>&
u,
126 return evalLocal<SCALAR>(
x,
u,
t);
130 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
134 ct::core::ADCGScalar
t)
136 return evalLocal<ct::core::ADCGScalar>(
x,
u,
t);
140 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
145 const SCALAR_EVAL& t)
149 return xDiff.transpose() *
Q_.transpose() + xDiff.transpose() *
Q_;
152 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
157 const SCALAR_EVAL& t)
159 return Q_ +
Q_.transpose();
162 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
167 const SCALAR_EVAL& t)
171 return uDiff.transpose() *
R_.transpose() + uDiff.transpose() *
R_;
174 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
179 const SCALAR_EVAL& t)
181 return R_ +
R_.transpose();
184 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
189 const SCALAR_EVAL& t)
191 return control_state_matrix_t::Zero();
194 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
196 const std::string& termName,
199 boost::property_tree::ptree pt;
202 boost::property_tree::read_info(filename, pt);
206 this->
name_ = pt.get<std::string>(termName +
".name.", termName);
214 std::cout <<
"Read Q as Q = \n" <<
Q_ << std::endl;
215 std::cout <<
"Read R as R = \n" <<
R_ << std::endl;
216 std::cout <<
"Read x_des as x_des = \n" <<
x_ref_.transpose() << std::endl;
217 std::cout <<
"Read u_des as u_des = \n" <<
u_ref_.transpose() << std::endl;
222 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
224 const Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1>& newRefState)
229 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
231 const Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, 1>& newRefControl)
236 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
control_state_matrix_t stateControlDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute the cross-term derivative (state-control) of this cost function term
Definition: TermQuadratic-impl.hpp:186
virtual SCALAR evaluate(const Eigen::Matrix< SCALAR, STATE_DIM, 1 > &x, const Eigen::Matrix< SCALAR, CONTROL_DIM, 1 > &u, const SCALAR &t) override
Evaluates the term at x, u, t.
Definition: TermQuadratic-impl.hpp:121
A basic quadratic term of type .
Definition: TermQuadratic.hpp:22
virtual void updateReferenceState(const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > &newRefState) override
updates the reference state for this term
Definition: TermQuadratic-impl.hpp:223
control_matrix_t controlSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute second order derivative of this cost term w.r.t. the control input
Definition: TermQuadratic-impl.hpp:176
virtual void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false) override
load this term from a configuration file
Definition: TermQuadratic-impl.hpp:195
void setStateAndControlReference(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x_ref, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u_ref)
Definition: TermQuadratic-impl.hpp:111
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
control_matrix_t R_
Definition: TermQuadratic.hpp:110
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > u_ref_
Definition: TermQuadratic.hpp:113
core::StateVector< STATE_DIM, SCALAR_EVAL > stateDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute derivative of this cost term w.r.t. the state
Definition: TermQuadratic-impl.hpp:142
An interface for a term, supporting both analytical and auto-diff terms.
Definition: TermBase.hpp:30
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
TermQuadratic()
Definition: TermQuadratic-impl.hpp:21
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > controlDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute derivative of this cost term w.r.t. the control input
Definition: TermQuadratic-impl.hpp:164
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * clone() const override
Deep-copy term.
Definition: TermQuadratic-impl.hpp:66
virtual void updateReferenceControl(const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, 1 > &newRefControl) override
updates the reference control for this term
Definition: TermQuadratic-impl.hpp:230
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
core::StateVector< STATE_DIM, SCALAR_EVAL > x_ref_
Definition: TermQuadratic.hpp:112
virtual Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > getReferenceState() const override
retrieve this term's current reference state
Definition: TermQuadratic-impl.hpp:237
state_matrix_t Q_
Definition: TermQuadratic.hpp:109
virtual ~TermQuadratic()
Definition: TermQuadratic-impl.hpp:59
const state_matrix_t & getStateWeight() const
Definition: TermQuadratic-impl.hpp:84
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermBase.hpp:39
void setWeights(const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > &Q, const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > &R)
Definition: TermQuadratic-impl.hpp:73
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: TermQuadratic.hpp:29
const bool verbose
Definition: ConstraintComparison.h:18
void loadMatrixCF(const std::string &filename, const std::string &matrixName, Eigen::Matrix< SCALAR, ROW, COL > &matrix, const std::string &termName="")
Definition: utilities.hpp:46
std::string name_
a name identifier for this term
Definition: TermBase.hpp:34
state_matrix_t stateSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute second order derivative of this cost term w.r.t. the state
Definition: TermQuadratic-impl.hpp:154
const control_matrix_t & getControlWeight() const
Definition: TermQuadratic-impl.hpp:98
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermQuadratic.hpp:28
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermBase.hpp:40