pinocchio  1.2.6-7-g6de3e-dirty
dc-temp-non-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_temp_non_linear_motor_model_hpp_
21 #define _se3_temp_non_linear_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 {
141  template<typename Scalar_>
142  class ActuatorDCTempNonLinearMotorData : ActuatorDataBase<ActuatorDCTempNonLinearMotorData<Scalar_> >
143  {
144  public:
145  typedef Scalar_ Scalar_t;
146  typedef typename Eigen::Matrix<Scalar_, 13,1 > Parameters_t;
147  typedef typename Eigen::Matrix<Scalar_, 3,1> Observations_t;
148  typedef typename Eigen::Matrix<Scalar_, 6,1> S_t;
149  typedef typename Eigen::Matrix<Scalar_, 2,1> X_t;
150  typedef typename Eigen::Matrix<Scalar_, 2,1> dX_t;
151  typedef typename Eigen::Matrix<Scalar_, 1,1> U_t;
152 
153  enum InternalParameters
154  {
155  P_ROTOR_INERTIA=6,
156  P_TORQUE_CST,
157  P_SPEED_TORQUE_GRD,
158  P_BACK_EMF,
159  P_THONE_RESISTOR,
160  P_THTWO_RESISTOR,
161  P_TA_RESISTOR,
162  P_MAX_PERM_WINDING_T,
163  P_THERM_TIME_CST_WINDING,
164  P_AMBIANT_TEMP
165  };
167  const Observations_t & h() const { return h_;}
168 
170  const Parameters_t & c() const { return c_;}
171 
173  const S_t & S() const { return S_;}
174 
177  void rotorInertia(Scalar_ c)
178  { c_[P_ROTOR_INERTIA] = c; updateParameters();}
179 
180 
182  void torqueConst(Scalar_ c)
183  { c_[P_TORQUE_CST] = c; updateParameters();}
184 
186  void speedTorqueGrad(Scalar_ c)
187  {c_[P_SPEED_TORQUE_GRD] = c; updateParameters();}
188 
190  //void terminalInductance(Scalar_ &c)
191  // {c_[7] = c;}
192 
198  void backEMF(Scalar_ c)
199  {c_[P_BACK_EMF] = c;updateParameters();}
200 
203  void resistorOne(Scalar_ c)
204  {c_[P_THONE_RESISTOR] = c;updateParameters();}
205 
208  void resistorTwo(Scalar_ c)
209  {c_[P_THTWO_RESISTOR] = c;updateParameters();}
210 
213  void resistorTA(Scalar_ c)
214  {c_[P_TA_RESISTOR] = c;updateParameters();}
215 
220  {c_[P_MAX_PERM_WINDING_T] = c;updateParameters();}
221 
224  void thermTimeCstWinding(Scalar_ c)
225  {c_[P_THERM_TIME_CST_WINDING] = c; updateParameters();}
226 
229  void thermAmbient(Scalar_ c)
230  {c_[P_AMBIENT_TEMP] = c; updateParameters();}
231 
232  void setS(S_t &S)
233  {S_ = S;}
235 
239  Scalar_ getMaxPermissibleOverloadForONTime(Scalar_ aDuration)
240  {
241  return sqrt(1/(1-exp(-aDuration/c_[P_THERM_TIME_CST_WINDING])));
242  }
243 
247  Scalar_ getOverloadForCurrent(Scalar_ aCurrent, Scalar_ TS)
248  {
249  return aCurrent/c_[P_NOMINAL_CURRENT]*sqrt((c_[P_MAX_PERM_WINDING_T]- c_[P_AMBIENT_TEMP)/(c_[P_MAX_PERM_WINDING_T] - TS) *
250  (c_[P_THONE_RESISTOR]/(c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR])));
251  }
252 
256  Scalar_ getMaxONTimeForK(Scalar_ aK)
257  {
258  return c_[P_THERM_TIME_CST_WINDING] * log(aK*aK/(aK*aK-1.0));
259  }
260 
264  Scalar_ getMaxCurrentForK(Scalar_ aK)
265  {
266  return aK * c_[P_NOMINAL_CURRENT]*sqrt((c_[P_MAX_PERM_WINDING_T] - TS)/(c_[P_MAX_PERM_WINDING_T]- c_[P_AMBIENT_TEMP]) *
267  (c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR])/(c_[P_THONE_RESISTOR]));
268  }
269 
270  Observations_t & h() { return h_;}
271 
272  protected:
275  {
276  // c_1 = torque_cst
277  c_[0] = c_[P_TORQUE_CST];
278 
279  // c_2 = B_m R_{TA} (1+T_A \alpha_{Cu} )
280  c_[1] = c_[P_ROTOR_INERTIA] * c_[P_TA_RESISTOR])*(1+ c_[P_AMBIENT_TEMP] * alpha_cu);
281 
282  // c_3 = -B_m R_{TA} \alpha_{Cu}
283  c_[2] = -c_[P_ROTOR_INERTIA] * c_[P_TA_RESISTOR] * alpha_cu_;
284 
285  // c_4 = K_B + D_m R_{TA} + D_m R_{TA} \alpha_{Cu} T_{A}
286  c_[3] = c_[P_BACK_EMF] + c_[P_SPEED_TORQUE_GRD]*c_[P_TA_RESISTOR] (1+alpha_cu_ * c_[P_AMBIENT_TEMP]);
287 
288  // c_5 = -D_m R_{TA} \alpha_{Cu}
289  c_[4] = -c_[P_SPEED_TORQUE_GRD] * c_[P_TA_RESISTOR] * alpha_cu_;
290 
291  // c_6 = -frac{1}{B_m}
292  c_[5] = -1/c_[P_ROTOR_INERTIA];
293 
294  // c_7 = (R_{th1} + R_{th2})
295  c_[6] = c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR];
296 
297  // c_8 = -K_b
298  c_[7] = -c_[P_BACK_EMF];
299 
301  c_[8] = c_[P_TA_RESISTOR] - alpha_cu_ * c_[P_AMBIENT_TEMP] * c_[P_TA_RESISTOR];
302 
303  // \f$ c_{10} = \alpha_{Cu} R_{TA} \f$
304  c_[9] = alpha_cu_ *c_[P_TA_RESISTOR];
305 
306  // \f$ c_{11} = -\alpha_{Cu} (R_{th1} + R_{th2}) \f$
307  c_[10] = alpha_cu_ * (c_[P_THONE_RESISTOR] + c_[P_THTWO_RESISTOR]);
308 
309  }
310 
312  Observations_t h_;
313 
315  Parameters_t c_;
316 
318  S_t S_;
319 
321  double alpha_cu_;
322 
323  };
324 
331  template< typename Scalar_>
332  class ActuatorDCTempNonLinearMotorModel : ActuatorModelBase<ActuatorDCTempNonLinearMotorModel<Scalar_> >
333  {
334 
335  typedef Eigen::Matrix<Scalar_,3,1,0> Vector3Scalar;
336 
337  public:
339 
340  void calc(typename ActuatorDCTempNonLinearMotorData<Scalar_>::dX_t & dstate,
341  typename ActuatorDCTempNonLinearMotorData<Scalar_>::X_t & state,
342  typename ActuatorDCTempNonLinearMotorData<Scalar_>::U_t & control,
343  Force & fext,
345  {
346  // Update dstate
347  dstate[0] = state[1];
348  dstate[1] = data.c()[0]/(data.c()[1] + data.c()[2]*state[2]) * control[0] +
349  state[1]*(data.c()[3]+data.c()[4]*state[2])/(data.c()[1] + data.c()[2]*state[2])
350  + data.c()[5] *data.S().dot(fext.toVector());
351  dstate[2] =
352 
353  // Update observation
354  // Current
355  data.h()[0] = control[0] /data.c()[P_ROTOR_RESISTOR]
356  - data.c()[P_BACK_EMF] *state[1]/data.c()[P_ROTOR_RESISTOR];
357  // Motor torque
358  data.h()[1] = data.c()[P_TORQUE_CST] *data.h()[0];
359  // Back emf potential
360  data.h()[2] = data.c()[P_BACK_EMF] * state[1];
361  }
362 
363 
364  void get_force(ActuatorDCTempNonLinearMotorData<Scalar_> &data, Force &aForce) const
365  {
366  aForce.linear(Vector3Scalar::Zero(3,1));
367  aForce.angular(Vector3Scalar(0.0,0.0,data.h()[1]));
368  }
369 
372 
373  protected:
374 
375  // Store actuator name.
376  std::string name_;
377 
378  };
379 
380  template <typename Scalar_>
382  {
384  };
385 
386  template <typename Scalar_>
388  {
391  };
392 
393 
394 } // end of namespace se3
395 
396 #endif /* _se3_temp_non_linear_motor_model_ */
const Observations_t & h() const
Return observation vector.
const Parameters_t & c() const
Return parameters.
void updateParameters()
Update the first three parameters of the actuators:
Template which implements a second order linear DC motor model.
Scalar_ getMaxPermissibleOverloadForONTime(Scalar_ aDuration)
Returns the maximum overload possible for a given duration. Implements .
Concreate Class representing a force.
Definition: force.hpp:243
void speedTorqueGrad(Scalar_ c)
Speed torque gradient (rads^-1/Nm) .
Scalar_ getMaxONTimeForK(Scalar_ aK)
Returns the maximum ON time at a given overload factor K Implements .
const Vector6 & toVector() const
Return the force.
Definition: force.hpp:102
void maxPermissibleWindingTemp(Scalar_ c)
Max. permissible winding temperature catalog value units: C.
void backEMF(Scalar_ c)
Terminal Inductance (Henry)
void thermAmbient(Scalar_ c)
Ambient temperature for the motor characteristics. Typically .
ConstAngular_t angular() const
Return the angular part of the force vector.
Definition: force.hpp:64
void torqueConst(Scalar_ c)
Torque constant (Nm/A) - .
void resistorOne(Scalar_ c)
Gearhead thermal resistance at ambient temperature units: K/W.
const S_t & S() const
Returns selection matrix.
void thermTimeCstWinding(Scalar_ c)
Therm. time constant winding units: seconds (s)
void rotorInertia(Scalar_ c)
Rotor inertia (kg/m2) - .
void resistorTwo(Scalar_ c)
Winding thermal resistance at ambient temperature units: K/W.
void resistorTA(Scalar_ c)
Winding resistance at ambient temperature units: Ohms.
ConstLinear_t linear() const
Return the linear part of the force vector.
Definition: force.hpp:71
Scalar_ getOverloadForCurrent(Scalar_ aCurrent, Scalar_ TS)
Returns the overload for a given motor current and the current stator temperature ( ) Implements ...
Template for handling data related to a second order linear DC motor model.
Scalar_ getMaxCurrentForK(Scalar_ aK)
Returns the maximum current at a given overload factor . Implements .