- 3.0.2 optimal control module.
TerminalConstraint.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace optcon {
10 
20 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
21 class TerminalConstraint : public ConstraintBase<STATE_DIM, CONTROL_DIM, SCALAR>
22 {
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
30 
31  typedef Eigen::Matrix<int, Eigen::Dynamic, 1> VectorXi;
32  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> VectorXs;
33  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
34 
41 
43 
45 
46  virtual ~TerminalConstraint();
47 
48  virtual size_t getConstraintSize() const override;
49 
50  virtual VectorXs evaluate(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
51 
52 #ifdef CPPADCG
53  virtual Eigen::Matrix<ct::core::ADCGScalar, Eigen::Dynamic, 1> evaluateCppadCg(
56  ct::core::ADCGScalar t) override;
57 #endif
58 
59  virtual MatrixXs jacobianState(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
60 
61  virtual MatrixXs jacobianInput(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
62 
63  virtual size_t getNumNonZerosJacobianState() const override;
64 
65  virtual size_t getNumNonZerosJacobianInput() const override;
66 
67  virtual VectorXs jacobianStateSparse(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
68 
69  virtual void sparsityPatternState(VectorXi& rows, VectorXi& cols) override;
70 
71 private:
73 };
74 }
75 }
virtual MatrixXs jacobianInput(const state_vector_t &x, const control_vector_t &u, const SCALAR t) override
Returns the constraint jacobian wrt input.
Definition: TerminalConstraint-impl.h:77
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
virtual size_t getConstraintSize() const override
The evaluate method used for jit compilation in constraint container ad.
Definition: TerminalConstraint-impl.h:40
virtual TerminalConstraint< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
Creates a new instance of the object with same properties than original.
Definition: TerminalConstraint-impl.h:23
core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: TerminalConstraint.h:28
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
core::ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: TerminalConstraint.h:29
virtual ~TerminalConstraint()
Definition: TerminalConstraint-impl.h:35
virtual void sparsityPatternState(VectorXi &rows, VectorXi &cols) override
Definition: TerminalConstraint-impl.h:106
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: TerminalConstraint.h:33
ConstraintBase< STATE_DIM, CONTROL_DIM, SCALAR > Base
Definition: TerminalConstraint.h:27
Eigen::Matrix< int, Eigen::Dynamic, 1 > VectorXi
Definition: TerminalConstraint.h:31
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
virtual VectorXs evaluate(const state_vector_t &x, const control_vector_t &u, const SCALAR t) override
The evaluation of the constraint violation. Note this method is SCALAR typed.
Definition: TerminalConstraint-impl.h:47
virtual size_t getNumNonZerosJacobianInput() const override
Returns the number of nonzeros in the jacobian wrt control input. The default implementation assumes ...
Definition: TerminalConstraint-impl.h:91
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ct::core::tpl::TraitSelector< SCALAR >::Trait Trait
Definition: TerminalConstraint.h:26
virtual VectorXs jacobianStateSparse(const state_vector_t &x, const control_vector_t &u, const SCALAR t) override
Returns the constraint jacobian wrt state in sparse structure. The default implementation maps the Ja...
Definition: TerminalConstraint-impl.h:98
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: TerminalConstraint.h:32
virtual size_t getNumNonZerosJacobianState() const override
Returns the number of nonzeros in the jacobian wrt state. The default implementation assumes a dense ...
Definition: TerminalConstraint-impl.h:85
TerminalConstraint(const core::StateVector< STATE_DIM, SCALAR > xf)
Custom constructor.
Definition: TerminalConstraint-impl.h:12
Base class for the constraints used in this toolbox.
Definition: ConstraintBase.h:21
virtual MatrixXs jacobianState(const state_vector_t &x, const control_vector_t &u, const SCALAR t) override
Returns the constraint jacobian wrt state.
Definition: TerminalConstraint-impl.h:68
Class for terminal constraint.
Definition: TerminalConstraint.h:21