pinocchio  1.2.6-7-g6de3e-dirty
dc-linear-first-order-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_dc_linear_first_order_motor_model_hpp_
21 #define _se3_dc_linear_first_order_motor_model_hpp_
22 
23 
24 #include "pinocchio/macros.hpp"
25 #include "pinocchio/actuators/actuator-model.hpp"
26 
27 
28 namespace se3
29 {
117  template<typename Scalar_>
118  class ActuatorDCFirstOrderMotorData : ActuatorDataBase<ActuatorDCFirstOrderMotorData<Scalar_> >
119  {
120  public:
121  typedef Scalar_ Scalar_t;
122  typedef typename Eigen::Matrix<Scalar_, 10,1 > Parameters_t;
123  typedef typename Eigen::Matrix<Scalar_, 3,1> Observations_t;
124  typedef typename Eigen::Matrix<Scalar_, 6,1> S_t;
125  typedef typename Eigen::Matrix<Scalar_, 2,1> X_t;
126  typedef typename Eigen::Matrix<Scalar_, 2,1> dX_t;
127  typedef typename Eigen::Matrix<Scalar_, 1,1> U_t;
128 
130  const Observations_t & h() const { return h_;}
131 
133  const Parameters_t & c() const { return c_;}
134 
136  const S_t & S() const { return S_;}
137 
140  void rotorInertia(Scalar_ c)
141  { c_[3] = c; updateFirstThreeParameters();}
142 
144  void rotorResistor(Scalar_ c)
145  { c_[4] = c; updateFirstThreeParameters();}
146 
148  void torqueConst(Scalar_ c)
149  { c_[5] = c; updateFirstThreeParameters();}
150 
152  void speedTorqueGrad(Scalar_ c)
153  {c_[6] = 1/c; updateFirstThreeParameters();}
154 
156  //void terminalInductance(Scalar_ &c)
157  // {c_[7] = c;}
158 
164  void backEMF(Scalar_ c)
165  {c_[7] = c;}
166 
167  void setS(S_t &S)
168  {S_ = S;}
170 
171  Observations_t & h() { return h_;}
172 
173  protected:
176  {
177  // c_1 = torque_cst / (rotorInertia * rotorResistor)
178  c_[0] = c_[5] /(c_[3] * c_[4]);
179  // c_2 = - back_emf_cst / (rotorInertia * rotorResistor)
180  // - speedTorqueGrad^{-1} / rotorInertia
181  c_[1] = -c_[5]*c_[7] /(c_[5] + c_[3]*c_[6] ) ;
182  }
183 
185  Observations_t h_;
186 
188  Parameters_t c_;
189 
191  S_t S_;
192 
194  X_t x_;
195  };
196 
203  template< typename Scalar_>
205  ActuatorModelBase<ActuatorDCFirstOrderMotorModel<Scalar_> >
206  {
207 
208  typedef Eigen::Matrix<Scalar_,3,1,0> Vector3Scalar;
209 
210  public:
212 
213  void calc(typename ActuatorDCFirstOrderMotorData<Scalar_>::dX_t & dstate,
214  typename ActuatorDCFirstOrderMotorData<Scalar_>::X_t & state,
215  typename ActuatorDCFirstOrderMotorData<Scalar_>::U_t & control,
216  Force & fext,
218  {
219  // Update dstate
220  dstate[0] = data.c()[0] * control[0] + data.c()[1] * state[0] +
221  data.c()[2] *data.S().dot(fext.toVector());
222  // Update observation
223  // Current
224  data.h()[0] = control[0] /data.c()[4] - data.c()[7] *state[1]/data.c()[4];
225  // Motor torque
226  data.h()[1] = data.c()[5] *data.h()[0];
227  // Back emf potential
228  data.h()[2] = data.c()[7] * state[1];
229  }
230 
231 
232  void get_force(ActuatorDCFirstOrderMotorData<Scalar_> &data, Force &aForce) const
233  {
234  aForce.linear(Vector3Scalar::Zero(3,1));
235  aForce.angular(Vector3Scalar(0.0,0.0,data.h()[1]));
236  }
237 
238  ActuatorDCFirstOrderMotorData<Scalar_> createData() const
240 
241  protected:
242 
243  // Store actuator name.
244  std::string name_;
245 
246  };
247 
248  template <typename Scalar_>
250  {
252  };
253 
254  template <typename Scalar_>
256  {
259  };
260 
261 
262 } // end of namespace se3
263 
264 #endif /* _se3_dc_linear_first_order_motor_model_ */
void backEMF(Scalar_ c)
Terminal Inductance (Henry)
void speedTorqueGrad(Scalar_ c)
Speed torque gradient (rads^-1/Nm) .
void rotorResistor(Scalar_ c)
Rotor resistor (Ohm) - .
Template implementing a first order linear DC motor model.
const Observations_t & h() const
Return observation vector.
Concreate Class representing a force.
Definition: force.hpp:243
const Vector6 & toVector() const
Return the force.
Definition: force.hpp:102
const Parameters_t & c() const
Return parameters.
void torqueConst(Scalar_ c)
Torque constant (Nm/A) - .
ConstAngular_t angular() const
Return the angular part of the force vector.
Definition: force.hpp:64
void rotorInertia(Scalar_ c)
Rotor inertia (kg/m2) - .
Template for handling data related to a first order linear DC motor model.
ConstLinear_t linear() const
Return the linear part of the force vector.
Definition: force.hpp:71
void updateFirstThreeParameters()
Update the first three parameters of the actuators:
const S_t & S() const
Returns selection matrix.