Robotics StackExchange | Archived questions

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:

  1. include the gazebowindplugin.cpp file in my src folder
  2. include the header file (gazebowindplugin.h) in the include folder
  3. edit the CmakeLists.txt to include this plugin

https://github.com/PX4/PX4-SITL_gazebo/blob/master/src/gazebo_wind_plugin.cpp

However, I get errors during catkin_make showing the following:

/home/mowaistahir/test3ws/src/src/sjtu-drone/include/gazebowindplugin.h:131:3: error: ‘physicsmsgs’ does not name a type physicsmsgs::msgs::Wind windmsg; ^~~~~~ In file included from /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:22:0: /home/mowaistahir/test3ws/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/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:21:0: /home/mowaistahir/test3ws/src/src/sjtu-drone/include/gazebowindplugin.h:36:26: note: ‘const string gazebo::kDefaultNamespace’ previously declared here static const std::string kDefaultNamespace = ""; ^~~~~~~ /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp: In member function ‘virtual void gazebo::GazeboWindPlugin::Load(gazebo::physics::WorldPtr, sdf::ElementPtr)’: /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:91:39: error: ‘physicsmsgs’ was not declared in this scope windpub_ = nodehandle->Advertise("/" + windpubtopic, 10); ^~~~~~ /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:91:29: error: parse error in template argument list windpub = nodehandle->Advertise("/" + windpubtopic, 10); ^~~~~~~~~~~~~ /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:91:91: error: no matching function for call to ‘gazebo::transport::Node::Advertise< >(std::cxx11::basicstring, int)’ handle->Advertise<physicsmsgs::msgs::Wind>("~/" + windpubtopic, 10); ^ In file included from /usr/include/gazebo-9/gazebo/transport/transport.hh:6:0, from /usr/include/gazebo-9/gazebo/gazebocore.hh:21, from /usr/include/gazebo-9/gazebo/gazebo.hh:20, from /home/mowaistahir/test3ws/src/src/sjtu-drone/include/gazebowindplugin.h:29, from /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.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/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:91:91: error: template argument 1 is invalid handle->Advertise("~/" + windpubtopic, 10); ^ /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp: In member function ‘void gazebo::GazeboWindPlugin::OnUpdate(const gazebo::common::UpdateInfo&)’: /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:145:3: error: ‘windmsg’ was not declared in this scope windmsg.setframeid(frameid); ^~~~ /home/mowaistahir/test3ws/src/src/sjtu-drone/src/gazebowindplugin.cpp:145:3: note: suggested alternative: ‘sendmmsg’ windmsg.setframeid(frameid); ^~~~ sendmmsg src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/build.make:62: recipe for target 'src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/src/gazebowindplugin.cpp.o' failed make[3]: * [src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/src/gazebowindplugin.cpp.o] Error 1 CMakeFiles/Makefile2:1325: recipe for target 'src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/all' failed make[2]: * [src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/all] Error 2 CMakeFiles/Makefile2:1337: recipe for target 'src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/rule' failed make[1]: * [src/sjtu-drone/CMakeFiles/gazebowindplugin.dir/rule] Error 2 Makefile:630: recipe for target 'gazebowindplugin' failed make: * [gazebowindplugin] Error 2 Invoking "make clean gazebowind_plugin -j4 -l4" failed

How do I resolve this physics_msgs issue?

Asked by robo16 on 2021-12-27 04:47:34 UTC

Comments

Answers

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.

Asked by shonigmann on 2022-01-06 12:34:22 UTC

Comments