anandvgeorge

plugin

Dec 16th, 2015
372
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <boost/bind.hpp>
  2. #include <gazebo/gazebo.hh>
  3. #include <gazebo/physics/physics.hh>
  4. #include <gazebo/common/common.hh>
  5. #include <stdio.h>
  6.  
  7. double x,y,z;
  8.  
  9. namespace gazebo
  10. {
  11.   class TestModel : public ModelPlugin
  12.   {
  13.     public: TestModel() : ModelPlugin()
  14.             {
  15.               printf("Model Plugin OKAY\n");
  16.             }
  17.  
  18.     public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
  19.     {
  20.       // Store the pointer to the model
  21.       this->model = _parent;
  22.  
  23.       gazebo::math::Pose pose = this->model->gazebo::physics::ModelState::GetPose();
  24.    
  25.       x = pose._x;
  26.       y = pose._y;
  27.       z = pose._z;
  28.  
  29.       // Listen to the update event. This event is broadcast every
  30.       // simulation iteration.
  31.       this->updateConnection = event::Events::ConnectWorldUpdateBegin(
  32.           boost::bind(&TestModel::OnUpdate, this, _1));
  33.     }
  34.  
  35.     // Called by the world update start event
  36.     public: void OnUpdate(const common::UpdateInfo & /*_info*/)
  37.     {
  38.      
  39.     }
  40.  
  41.     // Pointer to the model
  42.     private: physics::ModelPtr model;
  43.  
  44.     // Pointer to the update event connection
  45.     private: event::ConnectionPtr updateConnection;
  46.   };
  47.  
  48.   // Register this plugin with the simulator
  49.   GZ_REGISTER_MODEL_PLUGIN(TestModel)
  50. }
RAW Paste Data