Visual plugin shuts down the simulation
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);
}
}
}
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?
Which version do you use? Gazebo8 or Gazebo9?
gazebo 7, as tagged to the question.
Then it seems that this error happens in all release version.
If you have any clue, please let me know, my friends.