Gazebo | Ignition | Community
Ask Your Question

Minimal Class to create a VisualPlugin

asked 2021-08-01 11:58:04 -0500

ihateros gravatar image

I want to create a VisualPlugin , I tried following the tutorial in the gazebo website , which uses a WorldPlugin , and going along those lines I created the following class

#include <gazebo/common/Plugin.hh>
#include <gazebo/rendering/Visual.hh>

namespace gazebo

 class GZ_PLUGIN_VISIBLE WorldPluginTutorial : public VisualPlugin
public: WorldPluginTutorial() 
          printf("Hello World!\n");

 public: virtual void Load(rendering::VisualPtr _visual,
    sdf::ElementPtr _sdf)
    if (!_visual || !_sdf)
            gzerr << "No visual or SDF element specified. Plugin won't load." <<


 /* following the model shown in the basic plugin tutorial in the gazebo website   
public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)



which creates shared library However the Load() function does not seem to be working, It prints Hello World! and then does nothing.

I used the following sdf file a part of

<?xml version="1.0" ?>
<sdf version="1.5">
<world name="default">
<model name="box_sim">
  <pose>0 0 0.5 0 0 0</pose>
  <link name="link">
    <collision name="collision">
          <size>1 1 1</size>
    <visual name="visual">
          <size>1 1 1</size>
      <plugin name="gazebo_line_plugin" filename="">
        <color_a>1 0 0 1</color_a>
        <color_b>1 0 0 0</color_b>

I would really appreciate it if someone told me what I was doing wrong , and how I can correct it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-04 02:01:07 -0500

Veerachart gravatar image

Is the missing of "\n" at the end of printf("loaded!"); the cause?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-08-01 11:58:04 -0500

Seen: 19 times

Last updated: Aug 04