00001 /* 00002 00003 Copyright (c) 2018, Brian Bingham 00004 All rights reserved 00005 00006 This file is part of the usv_gazebo_dynamics_plugin package, known as this Package. 00007 00008 This Package free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 This Package s distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this package. If not, see <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #ifndef USV_GAZEBO_WIND_H 00024 #define USV_GAZEBO_WIND_H 00025 00026 00027 // Gazebo 00028 #include <gazebo/common/common.hh> 00029 #include <gazebo/physics/physics.hh> 00030 //#include <gazebo_plugins/gazebo_ros_utils.h> 00031 00032 //ROS 00033 #include <nav_msgs/Odometry.h> 00034 #include <geometry_msgs/TwistWithCovariance.h> 00035 #include <geometry_msgs/PoseWithCovariance.h> 00036 00037 #include <Eigen/Core> 00038 //#include <tf/transform_broadcaster.h> 00039 #include <ros/ros.h> 00040 00041 // Custom Callback Queue 00042 #include <ros/callback_queue.h> 00043 #include <ros/advertise_options.h> 00044 00045 namespace gazebo 00046 { 00047 class UsvWindPlugin : public ModelPlugin 00048 { 00049 public: 00050 UsvWindPlugin(); 00051 virtual ~UsvWindPlugin(); 00053 virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf); 00054 protected: 00056 virtual void UpdateChild(); 00057 virtual void FiniChild(); 00058 private: 00059 00060 double getSdfParamDouble(sdf::ElementPtr sdfPtr, const std::string ¶m_name, double default_val); 00061 00063 void spin(); 00064 00066 std::string node_namespace_; 00067 std::string link_name_; 00068 00069 ros::NodeHandle *rosnode_; 00070 00071 //GazeboRosPtr gazebo_ros_; 00072 //physics::ModelPtr parent; 00073 event::ConnectionPtr update_connection_; 00074 00076 physics::WorldPtr world_; 00078 physics::ModelPtr model_; 00082 physics::LinkPtr link_; 00083 00085 math::Vector3 param_wind_velocity_vector_; 00086 00088 math::Vector3 param_wind_coeff_vector_; 00089 00090 boost::thread *spinner_thread_; 00091 00092 event::ConnectionPtr contact_event_; 00093 00094 // Pointer to the update event connection 00095 event::ConnectionPtr updateConnection; 00096 00097 }; // class UsvWindPlugin 00098 } // namespace gazebo 00099 00100 #endif //USV_GAZEBO_WIND_H