Robotics StackExchange | Archived questions

How to draw line or path in gazebo or is any model for line exist?

Hi,

I want to create line or path. I am attaching my code but nothing is displayed.I want to use world plugin instead of system plugin, but I am not able to get how to pass the name parameter. I also tried with system plugin but then also nothing was shown. Is it the ogre issue. Here I am attaching my world plugin code. Any help would be appreciated. Thanks!

namespace gazebo
{
namespace rendering
{
class ModelPush1 : public WorldPlugin
{
  private:physics::WorldPtr world;
  private: event::ConnectionPtr updateConnection;
  public:boost::thread draw;
  private: Ogre::SceneManager *manager;
    Ogre::SceneNode *sceneNode ;
    Ogre::ManualObject *obj;

    public: void Load(physics::WorldPtr _parent, sdf::ElementPtr _sdf)
    {
      std::cout<<"loading rfid world"<<std::endl;
      world = _parent;

      this->updateConnection = event::Events::ConnectWorldUpdateBegin(boost::bind(&ModelPush1::OnUpdate, this, _1));
      this->draw=boost::thread(boost::bind(&ModelPush1::draw_line, this));
    }

public: void draw_line()
    {
          bool attached = false;
          if (this->manager->hasManualObject("ground_plane"))
           {
             sceneNode = this->manager->getSceneNode("ground_plane");
             obj = this->manager->getManualObject("ground_plane");
             attached = true;
           }
           else
           {
             sceneNode = this->manager->getRootSceneNode()->createChildSceneNode("ground_plane");
             obj = this->manager->createManualObject("ground_plane");
           }

           sceneNode->setVisible(true);
           obj->setVisible(true);

           obj->clear();
           obj->begin("Gazebo/Red", Ogre::RenderOperation::OT_LINE_LIST);
           obj->position(12, 12, 0);
           obj->position(20,20, 0);
           obj->end();

           if (!attached)
             sceneNode->attachObject(obj);
    }

    public: void OnUpdate(const common::UpdateInfo & /*_info*/)
    {
std::cout<<"loading"<<std::endl;

    }


};

GZ_REGISTER_WORLD_PLUGIN(ModelPush1)
}

}

Asked by anonymous on 2015-04-17 06:59:02 UTC

Comments

Answers

Hi, you can have a look at this:

http://answers.gazebosim.org/question/3383/how-to-add-a-dynamic-visual-marker-in-gazebo/#3394

And otherwise you would probably need to create a model for a line.

Cheers

EDIT:

As stated in one of your comments, if you just want to do following, create a model/texture with (a) line(s) on it. Use Blender/SketchUp or any Image manipulation program

Asked by ffurrer on 2015-04-18 03:44:05 UTC

Comments

Hi,

Thank You for the reply. I tried with this also , but then it is not loading the visual plugin . Here I am attaching my code.

namespace gazebo {

namespace rendering {

class ModelPush1 : public VisualPlugin {

private: event::ConnectionPtr update_connection_;

private:VisualPtr visual_;

private:ScenePtr scene_;

private:DynamicLines *line;

public:boost::thread draw;

public: void Load( VisualPtr _parent, sdf::ElementPtr _sdf ) {

std::cout<<"loading rfid world"<<std::endl;

this->visual_ = _parent;

this->update_connection_ = event::Events::ConnectRender(boost::bind(&ModelPush1::UpdateChild, this));

this->draw=boost::thread(boost::bind(&ModelPush1::visualise_line, this));

}

public:void UpdateChild() {

    while(1)

    {

    std::cout<<"data"<<std::endl;
    }
                     }

public: void visualise_line() { std::cout<<"data"<<std::endl;

  this->line= this->visual_->CreateDynamicLine(RENDERING_LINE_STRIP);

  this->line->AddPoint(math::Vector3(12, 12, 0));

  this->line->AddPoint(math::Vector3(15, 15, 0));

  this->line->setMaterial("Gazebo/Purple");

    this->line->setVisibilityFlags(GZ_VISIBILITY_GUI);

  this->line->setVisible(true);


}

};

GZ_REGISTER_VISUAL_PLUGIN(ModelPush1) } }

And my sdf file is

<?xml version='1.0'?>

 <include>
  <uri>model://ground_plane</uri>
    <link name="my_visual_link">
      <visual name="my_visual">
        <plugin name="SomeVisualPlugin" filename="libSomeVisualPlugin.so"/>
         <pose>0 0 0 0 0 0</pose>
         <geometry>
         <empty>
         </empty>
      </geometry>

<include>
  <uri>model://sun</uri>
</include>

Asked by anonymous on 2015-04-18 05:15:34 UTC

Comments

well you should load the same shared library (.so) file as you generate. libSomeVisualPlugin.so is most likely wrong.

Asked by ffurrer on 2015-04-18 06:04:20 UTC

I am loading the same shared library as generated by code . My code filename is SomeVisualPlugin.cc and after cmake , it generated the libSomeVisualPlugin.so. But, I even export GAZEBO_PLUGIN_PATH, but still is not loading my plugin and nothing is displayed. My normal code world plugin and model plugin code are easily loading , but only this has some issues, might be because something wrong in code. Is it mandatory to use gazebo msgs, because i have done without that .

Asked by anonymous on 2015-04-18 07:33:32 UTC

I want to create line , because I want to do line following. so I think line model wont work.

Asked by anonymous on 2015-04-18 07:35:18 UTC

I'm not sure, what the problem is, did you try to run the example in my link? For your purpose I would really consider just creating a model/texture with some lines on it. I guess if you don't want to dynamically change the lines, this should be the easiest solution.

Asked by ffurrer on 2015-04-20 02:58:14 UTC