pinocchio  1.2.6-7-g6de3e-dirty
pneumatic-two-chambers.hpp
1 //
2 // Copyright (c) 2017 LAAS CNRS
3 //
4 // Author: Olivier Stasse
5 //
6 // This file is part of Pinocchio
7 // Pinocchio is free software: you can redistribute it
8 // and/or modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation, either version
10 // 3 of the License, or (at your option) any later version.
11 //
12 // Pinocchio is distributed in the hope that it will be
13 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Lesser Public License for more details. You should have
16 // received a copy of the GNU Lesser General Public License along with
17 // Pinocchio If not, see
18 // <http://www.gnu.org/licenses/>.
19 
20 #ifndef _se3_pneumatic_two_chambers_hpp_
21 #define _se3_pneumatic_two_chambers_hpp_
22 
23 #include <iostream>
24 #include "pinocchio/macros.hpp"
25 #include "pinocchio/actuators/actuator-model.hpp"
26 
27 
28 namespace se3
29 {
41  template<typename Scalar_>
43  ActuatorDataBase< PneumaticTwoChambersData<Scalar_> >
44  {
45  public:
46  typedef Scalar_ Scalar_t;
47  typedef typename Eigen::Matrix<Scalar_, 12,1 > Parameters_t;
48  typedef typename Eigen::Matrix<Scalar_, 3,1> Observations_t;
49  typedef typename Eigen::Matrix<Scalar_, 6,1> S_t;
50  typedef typename Eigen::Matrix<Scalar_, 1,1> X_t;
51  typedef typename Eigen::Matrix<Scalar_, 1,1> dX_t;
52  typedef typename Eigen::Matrix<Scalar_, 1,1> U_t;
53 
55  const Observations_t & h() const { return h_;}
56 
58  const Parameters_t & c() const { return c_;}
59 
61  const S_t & S() const { return S_;}
62 
63  enum InternalParameters
64  {
65  P_VALVE_VOLTAGE_ORIGIN,
66  P_VALVE_VOLTAGE_SCALE,
67  P_KINK_FACTOR,
68  P_DS_DDV,
69  P_DR_DDV,
70  P_VOLUME_SENSOR_SCALE,
71  P_B_EQ,
72  P_RATE_ASSYMMETRY,
73  P_LEAKAGE,
74  P_PRESSURE_SENSOR_BIAS,
75  P_PRESSURE_SENSOR_SCALE,
76  P_VOLTAGE_RANGE_OF_LEAKY_REGIME
77  };
78 
81  void valveVoltageOrigin(Scalar_ c)
82  { c_[P_VALVE_VOLTAGE_ORIGIN] = c;}
83 
85  void valveVoltageScale(Scalar_ c)
86  { c_[P_VALVE_VOLTAGE_SCALE]=c;}
87 
89  void kinkFactor(Scalar_ c)
90  { c_[P_KINK_FACTOR]=c;}
91 
93  void pDsDdv(Scalar_ c)
94  {c_[P_DS_DDV] = c;}
95 
97  void pDrDdv(Scalar_ c)
98  {c_[P_DR_DDV] = c;}
99 
101  void pBeq(Scalar_ c)
102  {c_[P_B_EQ] = c;}
103 
105  void pRateAssymmetry(Scalar_ c)
106  {c[P_RATE_ASSYMMETRY] = c;}
107 
109  void pLeakage(Scalar_ c)
110  {c[P_LEAKAGE] = c;}
111 
113  void pPressureSensorBias(Scalar_ c)
114  {c[P_PRESSURE_SENSOR_BIAS] = c;}
115 
117  void pPressureSensorScale(Scalar_ c)
118  {c[P_PRESSURE_SENSOR_SCALE] = c;}
119 
120  // \brief Voltage Range of leaky regime
121  void pVoltageRangeOfLeakyRegime(Scalar_ c)
122  {c[P_VOLTAGE_RANGE_OF_LEAKY_REGIME] = c; }
123 
124  void setS(S_t &S)
125  {S_ = S;}
127 
128  Observations_t & h() { return h_;}
129 
130  protected:
131 
133  Observations_t h_;
134 
136  Parameters_t c_;
137 
139  S_t S_;
140 
141  };
142 
149  template< typename Scalar_>
151  ActuatorModelBase< PneumaticTwoChambersModel <Scalar_> >
152  {
153 
154  typedef Eigen::Matrix<Scalar_,3,1,0> Vector3Scalar;
155 
156  public:
158 
159  void ode_func(typename ActuatorDCMotorData<Scalar_>::dX_t & dstate,
160  typename ActuatorDCMotorData<Scalar_>::X_t & state,
161  typename ActuatorDCMotorData<Scalar_>::U_t & control,
162  Force & fext,
164  {
165  // Update dstate
166 
167  // Update observation
168  // Current
169  data.h()[0] = control[0] /data.c()[4] - data.c()[7] *state[1]/data.c()[4];
170  // Motor torque
171  data.h()[1] = data.c()[5] *data.h()[0];
172  // Back emf potential
173  data.h()[2] = data.c()[7] * state[1];
174  }
175 
176 
177  void get_force(ActuatorDCMotorData<Scalar_> &data, Force &aForce) const
178  {
179  aForce.linear(Vector3Scalar::Zero(3,1));
180  aForce.angular(Vector3Scalar(0.0,0.0,data.h()[1]));
181  }
182 
183  ActuatorDCMotorData<Scalar_> createData() const
184  { return ActuatorDCMotorData<Scalar_>(); };
185 
186  protected:
187 
188  // Store actuator name.
189  std::string name_;
190 
191  };
192 
193  template <typename Scalar_>
194  struct adb_traits<ActuatorDCMotorData<Scalar_> >
195  {
196  typedef ActuatorDCMotorData<Scalar_> ActuatorDataDerived;
197  };
198 
199  template <typename Scalar_>
200  struct amb_traits<ActuatorDCMotorModel<Scalar_> >
201  {
202  typedef ActuatorDCMotorModel<Scalar_> ActuatorModelDerived;
203  typedef ActuatorDCMotorData<Scalar_> ActuatorDataDerived;
204  };
205 
206 
207 } // end of namespace se3
208 
209 #endif /* _se3_motor_model_ */
Template for handling data related to a second order linear DC motor model.
const S_t & S() const
Returns selection matrix.
void pRateAssymmetry(Scalar_ c)
Rate assymmetry.
const Observations_t & h() const
Return observation vector.
void valveVoltageOrigin(Scalar_ c)
Valve-voltage origin.
const Parameters_t & c() const
Return parameters.
Concreate Class representing a force.
Definition: force.hpp:243
Template which implements a second order linear DC motor model.
void kinkFactor(Scalar_ c)
Kink Factor.
ConstAngular_t angular() const
Return the angular part of the force vector.
Definition: force.hpp:64
void valveVoltageScale(Scalar_ c)
Valve Voltage scale.
Template for handling data related to a second order linear DC motor model.
Template which implements a second order linear DC motor model.
void pPressureSensorBias(Scalar_ c)
Pressure sensor bias.
Observations_t h_
Observation variables.
const Parameters_t & c() const
Return parameters.
void pPressureSensorScale(Scalar_ c)
Pressure sensor scale.
Parameters_t c_
Vector parameters.
ConstLinear_t linear() const
Return the linear part of the force vector.
Definition: force.hpp:71
const Observations_t & h() const
Return observation vector.