usv_gazebo_wind_plugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Brian Bingham
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  *
16 */
17 
18 #ifndef USV_GAZEBO_PLUGINS_WIND_HH_
19 #define USV_GAZEBO_PLUGINS_WIND_HH_
20 
21 #include <ros/ros.h>
22 #include <memory>
23 #include <random>
24 #include <string>
25 #include <vector>
26 #include <gazebo/common/CommonTypes.hh>
27 #include <gazebo/common/Plugin.hh>
28 #include <ignition/math/Vector3.hh>
29 #include <gazebo/physics/physics.hh>
30 
31 #include <sdf/sdf.hh>
32 
33 namespace gazebo
34 {
61  class UsvWindPlugin : public WorldPlugin
62  {
63  struct WindObj
64  {
66  // cppcheck-suppress unusedStructMember
67  bool init = false;
69  std::string modelName;
71  physics::ModelPtr model;
73  std::string linkName;
77  physics::LinkPtr link;
79  ignition::math::Vector3d windCoeff;
80  };
82  public: UsvWindPlugin();
83 
85  public: virtual ~UsvWindPlugin() = default;
86 
87  // Documentation inherited.
88  public: virtual void Load(physics::WorldPtr _parent,
89  sdf::ElementPtr _sdf);
90 
92  protected: virtual void Update();
93 
95  private: std::vector<UsvWindPlugin::WindObj> windObjs;
96 
98  private: bool windObjsInit = false;
99 
101  private: unsigned int windObjsInitCount = 0;
102 
104  private: physics::WorldPtr world;
105 
107  private: ignition::math::Vector3d windDirection;
108 
110  private: double windMeanVelocity;
111 
113  private: double gainConstant;
114 
116  private: double filterGain;
117 
119  private: double timeConstant;
120 
122  private: double previousTime;
123 
125  private: double varVel;
126 
128  private: std::unique_ptr<ros::NodeHandle> rosNode;
129 
132 
135 
137  private: std::string topicWindSpeed = "/vrx/debug/wind/speed";
138 
140  private: std::string topicWindDirection = "/vrx/debug/wind/direction";
141 
143  private: double lastPublishTime = 0;
144 
146  private: double updateRate;
147 
149  private: event::ConnectionPtr updateConnection;
150 
152  private: bool debug = true;
153 
155  private: std::unique_ptr<std::mt19937> randGenerator;
156  };
157 }
158 
159 #endif
double windMeanVelocity
Average wind velocity.
physics::ModelPtr model
Pointer to the model
bool debug
Bool debug set by environment var VRX_DEBUG
physics::LinkPtr link
Pointer to model link in gazebo, optionally specified by the bodyName parameter, The states are taken...
physics::WorldPtr world
Pointer to the Gazebo world.
unsigned int windObjsInitCount
Bool to keep track if ALL of the windObjs have been initialized.
std::vector< UsvWindPlugin::WindObj > windObjs
vector of simple objects effected by the wind
std::unique_ptr< ros::NodeHandle > rosNode
ROS node handle.
double filterGain
Calculated filter gain constant.
double lastPublishTime
Last time wind speed and direction was published.
A plugin that simulates a simple wind model. It accepts the following parameters: ...
double updateRate
Update rate buffer for wind speed and direction.
ros::Publisher windSpeedPub
Publisher for wind speed.
ignition::math::Vector3d windDirection
Wind velocity unit vector in Gazebo coordinates [m/s].
double previousTime
Previous time.
std::string linkName
of the link on that model
event::ConnectionPtr updateConnection
Pointer to the update event connection.
bool init
to show weather the model and link pointers have been set
double timeConstant
Time constant.
bool windObjsInit
Bool to keep track if ALL of the windObjs have been initialized.
double gainConstant
User specified gain constant.
virtual void Update()
Callback executed at every physics update.
std::unique_ptr< std::mt19937 > randGenerator
virtual ~UsvWindPlugin()=default
Destructor.
std::string topicWindDirection
Topic where the wind direction is published.
std::string topicWindSpeed
Topic where the wind speed is published.
double varVel
Variable velocity component.
ignition::math::Vector3d windCoeff
Wind force coefficients.
virtual void Load(physics::WorldPtr _parent, sdf::ElementPtr _sdf)
ros::Publisher windDirectionPub
Publisher for wind direction.


usv_gazebo_plugins
Author(s): Brian Bingham , Carlos Aguero
autogenerated on Thu May 7 2020 03:54:47