16 #include <gazebo/gazebo.hh> 33 if (!_sdf->HasElement(
"type"))
35 std::cerr <<
"dynamics does not have a type element" << std::endl;
39 std::string identifier = _sdf->Get<std::string>(
"type");
41 if (creators_.find(identifier) == creators_.end())
43 std::cerr <<
"Cannot create ThrusterDynamics with unknown identifier: " 44 << identifier << std::endl;
48 return creators_[identifier](_sdf);
62 if (creators_.find(_identifier) != creators_.end())
64 std::cerr <<
"Warning: Registering ThrusterDynamics with identifier: " 65 << _identifier <<
" twice" << std::endl;
67 creators_[_identifier] = _creator;
69 std::cout <<
"Registered ThrusterDynamics type " << _identifier << std::endl;
98 if (!_sdf->HasElement(
"timeConstant"))
100 std::cerr <<
"DynamicsFirstOrder: expected element time_constant" 104 double tau = _sdf->Get<
double>(
"timeConstant");
119 double alpha = std::exp(-dt/tau);
141 if (!_sdf->HasElement(
"alpha"))
143 std::cerr <<
"ThrusterDynamicsYoerger: expected element alpha" 147 double alpha = _sdf->Get<
double>(
"alpha");
149 if (!_sdf->HasElement(
"beta"))
151 std::cerr <<
"ThrusterDynamicsYoerger: expected element beta" 155 double beta = _sdf->Get<
double>(
"beta");
177 :
Dynamics(), alpha(_alpha), beta(_beta)
190 if (!_sdf->HasElement(
"Jmsp"))
192 std::cerr <<
"ThrusterDynamicsBessa: expected element Jmsp" 197 if (!_sdf->HasElement(
"Kv1"))
199 std::cerr <<
"ThrusterDynamicsBessa: expected element Kv1" 204 if (!_sdf->HasElement(
"Kv2"))
206 std::cerr <<
"ThrusterDynamicsBessa: expected element Kv2" 211 if (!_sdf->HasElement(
"Kt"))
213 std::cerr <<
"ThrusterDynamicsBessa: expected element Kt" 218 if (!_sdf->HasElement(
"Rm"))
220 std::cerr <<
"ThrusterDynamicsBessa: expected element Rm" 225 _sdf->Get<
double>(
"Kv1"),
226 _sdf->Get<
double>(
"Kv2"),
227 _sdf->Get<
double>(
"Kt"),
228 _sdf->Get<
double>(
"Rm"));
250 double _Kv2,
double _Kt,
252 Dynamics(), Jmsp(_Jmsp), Kv1(_Kv1), Kv2(_Kv2), Kt(_Kt), Rm(_Rm)
virtual double update(double _cmd, double _t)
Update dynamical model given input value and time.
ThrusterDynamicsBessa(double _Jmsp, double _Kv1, double _kv2, double _Kt, double _Rm)
Constructor.
Yoerger's dynamic thruster model.
Bessa's dynamic thruster model.
Dynamics * CreateDynamics(sdf::ElementPtr _sdf)
Create ThrusterDynamics object according to its sdf Description.
ThrusterDynamicsYoerger(double alpha, double beta)
Constructor.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
static DynamicsFactory & GetInstance()
Returns the singleton instance of this factory.
virtual double update(double _cmd, double _t)
Update dynamical model given input value and time.
virtual double update(double _cmd, double _t)
Update dynamical model given input value and time.
Dynamics *(* DynamicsCreator)(sdf::ElementPtr)
Function pointer to create a certain thruster dynamics object.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
double prevTime
Time of last state update.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
static Dynamics * create(sdf::ElementPtr _sdf)
Create thruster model of this type with parameter values from sdf.
virtual double update(double _cmd, double _t)
Update dynamical model given input value and time.
static Dynamics * create(sdf::ElementPtr _sdf)
Create thruster model of this type with parameter values from sdf.
Abstract base class for thruster dynamics.
double state
Latest state.
static Dynamics * create(sdf::ElementPtr _sdf)
Create thruster model of this type with parameter values from sdf.
bool RegisterCreator(const std::string &_identifier, DynamicsCreator _creator)
Register a ThrusterDynamic class with its creator.
First-order dynamic system.
static Dynamics * create(sdf::ElementPtr _sdf)
Create thruster model of this type with parameter values from sdf.
DynamicsFirstOrder(double _tau)
Constructor.
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
REGISTER_DYNAMICS_CREATOR(DynamicsZeroOrder,&DynamicsZeroOrder::create) Dynamics *DynamicsZeroOrder
Trivial (no dynamics) zero-order dynamic system.
Factory singleton class that creates a ThrusterDynamics from sdf.