- 3.0.2 optimal control module.
TermStateBarrier.hpp
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 #include "TermBase.hpp"
11 
12 namespace ct {
13 namespace optcon {
14 
25 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR_EVAL = double, typename SCALAR = SCALAR_EVAL>
26 class TermStateBarrier : public TermBase<STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR>
27 {
28 public:
29  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
30 
31  typedef Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1> state_vector_t;
32  typedef Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM> state_matrix_t;
33  typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM> control_matrix_t;
34  typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, STATE_DIM> control_state_matrix_t;
35  typedef Eigen::Matrix<SCALAR_EVAL, STATE_DIM, STATE_DIM> state_matrix_double_t;
36  typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM> control_matrix_double_t;
37  typedef Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, STATE_DIM> control_state_matrix_double_t;
38 
40 
41  TermStateBarrier(const state_vector_t& ub, const state_vector_t& lb, const state_vector_t& alpha);
42 
44 
45  virtual ~TermStateBarrier();
46 
48 
49  virtual SCALAR evaluate(const Eigen::Matrix<SCALAR, STATE_DIM, 1>& x,
50  const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>& u,
51  const SCALAR& t) override;
52 
53 #ifdef CPPADCG
54  virtual ct::core::ADCGScalar evaluateCppadCg(const core::StateVector<STATE_DIM, ct::core::ADCGScalar>& x,
56  ct::core::ADCGScalar t) override;
57 #endif
58 
60  virtual void loadConfigFile(const std::string& filename,
61  const std::string& termName,
62  bool verbose = false) override;
63 
64 protected:
65  void initialize();
66 
67  state_vector_t alpha_;
68  state_vector_t ub_;
69  state_vector_t lb_;
70 
71  std::vector<ct::core::tpl::BarrierActivation<SCALAR, ct::core::tpl::TraitSelector<SCALAR>>> barriers_;
72 };
73 
74 
75 } // namespace optcon
76 } // namespace ct
void initialize()
Definition: TermStateBarrier-impl.hpp:45
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_double_t
Definition: TermStateBarrier.hpp:36
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_double_t
Definition: TermStateBarrier.hpp:35
virtual ~TermStateBarrier()
Definition: TermStateBarrier-impl.hpp:33
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermStateBarrier.hpp:33
An interface for a term, supporting both analytical and auto-diff terms.
Definition: TermBase.hpp:30
state_vector_t ub_
Definition: TermStateBarrier.hpp:68
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > state_vector_t
Definition: TermStateBarrier.hpp:31
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: TermStateBarrier.hpp:34
CppAD::AD< CppAD::cg::CG< double > > SCALAR
A state barrier term (could also be considered a soft constraint) Note that this term explicitly excl...
Definition: TermStateBarrier.hpp:26
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
std::vector< ct::core::tpl::BarrierActivation< SCALAR, ct::core::tpl::TraitSelector< SCALAR > > > barriers_
Definition: TermStateBarrier.hpp:71
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_double_t
Definition: TermStateBarrier.hpp:37
state_vector_t alpha_
Definition: TermStateBarrier.hpp:67
TermStateBarrier< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * clone() const override
Deep-copy term.
Definition: TermStateBarrier-impl.hpp:39
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: TermStateBarrier-impl.hpp:55
TermStateBarrier()
Definition: TermStateBarrier-impl.hpp:20
state_vector_t lb_
Definition: TermStateBarrier.hpp:69
const bool verbose
Definition: ConstraintComparison.h:18
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermStateBarrier.hpp:32
virtual void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false) override
load the term from config file, where the bounds are stored as matrices
Definition: TermStateBarrier-impl.hpp:81