Gazebo | Ignition | Community
Ask Your Question
0

Simulate Wind In Gazebo

asked 2021-12-27 03:47:34 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

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:

  1. include the gazebo_wind_plugin.cpp file in my src folder
  2. include the header file (gazebo_wind_plugin.h) in the include folder
  3. 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 ...

(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2022-01-06 11:34:22 -0600

shonigmann gravatar image

Make sure you are including and linking the Gazebo dependencies you need (the CMakeLists of the repo you linked presumably builds the project successfully, so you can look there for guidance.

If you're struggling with adapting your CMakeLists, consider just building the PX4-SITL_gazebo project on its own, and simply adding the directory containing the compiled plugins (e.g. gazebo_wind_plugin.so) to your GAZEBO_PLUGIN_PATH environment variable.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-12-27 03:47:34 -0600

Seen: 37 times

Last updated: Jan 06