- 3.0.2 models module.
HyQContactModelForwardZeroSystem.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 
9 #include <ct/core/systems/ControlledSystem.h>
10 #include <ct/rbd/rbd.h>
11 
14 
15 #include "HyQForwardZero.h"
16 
17 namespace ct {
18 namespace models {
19 namespace HyQ {
20 
26 {
27 public:
28  const static size_t STATE_DIM = 36;
29  const static size_t CONTROL_DIM = 12;
30 
33 
35 
37 
39  : Base(other), hyqForwardZero_(other.hyqForwardZero_){};
40 
42 
43  virtual HyQContactModelForwardZeroSystem* clone() const override
44  {
45  return new HyQContactModelForwardZeroSystem(*this);
46  }
47 
48  virtual void computePdot(const StateVector& x,
49  const core::StateVector<18>& v,
50  const ControlVector& control,
51  core::StateVector<18>& pDot) override
52  {
53  StateVector xLocal = x;
54  xLocal.tail(18) = v;
55  ct::rbd::RBDState<12> rbdCached = RBDStateFromVector(xLocal);
57  pDot = toStateDerivative(xd, rbdCached).head(18);
58  }
59 
60  virtual void computeVdot(const StateVector& x,
61  const core::StateVector<18>& p,
62  const ControlVector& control,
63  core::StateVector<18>& vDot) override
64  {
65  StateVector xLocal = x;
66  xLocal.head(18) = p;
67  Eigen::Matrix<double, STATE_DIM + CONTROL_DIM + 1, 1> xut;
68  xut << xLocal, control, 0.0;
69  vDot = hyqForwardZero_.forwardZero(xut).tail(18);
70  }
71 
72 
73 private:
74  HyQForwardZero hyqForwardZero_;
75 
76  StateVector toStateDerivative(const ct::rbd::RBDAcceleration<12>& acceleration, const ct::rbd::RBDState<12>& state)
77  {
78  return acceleration.toStateUpdateVectorEulerXyz(state);
79  }
80 
81  ct::rbd::RBDState<12> RBDStateFromVector(const StateVector& state)
82  {
84  x.fromStateVectorEulerXyz(state);
85  return x;
86  }
87 };
88 
89 } // namespace HyQ
90 
91 } // namespace models
92 } // namespace ct
virtual HyQContactModelForwardZeroSystem * clone() const override
Definition: HyQContactModelForwardZeroSystem.h:43
OUT_TYPE forwardZero(const Eigen::VectorXd &x_in) override
Definition: HyQForwardZero.cpp:12
static const size_t CONTROL_DIM
Definition: HyQContactModelForwardZeroSystem.h:29
A floating base rigid body system that uses forward dynamics. The input vector is assumed to consist ...
Definition: HyQContactModelForwardZeroSystem.h:25
virtual ~HyQContactModelForwardZeroSystem()
Definition: HyQContactModelForwardZeroSystem.h:41
virtual void computePdot(const StateVector &x, const core::StateVector< 18 > &v, const ControlVector &control, core::StateVector< 18 > &pDot) override
Definition: HyQContactModelForwardZeroSystem.h:48
core::SymplecticSystem< 18, 18, CONTROL_DIM > Base
Definition: HyQContactModelForwardZeroSystem.h:34
core::StateVector< STATE_DIM > StateVector
Definition: HyQContactModelForwardZeroSystem.h:31
ct::core::StateVector< state_dim > x
virtual void computeVdot(const StateVector &x, const core::StateVector< 18 > &p, const ControlVector &control, core::StateVector< 18 > &vDot) override
Definition: HyQContactModelForwardZeroSystem.h:60
static const size_t STATE_DIM
Definition: HyQContactModelForwardZeroSystem.h:28
void fromStateVectorEulerXyz(const state_vector_euler_t &state)
RBDState< NJOINTS, SCALAR >::state_vector_euler_t toStateUpdateVectorEulerXyz(const RBDState< NJOINTS, SCALAR > &state) const
HyQContactModelForwardZeroSystem(const HyQContactModelForwardZeroSystem &other)
Definition: HyQContactModelForwardZeroSystem.h:38
Definition: HyQForwardZero.h:14
HyQContactModelForwardZeroSystem()
Definition: HyQContactModelForwardZeroSystem.h:36
core::ControlVector< CONTROL_DIM > ControlVector
Definition: HyQContactModelForwardZeroSystem.h:32