- 3.0.2 optimal control module.
|
A basic quadratic term of type . More...
#include <TermQuadratic.hpp>
Public Types | |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > | control_matrix_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > | control_state_matrix_t |
typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > | state_matrix_double_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > | control_matrix_double_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > | control_state_matrix_double_t |
Public Types inherited from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > | |
typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > | state_matrix_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > | control_matrix_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > | control_state_matrix_t |
typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > | state_matrix_double_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > | control_matrix_double_t |
typedef Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > | control_state_matrix_double_t |
Public Member Functions | |
TermQuadratic () | |
TermQuadratic (const state_matrix_t &Q, const control_matrix_t &R) | |
TermQuadratic (const state_matrix_t &Q, const control_matrix_t &R, const core::StateVector< STATE_DIM, SCALAR_EVAL > &x_ref, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u_ref) | |
TermQuadratic (const std::string &configFile, const std::string &termName, bool verbose=false) | |
TermQuadratic (const TermQuadratic &arg) | |
virtual | ~TermQuadratic () |
virtual TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * | clone () const override |
Deep-copy term. More... | |
void | setWeights (const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > &Q, const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > &R) |
const state_matrix_t & | getStateWeight () const |
state_matrix_t & | getStateWeight () |
const control_matrix_t & | getControlWeight () const |
control_matrix_t & | getControlWeight () |
void | setStateAndControlReference (const core::StateVector< STATE_DIM, SCALAR_EVAL > &x_ref, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u_ref) |
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. More... | |
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 More... | |
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 More... | |
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 More... | |
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 More... | |
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 More... | |
virtual void | loadConfigFile (const std::string &filename, const std::string &termName, bool verbose=false) override |
load this term from a configuration file More... | |
virtual void | updateReferenceState (const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > &newRefState) override |
updates the reference state for this term More... | |
virtual void | updateReferenceControl (const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, 1 > &newRefControl) override |
updates the reference control for this term More... | |
virtual Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > | getReferenceState () const override |
retrieve this term's current reference state More... | |
Public Member Functions inherited from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > | |
TermBase (std::string name="Unnamed") | |
Default constructor. More... | |
TermBase (const TermBase &arg) | |
Copy Cunstructor. More... | |
virtual | ~TermBase () |
Destructor. More... | |
SCALAR_EVAL | eval (const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > &x, const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, 1 > &u, const SCALAR_EVAL &t) |
Gets called by the analytical costfunction. Adds time dependent activations on top of the term. More... | |
virtual bool | isActiveAtTime (SCALAR_EVAL t) |
Returns if term is non-zero at a specific time By default, all terms are evaluated at all times. However, if a term is not active at a certain time, you can overload this function to spare evaluations of the term and its derivatives. More... | |
SCALAR_EVAL | computeActivation (SCALAR_EVAL t) |
compute time activation More... | |
void | setTimeActivation (std::shared_ptr< ct::core::tpl::ActivationBase< SCALAR_EVAL >> c_i, bool verbose=false) |
set the time activation functions for this term More... | |
void | loadTimeActivation (const std::string &filename, const std::string &termName, bool verbose=false) |
load the time activation functions for this term from file More... | |
const std::string & | getName () const |
Returns the name of the term. More... | |
void | setName (const std::string &termName) |
Sets the name of the term. More... | |
Public Attributes | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > | state_matrix_t |
Protected Member Functions | |
template<typename SC > | |
SC | evalLocal (const Eigen::Matrix< SC, STATE_DIM, 1 > &x, const Eigen::Matrix< SC, CONTROL_DIM, 1 > &u, const SC &t) |
Protected Attributes | |
state_matrix_t | Q_ |
control_matrix_t | R_ |
core::StateVector< STATE_DIM, SCALAR_EVAL > | x_ref_ |
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > | u_ref_ |
Protected Attributes inherited from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > | |
std::string | name_ |
a name identifier for this term More... | |
std::shared_ptr< ct::core::tpl::ActivationBase< SCALAR_EVAL > > | c_i_ |
time activations for this term More... | |
A basic quadratic term of type .
An example for using this term is given in CostFunctionTest.cpp
typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_matrix_t |
typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, STATE_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_state_matrix_t |
typedef Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::state_matrix_double_t |
typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_matrix_double_t |
typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, STATE_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_state_matrix_double_t |
ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic | ( | ) |
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
Referenced by ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::clone(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic().
ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic | ( | const state_matrix_t & | Q, |
const control_matrix_t & | R | ||
) |
ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic | ( | const state_matrix_t & | Q, |
const control_matrix_t & | R, | ||
const core::StateVector< STATE_DIM, SCALAR_EVAL > & | x_ref, | ||
const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > & | u_ref | ||
) |
ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic | ( | const std::string & | configFile, |
const std::string & | termName, | ||
bool | verbose = false |
||
) |
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::loadConfigFile(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic | ( | const TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > & | arg | ) |
|
virtual |
|
overridevirtual |
Deep-copy term.
Implements ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic().
void ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setWeights | ( | const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > & | Q, |
const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > & | R | ||
) |
const TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::state_matrix_t & ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getStateWeight | ( | ) | const |
TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::state_matrix_t & ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getStateWeight | ( | ) |
const TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_matrix_t & ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getControlWeight | ( | ) | const |
TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::control_matrix_t & ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getControlWeight | ( | ) |
void ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setStateAndControlReference | ( | const core::StateVector< STATE_DIM, SCALAR_EVAL > & | x_ref, |
const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > & | u_ref | ||
) |
|
overridevirtual |
Evaluates the term at x, u, t.
[in] | x | The current state |
[in] | u | The current control |
[in] | t | The current time |
Implements ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
|
overridevirtual |
compute derivative of this cost term w.r.t. the state
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
|
overridevirtual |
compute second order derivative of this cost term w.r.t. the state
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_.
Referenced by main().
|
overridevirtual |
compute derivative of this cost term w.r.t. the control input
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_.
|
overridevirtual |
compute second order derivative of this cost term w.r.t. the control input
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_.
Referenced by main().
|
overridevirtual |
compute the cross-term derivative (state-control) of this cost function term
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
|
overridevirtual |
load this term from a configuration file
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::loadMatrixCF(), ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::name_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
Referenced by main(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic().
|
overridevirtual |
updates the reference state for this term
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
|
overridevirtual |
updates the reference control for this term
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_.
|
overridevirtual |
retrieve this term's current reference state
Reimplemented from ct::optcon::TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >.
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
|
protected |
References ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::Q_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::R_, ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::u_ref_, and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::x_ref_.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM> ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::state_matrix_t |
|
protected |
Referenced by ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::evalLocal(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getStateWeight(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::loadConfigFile(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setWeights(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::stateDerivative(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::stateSecondDerivative(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic().
|
protected |
Referenced by ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::controlDerivative(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::controlSecondDerivative(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::evalLocal(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getControlWeight(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::loadConfigFile(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setWeights(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic().
|
protected |
Referenced by ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::evalLocal(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::getReferenceState(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::loadConfigFile(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setStateAndControlReference(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::stateDerivative(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::updateReferenceState().
|
protected |
Referenced by ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::controlDerivative(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::evalLocal(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::loadConfigFile(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::setStateAndControlReference(), ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::TermQuadratic(), and ct::optcon::TermQuadratic< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR >::updateReferenceControl().