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);
}
}
}
Asked by kumpakri on 2019-02-25 10:07:23 UTC
Answers
You can check if it still crashed with drawing a single line. For me, if you draw a null value, then it will crash.
Asked by littleghost on 2019-03-05 09:39:40 UTC
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?
Asked by littleghost on 2019-02-25 22:33:10 UTC
Which version do you use? Gazebo8 or Gazebo9?
Asked by littleghost on 2019-02-26 04:44:35 UTC
gazebo 7, as tagged to the question.
Asked by kumpakri on 2019-02-26 05:12:39 UTC
Then it seems that this error happens in all release version.
Asked by littleghost on 2019-02-26 07:19:00 UTC
If you have any clue, please let me know, my friends.
Asked by littleghost on 2019-02-27 21:35:58 UTC