Home | Tutorials | Wiki | Issues
Ask Your Question

Error while creating a class attribute for a gazebo plugin

asked 2018-08-19 04:25:51 -0500

RobinBaruffa gravatar image

updated 2018-08-19 18:49:53 -0500

Hi, I am creating a gazebo plugin to control a non-holonomic robot (aka with so-called omni wheels), and while tinkering and playing with codes I found online I ran into an issue. I tried to compile this code : https://robotics.stackexchange.com/qu... but when I did so, I wansn't able to store the joint's pointer into a new attribute of the class. Here is my code :

//the path of the plugin must be known by gazebo through an environment variable, and this needs to be set at each terminal startup
//So you need to add the following to the .bashrc file at the root of your home directory
//nano ~.bashrc
//and add on the bottom
//export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:~/home/omniROS/omniROS_ws/src/gazebo_plugin_holonomic/build

//To run the plugin $/build cmake ../ && make
#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <ignition/math/Vector3.hh>

namespace gazebo
  class HolonomicPlugin : public ModelPlugin
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
      // Store the pointer to the model
      this->model = _parent;
      this->jointR2_ = this->model->GetJoint()[0];

      // Listen to the update event. This event is broadcast every
      // simulation iteration.
      this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          std::bind(&HolonomicPlugin::OnUpdate, this));

    // Called by the world update start event
    public: void OnUpdate()
      // Apply a small linear velocity to the model.
      this->model->SetLinearVel(ignition::math::Vector3d(.3, 0, 0));

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

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

  // Register this plugin with the simulator

And here is the errors I get while compiling it:

/home/user/omniROS/omniROS_ws/src/gazebo_plugin_holonomic/holonomic_model_plugin.cc: In member function ‘virtual void gazebo::HolonomicPlugin::Load(gazebo::physics::ModelPtr, sdf::ElementPtr)’:
/home/user/omniROS/omniROS_ws/src/gazebo_plugin_holonomic/holonomic_model_plugin.cc:22:13: error: ‘class gazebo::HolonomicPlugin’ has no member named ‘jointR2_’
       this->jointR2_ = this->model->GetJoint()[0];

My goal is to store the three pointers of my model's three joints in order to create a PID control in the OnUpdate() class function. It is probably a gazebo non-related question but I can't manage to find a correct answer on internet (I don't know where to search).

I'll keep you updated on this project if some are interested.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-08-20 02:08:29 -0500

wentz gravatar image

This usually means that you did not declare the class variable "jointR2_" properly. Take a look in the header file and make sure the declaration looks like this:

 gazebo::physics::JointPtr jointR2_;

(Leave the gazebo namespace prefix if your header already uses the gazebo namespace)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-19 04:25:51 -0500

Seen: 51 times

Last updated: Aug 20 '18