pinocchio  1.2.6-7-g6de3e-dirty
dc-linear-motor-model.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_motor_model_hpp_
21 #define _se3_motor_model_hpp_
22 
23 #include <iostream>
24 #include "pinocchio/macros.hpp"
25 #include "pinocchio/actuators/actuator-model.hpp"
26 
27 
28 namespace se3
29 {
123  template<typename Scalar_>
124  class ActuatorDCMotorData : ActuatorDataBase<ActuatorDCMotorData<Scalar_> >
125  {
126  public:
127  typedef Scalar_ Scalar_t;
128  typedef typename Eigen::Matrix<Scalar_, 13,1 > Parameters_t;
129  typedef typename Eigen::Matrix<Scalar_, 3,1> Observations_t;
130  typedef typename Eigen::Matrix<Scalar_, 6,1> S_t;
131  typedef typename Eigen::Matrix<Scalar_, 2,1> X_t;
132  typedef typename Eigen::Matrix<Scalar_, 2,1> dX_t;
133  typedef typename Eigen::Matrix<Scalar_, 1,1> U_t;
134 
135  enum InternalParameters
136  {
137  P_ROTOR_INERTIA=6,
138  P_ROTOR_RESISTOR,
139  P_TORQUE_CST,
140  P_SPEED_TORQUE_GRD,
141  P_BACK_EMF,
142  P_THONE_RESISTOR,
143  P_THTWO_RESISTOR,
144  P_TA_RESISTOR,
145  P_MAX_PERM_WINDING_T,
146  P_THERM_TIME_CST_WINDING
147  };
149  const Observations_t & h() const { return h_;}
150 
152  const Parameters_t & c() const { return c_;}
153 
155  const S_t & S() const { return S_;}
156 
159  void rotorInertia(Scalar_ c)
160  { c_[P_ROTOR_INERTIA] = c; updateParameters();}
161 
163  void rotorResistor(Scalar_ c)
164  { c_[P_ROTOR_RESISTOR] = c; updateParameters();}
165 
167  void torqueConst(Scalar_ c)
168  { c_[P_TORQUE_CST] = c; updateParameters();}
169 
171  void speedTorqueGrad(Scalar_ c)
172  {c_[P_SPEED_TORQUE_GRD] = c; updateParameters();}
173 
175  //void terminalInductance(Scalar_ &c)
176  // {c_[7] = c;}
177 
183  void backEMF(Scalar_ c)
184  {c_[P_BACK_EMF] = c;updateParameters();}
185 
188  void resistorOne(Scalar_ c)
189  {c_[P_THONE_RESISTOR] = c;updateParameters();}
190 
193  void resistorTwo(Scalar_ c)
194  {c_[P_THTWO_RESISTOR] = c;updateParameters();}
195 
198  void resistorTA(Scalar_ c)
199  {c_[P_TA_RESISTOR] = c;updateParameters();}
200 
205  {c_[P_MAX_PERM_WINDING_T] = c;updateParameters();}
206 
209  void thermTimeCstWinding(Scalar_ c)
210  {c_[P_THERM_TIME_CST_WINDING] = c; updateParameters();}
211 
212  void setS(S_t &S)
213  {S_ = S;}
215 
219  Scalar_ getMaxPermissibleOverloadForONTime(Scalar_ aDuration)
220  {
221  return sqrt(1/(1-exp(-aDuration/c_[P_THERM_TIME_CST_WINDING])));
222  }
223 
227  Scalar_ getOverloadForCurrent(Scalar_ aCurrent, Scalar_ TS)
228  {
229  return aCurrant/c_[P_NOMINAL_CURRENT]*sqrt((c_[P_MAX_PERM_WINDING_T]- 25)/(c_[P_MAX_PERM_WINDING_T] - TS) *
230  (c_[P_THONE_RESISTOR]/(c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR])));
231  }
232 
236  Scalar_ getMaxONTimeForK(Scalar_ aK)
237  {
238  return c_[P_THERM_TIME_CST_WINDING] * log(aK*aK/(aK*aK-1.0));
239  }
240 
244  Scalar_ getMaxCurrentForK(Scalar_ aK)
245  {
246  return aK * c_[P_NOMINAL_CURRENT]*sqrt((c_[P_MAX_PERM_WINDING_T] - TS)/(c_[P_MAX_PERM_WINDING_T]- 25) *
247  (c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR])/(c_[P_THONE_RESISTOR]));
248  }
249 
250  Observations_t & h() { return h_;}
251 
252  protected:
255  {
256  // c_1 = torque_cst / (rotorInertia * rotorResistor)
257  c_[0] = c_[P_TORQUE_CST] /(c_[P_ROTOR_INERTIA] * c_[P_ROTOR_RESISTOR]);
258  // c_2 = - torque_cst * back_emf_cst / (rotorInertia * rotorResistor)
259  // - speedTorqueGrad^{-1} / rotorInertia
260  c_[1] = -c_[P_TORQUE_CST]*c_[P_BACK_EMF] /(c_[P_ROTOR_INERTIA] * c_[P_ROTOR_RESISTOR])
261  - c_[P_SPEED_TORQUE_GRD]/c_[P_ROTOR_INERTIA];
262  // c_3 = -1/rotorInertia
263  c_[2] = -1/c_[P_ROTOR_INERTIA];
264  }
265 
267  Observations_t h_;
268 
270  Parameters_t c_;
271 
273  S_t S_;
274 
275  };
276 
283  template< typename Scalar_>
284  class ActuatorDCMotorModel : ActuatorModelBase<ActuatorDCMotorModel<Scalar_> >
285  {
286 
287  typedef Eigen::Matrix<Scalar_,3,1,0> Vector3Scalar;
288 
289  public:
291 
292  void calc(typename ActuatorDCMotorData<Scalar_>::dX_t & dstate,
293  typename ActuatorDCMotorData<Scalar_>::X_t & state,
294  typename ActuatorDCMotorData<Scalar_>::U_t & control,
295  Force & fext,
297  {
298  // Update dstate
299  dstate[0] = state[1];
300  dstate[1] = data.c()[0] * control[0] + data.c()[1] * state[0] +
301  data.c()[2] *data.S().dot(fext.toVector());
302 
303  // Update observation
304  // Current
305  data.h()[0] = control[0] /data.c()[P_ROTOR_RESISTOR]
306  - data.c()[P_BACK_EMF] *state[1]/data.c()[P_ROTOR_RESISTOR];
307  // Motor torque
308  data.h()[1] = data.c()[P_TORQUE_CST] *data.h()[0];
309  // Back emf potential
310  data.h()[2] = data.c()[P_BACK_EMF] * state[1];
311  }
312 
313 
314  void get_force(ActuatorDCMotorData<Scalar_> &data, Force &aForce) const
315  {
316  aForce.linear(Vector3Scalar::Zero(3,1));
317  aForce.angular(Vector3Scalar(0.0,0.0,data.h()[1]));
318  }
319 
320  ActuatorDCMotorData<Scalar_> createData() const
321  { return ActuatorDCMotorData<Scalar_>(); };
322 
323  protected:
324 
325  // Store actuator name.
326  std::string name_;
327 
328  };
329 
330  template <typename Scalar_>
331  struct adb_traits<ActuatorDCMotorData<Scalar_> >
332  {
334  };
335 
336  template <typename Scalar_>
338  {
341  };
342 
343 
344 } // end of namespace se3
345 
346 #endif /* _se3_motor_model_ */
void thermTimeCstWinding(Scalar_ c)
Therm. time constant winding units: seconds (s)
void resistorOne(Scalar_ c)
Gearhead thermal resistance at ambient temperature units: K/W.
Scalar_ getMaxPermissibleOverloadForONTime(Scalar_ aDuration)
Returns the maximum overload possible for a given duration. Implements .
const Parameters_t & c() const
Return parameters.
Concreate Class representing a force.
Definition: force.hpp:243
void backEMF(Scalar_ c)
Terminal Inductance (Henry)
void rotorInertia(Scalar_ c)
Rotor inertia (kg/m2) - .
const Vector6 & toVector() const
Return the force.
Definition: force.hpp:102
void updateParameters()
Update the first three parameters of the actuators:
ConstAngular_t angular() const
Return the angular part of the force vector.
Definition: force.hpp:64
void rotorResistor(Scalar_ c)
Rotor resistor (Ohm) - .
void torqueConst(Scalar_ c)
Torque constant (Nm/A) - .
Parameters_t c_
Vector parameters.
Scalar_ getMaxCurrentForK(Scalar_ aK)
Returns the maximum current at a given overload factor . Implements .
Template for handling data related to a second order linear DC motor model.
void resistorTA(Scalar_ c)
Winding resistance at ambient temperature units: Ohms.
Template which implements a second order linear DC motor model.
void maxPermissibleWindingTemp(Scalar_ c)
Max. permissible winding temperature catalog value units: C.
void resistorTwo(Scalar_ c)
Winding thermal resistance at ambient temperature units: K/W.
Observations_t h_
Observation variables.
Scalar_ getMaxONTimeForK(Scalar_ aK)
Returns the maximum ON time at a given overload factor K Implements .
void speedTorqueGrad(Scalar_ c)
Speed torque gradient (rads^-1/Nm) .
ConstLinear_t linear() const
Return the linear part of the force vector.
Definition: force.hpp:71
const S_t & S() const
Returns selection matrix.
Scalar_ getOverloadForCurrent(Scalar_ aCurrent, Scalar_ TS)
Returns the overload for a given motor current and the current stator temperature ( ) Implements ...
const Observations_t & h() const
Return observation vector.