11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
16 const bool trackControlTrajectory)
19 x_traj_ref_(stateSplineType),
20 u_traj_ref_(controlSplineType),
21 trackControlTrajectory_(trackControlTrajectory)
25 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
34 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
46 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
51 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
59 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
63 Q_ = Q.template cast<SCALAR_EVAL>();
64 R_ = R.template cast<SCALAR_EVAL>();
67 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
77 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
79 const Eigen::Matrix<SCALAR, STATE_DIM, 1>&
x,
80 const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>&
u,
83 return evalLocal<SCALAR>(
x,
u,
t);
86 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
93 Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1> xDiff = x -
x_traj_ref_.eval(t);
95 return xDiff.transpose() *
Q_.transpose() + xDiff.transpose() *
Q_;
98 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
103 const SCALAR_EVAL&
t)
105 return Q_ +
Q_.transpose();
108 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
113 const SCALAR_EVAL&
t)
115 Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, 1> uDiff;
122 return uDiff.transpose() *
R_.transpose() + uDiff.transpose() *
R_;
125 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
130 const SCALAR_EVAL&
t)
132 return R_ +
R_.transpose();
135 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
140 const SCALAR_EVAL&
t)
142 return control_state_matrix_t::Zero();
145 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
147 const std::string& termName,
154 std::cout <<
"Read Q as Q = \n" <<
Q_ << std::endl;
155 std::cout <<
"Read R as R = \n" <<
R_ << std::endl;
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_double_t
Definition: TermBase.hpp:42
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: TermQuadTracking.hpp:27
TermQuadTracking< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * clone() const override
Deep-copy term.
Definition: TermQuadTracking-impl.hpp:53
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
An interface for a term, supporting both analytical and auto-diff terms.
Definition: TermBase.hpp:30
A quadratic tracking term of type .
Definition: TermQuadTracking.hpp:20
void setWeights(const state_matrix_double_t &Q, const control_matrix_double_t &R)
Definition: TermQuadTracking-impl.hpp:60
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: TermQuadTracking-impl.hpp:88
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: TermQuadTracking-impl.hpp:137
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: TermQuadTracking-impl.hpp:100
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
CppAD::AD< CppAD::cg::CG< double > > SCALAR
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: TermQuadTracking-impl.hpp:78
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
void setStateAndControlReference(const core::StateTrajectory< STATE_DIM > &xTraj, const core::ControlTrajectory< CONTROL_DIM > &uTraj)
Definition: TermQuadTracking-impl.hpp:68
ct::core::ControlTrajectory< CONTROL_DIM, SCALAR_EVAL > u_traj_ref_
Definition: TermQuadTracking.hpp:88
control_matrix_t R_
Definition: TermQuadTracking.hpp:84
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermBase.hpp:39
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_double_t
Definition: TermBase.hpp:43
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: TermQuadTracking-impl.hpp:127
virtual void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false) override
load this term from a configuration file
Definition: TermQuadTracking-impl.hpp:146
const bool verbose
Definition: ConstraintComparison.h:18
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: TermQuadTracking-impl.hpp:110
void loadMatrixCF(const std::string &filename, const std::string &matrixName, Eigen::Matrix< SCALAR, ROW, COL > &matrix, const std::string &termName="")
Definition: utilities.hpp:46
virtual ~TermQuadTracking()
Definition: TermQuadTracking-impl.hpp:47
TermQuadTracking()
Definition: TermQuadTracking-impl.hpp:26
ct::core::StateTrajectory< STATE_DIM, SCALAR_EVAL > x_traj_ref_
Definition: TermQuadTracking.hpp:87
state_matrix_t Q_
Definition: TermQuadTracking.hpp:83
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermQuadTracking.hpp:26
bool trackControlTrajectory_
Definition: TermQuadTracking.hpp:91
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermBase.hpp:40