I want to write a Doppler Velocity Log (DVL) SensorPlugin for gazebo, but gazebo fails to load the plugin. My DvlPlugin.cpp looks like this

#include "DvlPlugin.hpp"

using namespace std;
using namespace gazebo;

void DvlPlugin::Load(sensors::SensorPtr sensor, sdf::ElementPtr pluginElement){
    gzmsg << "Load" << endl;

and my DvlPlugin.hpp looks like this

#include <gazebo/common/common.hh>
#include <gazebo/sensors/Sensor.hh>

namespace gazebo {
    class DvlPlugin : public gazebo::SensorPlugin
        void Load(gazebo::sensors::SensorPtr sensor, sdf::ElementPtr sdf);

So there is really nothing big that is done in the code, and everything compiles without errors. When I load following simple sdf file

<?xml version="1.0" ?>
<sdf version="1.6">
    <world name="worl_test">
        <model name="model_test">
            <link name="link_test">
                <pose>0 0 0 0 0 0</pose>
                <sensor type="dvl" name="dvl_test">
                    <plugin name="gazebo_dvl" filename="libgazebo_dvl.so"/>

I get the error [Err] [SensorManager.cc:276] Unable to create sensor of type[dvl] (which means, when we look the SensorManager.cc code, that the Sensor dvl is not in the SensorFactory. Do you have an Idea why I get this error?

PS: I am under Ubuntu 16.04 and I use gazebo 7 and I get the error even if i load the full path to the libgazebo_dvl.so.


Welcome to Robotics, Chris. This question is specific to Gazebo, so you might have better luck getting a question if you ask over at the Gazebo forums.

I'll start with the comment that using namespace ____ is bad practice and just leave the comment at that.

I'm not sure how you got started with creating the plugin the way you did, but I would suggest having a look at the sensor plugin tutorial. Specifically, the example includes gazebo/gazebo.hh, which you do not. Then, they have the class inherit class ContactPlugin : public SensorPlug. You call the inheritance class DvlPlugin : public gazebo::SensorPlugin, but I'm not sure how you're getting gazebo:: anything without having included the gazebo header.

Your header calls the ElementPtr sdf, but your source file calls the same thing pluginElement. Your source file doesn't define the constructor, or the destructor, and the Load method doesn't bind the plugin to anything.

Personally, I would start with the example code in the tutorial, gut it one section at a time until you get the minimum that compiles, then fill the shell with the functionality you want. Since the specific error that you're getting is that it can't create the sensor, I would at least try adding the constructor and destructor definitions.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.