- 3.0.2 optimal control module.
ObstacleConstraint.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 
18 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
19 class ObstacleConstraint : public ConstraintBase<STATE_DIM, CONTROL_DIM, SCALAR>
20 {
21 public:
22  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23 
26 
29 
30  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> VectorXs;
31  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
32 
33  typedef Eigen::Matrix<SCALAR, 3, 1> Vector3s;
34 
35  ObstacleConstraint(std::shared_ptr<ct::core::tpl::Ellipsoid<SCALAR>> obstacle,
36  std::function<void(const state_vector_t&, Vector3s&)> getPosition,
37  std::function<void(const state_vector_t&, Eigen::Matrix<SCALAR, 3, STATE_DIM>&)> getJacobian);
38 
40 
41  virtual ~ObstacleConstraint();
42 
44 
45  virtual size_t getConstraintSize() const override;
46 
47  virtual Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> evaluate(const state_vector_t& x,
48  const control_vector_t& u,
49  const SCALAR t) override;
50 
51  virtual MatrixXs jacobianState(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
52 
53  virtual MatrixXs jacobianInput(const state_vector_t& x, const control_vector_t& u, const SCALAR t) override;
54 
55 private:
56  std::shared_ptr<ct::core::tpl::Ellipsoid<SCALAR>> obstacle_;
57 
58  std::function<void(const core::StateVector<STATE_DIM, SCALAR>&, Vector3s&)> xFun_;
59  std::function<void(const core::StateVector<STATE_DIM, SCALAR>&, Eigen::Matrix<SCALAR, 3, STATE_DIM>&)> dXFun_;
60 
62  Eigen::Matrix<SCALAR, 1, STATE_DIM> jac_;
63 };
64 
65 } // namespace optcon
66 } // namespace ct
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: ObstacleConstraint.h:30
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp: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: ObstacleConstraint-impl.h:63
Class for obstacle constraint.
Definition: ObstacleConstraint.h:19
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
core::ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: ObstacleConstraint.h:28
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual ~ObstacleConstraint()
Definition: ObstacleConstraint-impl.h:27
core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: ObstacleConstraint.h:27
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
virtual Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > 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: ObstacleConstraint-impl.h:50
ObstacleConstraint(std::shared_ptr< ct::core::tpl::Ellipsoid< SCALAR >> obstacle, std::function< void(const state_vector_t &, Vector3s &)> getPosition, std::function< void(const state_vector_t &, Eigen::Matrix< SCALAR, 3, STATE_DIM > &)> getJacobian)
Definition: ObstacleConstraint-impl.h:14
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ct::core::tpl::TraitSelector< SCALAR >::Trait Trait
Definition: ObstacleConstraint.h:24
virtual MatrixXs jacobianInput(const state_vector_t &x, const control_vector_t &u, const SCALAR t) override
Returns the constraint jacobian wrt input.
Definition: ObstacleConstraint-impl.h:79
Eigen::Matrix< SCALAR, 3, 1 > Vector3s
Definition: ObstacleConstraint.h:33
virtual size_t getConstraintSize() const override
The evaluate method used for jit compilation in constraint container ad.
Definition: ObstacleConstraint-impl.h:44
ConstraintBase< STATE_DIM, CONTROL_DIM, SCALAR > Base
Definition: ObstacleConstraint.h:25
virtual ObstacleConstraint< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
Creates a new instance of the object with same properties than original.
Definition: ObstacleConstraint-impl.h:32
Base class for the constraints used in this toolbox.
Definition: ConstraintBase.h:21
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: ObstacleConstraint.h:31