Robotics StackExchange | Archived questions

Gazebo Plugin Debugging with VSCode

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 model_push.cc. [The code is in the very bottom part.] And I also added the plugin inside .sdf file

<plugin name="model_push" filename="libmodel_push.so"/>

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 was not found.

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
  GZ_REGISTER_MODEL_PLUGIN(ModelPush)
}

Asked by erdisayar on 2020-12-31 11:27:11 UTC

Comments

Answers