Quantcast
Channel: Gazebo: Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 7017

Creation of an attribute for a gazebo plugin

$
0
0
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/questions/8893/gazebo-moving-joint-with-model-plugin/16248#16248 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 #include #include #include #include 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 GZ_REGISTER_MODEL_PLUGIN(HolonomicPlugin) } 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.

Viewing all articles
Browse latest Browse all 7017

Trending Articles