Advertisement
Chris_To

Pluginload

Jul 22nd, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1.        // World plugin
  2.         using namespace std;
  3.         namespace gazebo
  4.         {    
  5.           class WorldC: public WorldPlugin
  6.           {
  7.               public: WorldC() : WorldPlugin()
  8.               {
  9.                  //...
  10.               }
  11.           public: void Load(physics::WorldPtr _parent, sdf::ElementPtr /*_sdf*/)
  12.           {
  13.               string sdfString = "";
  14.               sdfString = sdfString +  
  15.             "<sdf version ='1.3'>\
  16.               <model name='raybot_model'>\
  17.                 <!--- ... -->
  18.                 </link>\
  19.                 <link name='raybot_sensor1'>\
  20.                         <pose>0.01 0 1.03 0 0 0</pose>\
  21.                 <!--- ... -->
  22.                     <sensor name='laser1' type='ray'>\
  23.                         <always_on>true</always_on>\
  24.                         <visualize>true</visualize>\
  25.                         <ray>\
  26.                             <!--...->
  27.                         </ray>\
  28.                         <update_rate>30</update_rate>\
  29.                     </sensor>\
  30.                 </link>\
  31.                 <plugin name='ModelC'filename='libMOdelC.so'/>\
  32.                  </model>\
  33.                 </sdf>\
  34.                 ";
  35.            
  36.                 cout << sdfString << endl; // sdf-code seems to be correct (the code works when entered manually into a world-file)
  37.    
  38.                 sdf::SDF sphereSDF;
  39.                 sphereSDF.SetFromString(sdfString);
  40.                  _parent->InsertModelSDF(sphereSDF);
  41.    
  42.                 cout << "sdf done" << endl;
  43.             }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////////////////////////////
  46.  
  47. // Model plugin
  48. using namespace std;
  49. namespace gazebo
  50. {  
  51.   class ModelC : public ModelPlugin
  52.   {
  53.     public: ModelC (): ModelPlugin()
  54.     {
  55.       cout << "Hello World" << endl;      
  56.     }
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement