Dynamics.hh
Go to the documentation of this file.
1 // Copyright (c) 2016 The UUV Simulator Authors.
2 // All rights reserved.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
18 
19 #ifndef __UUV_GAZEBO_PLUGINS_THRUSTER_DYNAMICS_HH__
20 #define __UUV_GAZEBO_PLUGINS_THRUSTER_DYNAMICS_HH__
21 
22 #include <map>
23 #include <string>
24 
25 #include <sdf/sdf.hh>
26 
27 namespace gazebo
28 {
30 class Dynamics
31 {
33  protected: Dynamics() { Reset(); }
34 
36  public: virtual ~Dynamics() {}
37 
39  public: virtual std::string GetType() = 0;
40 
44  public: virtual double update(double _cmd, double _t) = 0;
45 
46  // \brief Reset state.
47  public: virtual void Reset();
48 
50  protected: double prevTime;
51 
53  protected: double state;
54 };
55 
57 typedef Dynamics* (*DynamicsCreator)(sdf::ElementPtr);
58 
61 {
63  public: Dynamics* CreateDynamics(sdf::ElementPtr _sdf);
64 
66  public: static DynamicsFactory& GetInstance();
67 
69  public: bool RegisterCreator(const std::string& _identifier,
70  DynamicsCreator _creator);
71 
73  private: DynamicsFactory() {}
74 
76  private: std::map<std::string, DynamicsCreator> creators_;
77 };
78 
80 #define REGISTER_DYNAMICS(type) static const bool registeredWithFactory
81 
83 #define REGISTER_DYNAMICS_CREATOR(type, creator) \
84  const bool type::registeredWithFactory = \
85  DynamicsFactory::GetInstance().RegisterCreator( \
86  type::IDENTIFIER, creator);
87 
88 
91 {
93  public: static Dynamics* create(sdf::ElementPtr _sdf);
94 
96  public: virtual std::string GetType() { return IDENTIFIER; }
97 
99  public: virtual double update(double _cmd, double _t);
100 
103 
105  private: static const std::string IDENTIFIER;
106 
108  private: DynamicsZeroOrder() : Dynamics() {}
109 };
110 
111 
114 {
116  public: static Dynamics* create(sdf::ElementPtr _sdf);
117 
119  public: virtual std::string GetType() { return IDENTIFIER; }
120 
122  public: virtual double update(double _cmd, double _t);
123 
126 
128  private: static const std::string IDENTIFIER;
129 
131  private: DynamicsFirstOrder(double _tau);
132 
134  private: double tau;
135 };
136 
137 
144 {
146  public: static Dynamics* create(sdf::ElementPtr _sdf);
147 
149  public: virtual std::string GetType() { return IDENTIFIER; }
150 
152  public: virtual double update(double _cmd, double _t);
153 
156 
158  private: static const std::string IDENTIFIER;
159 
161  private: ThrusterDynamicsYoerger(double alpha, double beta);
162 
164  private: double alpha;
165 
167  private: double beta;
168 };
169 
170 
177 {
179  public: static Dynamics* create(sdf::ElementPtr _sdf);
180 
182  public: virtual std::string GetType() { return IDENTIFIER; }
183 
185  public: virtual double update(double _cmd, double _t);
186 
189 
191  private: static const std::string IDENTIFIER;
192 
194  private: ThrusterDynamicsBessa(double _Jmsp, double _Kv1, double _kv2,
195  double _Kt, double _Rm);
196 
198  private: double Jmsp;
199 
201  private: double Kv1;
202 
204  private: double Kv2;
205 
207  private: double Kt;
208 
210  private: double Rm;
211 };
212 }
213 
214 #endif
std::map< std::string, DynamicsCreator > creators_
Map of each registered identifier to its corresponding creator.
Definition: Dynamics.hh:76
#define REGISTER_DYNAMICS(type)
Use the following macro within a ThrusterDynamics declaration:
Definition: Dynamics.hh:80
virtual ~Dynamics()
Destructor.
Definition: Dynamics.hh:36
Yoerger&#39;s dynamic thruster model.
Definition: Dynamics.hh:143
Dynamics()
Protected constructor: Use the factory for object creation.
Definition: Dynamics.hh:33
DynamicsZeroOrder()
Constructor.
Definition: Dynamics.hh:108
double alpha
Lumped model parameter with no direct physical meaning.
Definition: Dynamics.hh:164
Bessa&#39;s dynamic thruster model.
Definition: Dynamics.hh:176
double Kv2
Empirically-determined model parameter.
Definition: Dynamics.hh:204
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
Definition: Dynamics.hh:191
virtual std::string GetType()=0
Return (derived) type of thruster dynamics.
DynamicsFactory()
Constructor is private since this is a singleton.
Definition: Dynamics.hh:73
Dynamics *(* DynamicsCreator)(sdf::ElementPtr)
Function pointer to create a certain thruster dynamics object.
Definition: Dynamics.hh:57
double tau
Time constant tau.
Definition: Dynamics.hh:134
double Kv1
Empirically-determined model parameter.
Definition: Dynamics.hh:201
virtual void Reset()
Definition: Dynamics.cc:23
virtual std::string GetType()
Return (derived) type of dynamic system.
Definition: Dynamics.hh:119
double beta
Lumped model parameter with no direct physical meaning.
Definition: Dynamics.hh:167
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
Definition: Dynamics.hh:158
virtual std::string GetType()
Return (derived) type of dynamic system.
Definition: Dynamics.hh:96
double prevTime
Time of last state update.
Definition: Dynamics.hh:50
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
Definition: Dynamics.hh:128
double Rm
Winding resistance.
Definition: Dynamics.hh:210
Abstract base class for thruster dynamics.
Definition: Dynamics.hh:30
double state
Latest state.
Definition: Dynamics.hh:53
virtual std::string GetType()
Return (derived) type of dynamic system.
Definition: Dynamics.hh:182
double Kt
Motor torque constant.
Definition: Dynamics.hh:207
First-order dynamic system.
Definition: Dynamics.hh:113
virtual std::string GetType()
Return (derived) type of dynamic system.
Definition: Dynamics.hh:149
static const std::string IDENTIFIER
Unique identifier for this dynamical model.
Definition: Dynamics.hh:105
Trivial (no dynamics) zero-order dynamic system.
Definition: Dynamics.hh:90
Factory singleton class that creates a ThrusterDynamics from sdf.
Definition: Dynamics.hh:60
virtual double update(double _cmd, double _t)=0
Update the dynamic model.
double Jmsp
Motor-shaft-propeller inertia.
Definition: Dynamics.hh:198


uuv_gazebo_plugins
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Thu Jun 18 2020 03:28:24