Gazebo Plugin Debugging with VSCode

asked 2020-12-31 10:27:11 -0500

erdisayar gravatar image

updated 2020-12-31 10:27:56 -0500

Hello Friends, Due to scarcity of Gazebo Plugin tutorials, I would like to learn it using debugging process. For that purpose, I created a simple Gazebo Model Plugin named [The code is in the very bottom part.] And I also added the plugin inside .sdf file

<plugin name="model_push" filename=""/>

When I try to spawn a model ( without debugging purpose), then I see the correct output as in the following picture. image description

However, If I try to debug the plugin using VSCode, something strange happens;

in the Debuggin console of VSCode, image description

The program is stopped right now in the line 36, I am writing the code "this->model->GetName() " to see the name inside debugging console. I am getting an error because the method <getname()&gt; was="" not="" found.<="" p="">

image description

Do you have any idea how to fix it ? Thank you

#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <ignition/math/Vector3.hh>
namespace gazebo
  class ModelPush : public ModelPlugin
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
      // Store the pointer to the model
  this->model = _parent;
      std::cout << "Model is loaded" << std::endl;
      // Listen to the update event. This event is broadcast every
      // simulation iteration.
      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          std::bind(&ModelPush::OnUpdate, this));

    // Pointer to the model
    private: physics::ModelPtr model;

    // Pointer to the update event connection
    private: event::ConnectionPtr updateConnection;

      // Called by the world update start event
    public: void OnUpdate()

      std::cout << this->model->GetName() << std::endl;


  // Register this plugin with the simulator
edit retag flag offensive close merge delete


Arshad gravatar imageArshad ( 2022-12-06 05:28:00 -0500 )edit