21 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL =
double,
typename SCALAR = SCALAR_EVAL>
25 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
36 TermQuadratic(
const state_matrix_t& Q,
const control_matrix_t& R);
39 const control_matrix_t& R,
51 void setWeights(
const Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM>& Q,
52 const Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM>& R);
66 const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>&
u,
72 ct::core::ADCGScalar
t)
override;
77 const SCALAR_EVAL&
t)
override;
81 const SCALAR_EVAL&
t)
override;
85 const SCALAR_EVAL&
t)
override;
89 const SCALAR_EVAL&
t)
override;
93 const SCALAR_EVAL&
t)
override;
96 const std::string& termName,
99 virtual void updateReferenceState(
const Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1>& newRefState)
override;
101 virtual void updateReferenceControl(
const Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, 1>& newRefControl)
override;
103 virtual Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1>
getReferenceState()
const override;
106 template <
typename SC>
107 SC
evalLocal(
const Eigen::Matrix<SC, STATE_DIM, 1>&
x,
const Eigen::Matrix<SC, CONTROL_DIM, 1>&
u,
const SC&
t);
117 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
118 template <
typename SC>
120 const Eigen::Matrix<SC, CONTROL_DIM, 1>&
u,
123 Eigen::Matrix<SC, STATE_DIM, 1> xDiff = (x -
x_ref_.template cast<SC>());
124 Eigen::Matrix<SC, CONTROL_DIM, 1> uDiff = (u -
u_ref_.template cast<SC>());
126 return (xDiff.transpose() *
Q_.template cast<SC>() * xDiff + uDiff.transpose() *
R_.template cast<SC>() * uDiff)(
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
SC evalLocal(const Eigen::Matrix< SC, STATE_DIM, 1 > &x, const Eigen::Matrix< SC, CONTROL_DIM, 1 > &u, const SC &t)
Definition: TermQuadratic.hpp:119
control_matrix_t R_
Definition: TermQuadratic.hpp:110
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_double_t
Definition: TermQuadratic.hpp:30
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
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermQuadratic.hpp:27
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
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_double_t
Definition: TermQuadratic.hpp:31
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
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_double_t
Definition: TermQuadratic.hpp:32
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
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
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