Gazebo | Ignition | Community
Ask Your Question
1

Visual plugin shuts down the simulation

asked 2019-02-25 09:07:23 -0600

kumpakri gravatar image

updated 2019-02-25 09:36:52 -0600

I want to write a visual plugin. I started by writing a visual plugin that is only supposed to draw a line at the same position with every ~/pose/local/info message. I attached the plugin to a SDF description of a robot. So I launch the gazebo by the $ gazebo command and then include the robot from the left side menu. The simulation runs as normal before I put the robot in. Then it shuts down without error. Why and how can I fix it?

source code of the plugin:

#include "VisualizationPlugin.hh"

namespace gazebo
{
    namespace rendering
    {

        // Constructor
        VisualizationPlugin::VisualizationPlugin()
        {}

        // Destructor
        VisualizationPlugin::~VisualizationPlugin()
        {}

        // Load the plugin
        void VisualizationPlugin::Load( VisualPtr _parent, sdf::ElementPtr _sdf )
        {
            this->visual = _parent;

            this->visualNamespace = "visual/";

            this->node = gazebo::transport::NodePtr(new gazebo::transport::Node());
            this->node->Init();

            this->sub = this->node->Subscribe("~/pose/local/info", &VisualizationPlugin::Visualize, this);

        }

        void VisualizationPlugin::Visualize(ConstPosesStampedPtr &msg)
        {
            this->line = this->visual->CreateDynamicLine(RENDERING_LINE_STRIP);

            this->line->AddPoint( math::Vector3( 0, 0, 0 ), common::Color::White );
            this->line->AddPoint( math::Vector3( 1, 1, 1 ), common::Color::White );
            this->line->setVisibilityFlags(GZ_VISIBILITY_GUI);
            this->visual->SetVisible(true);
        }

    }
}
edit retag flag offensive close merge delete

Comments

I meet this same error since yesterday. My own visual plugin works well before, but it will crash gazebo8 now. What happens? Could anyone explain that?

littleghost gravatar imagelittleghost ( 2019-02-25 21:33:10 -0600 )edit

Which version do you use? Gazebo8 or Gazebo9?

littleghost gravatar imagelittleghost ( 2019-02-26 03:44:35 -0600 )edit

gazebo 7, as tagged to the question.

kumpakri gravatar imagekumpakri ( 2019-02-26 04:12:39 -0600 )edit

Then it seems that this error happens in all release version.

littleghost gravatar imagelittleghost ( 2019-02-26 06:19:00 -0600 )edit

If you have any clue, please let me know, my friends.

littleghost gravatar imagelittleghost ( 2019-02-27 20:35:58 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-05 08:39:40 -0600

littleghost gravatar image

You can check if it still crashed with drawing a single line. For me, if you draw a null value, then it will crash.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-02-25 09:07:23 -0600

Seen: 261 times

Last updated: Mar 05 '19