- 3.0.2 optimal control module.
StateSumConstraint.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 
16 {
17 public:
18  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
24 
25  typedef Eigen::Matrix<double, 1, 2> Jacobian_state_t;
26  typedef Eigen::Matrix<double, 1, 1> Jacobian_control_t;
27 
29  StateSumConstraint(double lb, double ub) : lb_(lb), ub_(ub)
30  {
31  Base::lb_.resize(1);
32  Base::ub_.resize(1);
33  Base::lb_.setConstant(lb);
34  Base::ub_.setConstant(ub);
35  }
36 
37  virtual ~StateSumConstraint() {}
38  virtual StateSumConstraint* clone() const override { return new StateSumConstraint(lb_, ub_); }
39  virtual size_t getConstraintSize() const override { return 1; }
40  virtual Eigen::VectorXd evaluate(const state_vector_t& x, const control_vector_t& u, const double t) override
41  {
42  Eigen::Matrix<double, 1, 1> val;
43  val.template segment<1>(0) << x(0) + x(1);
44  return val;
45  }
46 
47  virtual Eigen::Matrix<ct::core::ADCGScalar, Eigen::Dynamic, 1> evaluateCppadCg(
50  ct::core::ADCGScalar t) override
51  {
52  Eigen::Matrix<ct::core::ADCGScalar, 1, 1> val;
53  val.template segment<1>(0) << x(0) + x(1);
54  return val;
55  }
56 
57 private:
58  double lb_;
59  double ub_;
60 };
virtual Eigen::Matrix< ct::core::ADCGScalar, Eigen::Dynamic, 1 > evaluateCppadCg(const ct::core::StateVector< 2, ct::core::ADCGScalar > &x, const ct::core::ControlVector< 1, ct::core::ADCGScalar > &u, ct::core::ADCGScalar t) override
Definition: StateSumConstraint.h:47
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
ct::core::StateVector< 2 > state_vector_t
Definition: StateSumConstraint.h:22
virtual StateSumConstraint * clone() const override
Creates a new instance of the object with same properties than original.
Definition: StateSumConstraint.h:38
ct::optcon::ConstraintBase< 2, 1 > Base
Definition: StateSumConstraint.h:21
Eigen::Matrix< double, 1, 1 > Jacobian_control_t
Definition: StateSumConstraint.h:26
virtual Eigen::VectorXd evaluate(const state_vector_t &x, const control_vector_t &u, const double t) override
Definition: StateSumConstraint.h:40
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ct::core::tpl::TraitSelector< double >::Trait Trait
Definition: StateSumConstraint.h:19
Eigen::Matrix< double, 1, 2 > Jacobian_state_t
Definition: StateSumConstraint.h:25
StateSumConstraint(double lb, double ub)
constructor with constraint boundaries.
Definition: StateSumConstraint.h:29
ct::core::tpl::TraitSelector< ct::core::ADCGScalar >::Trait TraitCG
Definition: StateSumConstraint.h:20
virtual size_t getConstraintSize() const override
The evaluate method used for jit compilation in constraint container ad.
Definition: StateSumConstraint.h:39
VectorXs ub_
lower bound on the constraints
Definition: ConstraintBase.h:203
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
A simple 1d constraint term.
Definition: StateSumConstraint.h:15
virtual ~StateSumConstraint()
Definition: StateSumConstraint.h:37
ct::core::ControlVector< 1 > control_vector_t
Definition: StateSumConstraint.h:23
VectorXs lb_
Definition: ConstraintBase.h:202
Base class for the constraints used in this toolbox.
Definition: ConstraintBase.h:21