I've written a custom plugin for igntion gazebo just to see if I'm doing it right. Below is the .cc file of the plugin and its implementation in the sdf file.

There is a little section at the end that should print an ignmsg, but I don't where this should be printing or if I'm calling the plugin correctly to run the PostUpdate function in the code. I run gazebo with verbosity level 4 yet nothing comes out. If anyone could help me out that would be great!

Edit: As a make do solution for now, I have been using the ignerr command, but I'd like to get the ignmsg command working so I can differentiate between two types of message.

Plugin.cc code

// We'll use a string and the ignmsg command below for a brief example.
// Remove these includes if your plugin doesn't need them.
#include <string>
#include <ignition/common/Console.hh>

// This header is required to register plugins. It's good practice to place it
// in the cc file, like it's done here.
#include <ignition/plugin/Register.hh>

// Don't forget to include the plugin's header.
#include "TestbedWrench.hh"

// This is required to register the plugin. Make sure the interfaces match
// what's in the header.

using namespace testbed_wrench;

// Here we implement the PostUpdate function, which is called at every
// iteration.
void TestbedWrench::PostUpdate(const ignition::gazebo::UpdateInfo &_info,
    const ignition::gazebo::EntityComponentManager &/*_ecm*/)
  // This is a simple example of how to get information from UpdateInfo.
  std::string msg = "Testbed Wrench plugin working, ignore that -> ";
  if (!_info.paused)
    msg += "not ";
  msg += "paused.";

  // Messages printed with ignmsg only show when running with verbosity 3 or
  // higher (i.e. ign gazebo -v 3)
  ignmsg << msg << std::endl;

Implemtation in sdf file

?xml version="1.0" ?>
<sdf version="1.8">
    <world name="forfly_world">
        <physics name="1ms" type="ignored">
            filename='TestbedWrench' name='testbed_wrench::TestbedWrench'>

        <light type="directional" name="sun">
            <pose>0 0 10 0 0 0</pose>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.2 0.2 0.2 1</specular>
            <direction>-0.5 0.1 -0.9</direction>

        <model name="ground_plane">
            <link name="link">
                <collision name="collision">
                    <normal>0 0 1</normal>
                <visual name="visual">
                    <normal>0 0 1</normal>
                    <size>100 100</size>
                    <ambient>0.8 0.8 0.8 1</ambient>
                    <diffuse>0.8 0.8 0.8 1</diffuse>
                    <specular>0.8 0.8 0.8 1</specular>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.