Simulate Wind In Gazebo
I am trying to simulate a drone inside an environment with constant wind. I have found a good plugin (link below) and I have done the following to integrate this plugin in my system:
- include the gazebo_wind_plugin.cpp file in my src folder
- include the header file (gazebo_wind_plugin.h) in the include folder
- edit the CmakeLists.txt to include this plugin
https://github.com/PX4/PX4-SITL_gazeb...
However, I get errors during catkin_make showing the following:
/home/mowaistahir/test3_ws/src/src/sjtu-drone/include/gazebo_wind_plugin.h:131:3: error: ‘physics_msgs’ does not name a type physics_msgs::msgs::Wind wind_msg; ^~~~~~ In file included from /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:22:0: /home/mowaistahir/test3_ws/src/src/sjtu-drone/include/common.h:47:26: error: redefinition of ‘const string gazebo::kDefaultNamespace’ static const std::string kDefaultNamespace = ""; ^~~~~~~ In file included from /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:21:0: /home/mowaistahir/test3_ws/src/src/sjtu-drone/include/gazebo_wind_plugin.h:36:26: note: ‘const string gazebo::kDefaultNamespace’ previously declared here static const std::string kDefaultNamespace = ""; ^~~~~~~ /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp: In member function ‘virtual void gazebo::GazeboWindPlugin::Load(gazebo::physics::WorldPtr, sdf::ElementPtr)’: /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:91:39: error: ‘physics_msgs’ was not declared in this scope wind_pub_ = node_handle_->Advertise<physics_msgs::msgs::wind>("/" + wind_pub_topic_, 10); ^~~~~~ /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:91:29: error: parse error in template argument list wind_pub_ = node_handle_->Advertise<physics_msgs::msgs::wind>("/" + wind_pub_topic_, 10); ^~~~~~~~~~~~~ /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:91:91: error: no matching function for call to ‘gazebo::transport::Node::Advertise< >(std::cxx11::basic_string, int)’ handle->Advertise<physics_msgs::msgs::wind>("~/" + wind_pub_topic, 10); ^ In file included from /usr/include/gazebo-9/gazebo/transport/transport.hh:6:0, from /usr/include/gazebo-9/gazebo/gazebo_core.hh:21, from /usr/include/gazebo-9/gazebo/gazebo.hh:20, from /home/mowaistahir/test3_ws/src/src/sjtu-drone/include/gazebo_wind_plugin.h:29, from /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:21: /usr/include/gazebo-9/gazebo/transport/Node.hh:153:31: note: candidate: template gazebo::transport::PublisherPtr gazebo::transport::Node::Advertise(const string&, unsigned int, double) transport::PublisherPtr Advertise(const std::string &topic, ^~~~~ /usr/include/gazebo-9/gazebo/transport/Node.hh:153:31: note: template argument deduction/substitution failed: /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:91:91: error: template argument 1 is invalid handle->Advertise<physics_msgs::msgs::wind>("~/" + wind_pub_topic_, 10); ^ /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp: In member function ‘void gazebo::GazeboWindPlugin::OnUpdate(const gazebo::common::UpdateInfo&)’: /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:145:3: error: ‘wind_msg’ was not declared in this scope wind_msg.set_frame_id(frame_id_); ^~~~ /home/mowaistahir/test3_ws/src/src/sjtu-drone/src/gazebo_wind_plugin.cpp:145:3: note: suggested alternative: ‘sendmmsg’ wind_msg.set_frame_id(frame_id_); ^~~~ sendmmsg src/sjtu-drone/CMakeFiles/gazebo_wind_plugin.dir/build.make:62: recipe for target 'src/sjtu-drone/CMakeFiles/gazebo_wind_plugin.dir/src/gazebo_wind_plugin.cpp.o' failed make[3]: * [src/sjtu-drone/CMakeFiles/gazebo_wind_plugin.dir/src/gazebo_wind_plugin.cpp.o] Error 1 CMakeFiles/Makefile2 ...