[ros-users] Displaying visualization_msgs::Marker in Stage

Brian Gerkey gerkey at willowgarage.com
Mon Jun 14 17:04:04 UTC 2010


hi Gonçalo,

This turned out to be more trouble than I expected, but I have a
proof-of-concept working.  Attached is a patch against stageros that
has your changes, plus one important addition: calling
plume_model->Subscribe().  Stage doesn't bother to update models to
which noone has subscribed.

With that patch, I'm able to publish and see visualization_markers,
e.g., using rostopic:

rostopic pub /plumesim_markers visualization_msgs/Marker '{header:
auto, ns: foo, id: 0, type: 8, action: 0., points: [{x: 1., y: 1., z:
1.}, {x: 2., y: 2., z: 2.}], color: {r: 1., g: 0., b: 1., a: 1.}}'

However, publishing again with different values didn't have any
effect.  It looks like Stage's redraw logic is a little broken.
Calling Model::NeedRedraw() doesn't actually cause the display list to
be rebuilt.  I was able to make it work by applying the second
attached patch to stage itself (apply in
stage/build/Stage-3.2.2-Source, then 'make install' in
stage/build/Stage-3.2.2-Source/build).  I don't know enough about
OpenGL to know whether this is a good fix (e.g., will it leak
memory?).

Hopefully that gets you going.  If you get things working well, please
send back patches and I'll integrate them.

	brian.

2010/6/8 Gonçalo Cabrita <goncabrita at gmail.com>:
> Hi everyone!
> I've recently been trying to modify stageros to draw
> visualization_msgs::Marker. After taking a look at Stage's API this is what
> I came up with:
> // Our node
> class StageNode
> {
> private:
>
>     (...)
>     ros::Subscriber markers_sub_;
>     Stg::Model * plume_model;
>     (...)
> }
> void
> StageNode::markersReceived(const
> boost::shared_ptr<visualization_msgs::Marker const>& msg)
> {
> boost::mutex::scoped_lock lock(msg_lock);
> plume_model->SetColor(Stg::Color(msg->color.r, msg->color.g, msg->color.b,
> msg->color.a));
> plume_model->ClearBlocks();
> for(int i=0 ; i<msg->points.size() ; i++)
> {
> plume_model->AddBlockRect(msg->points[i].x, msg->points[i].y, 0.1, 0.1,
> 0.1);
> }
> plume_model->NeedRedraw();
> }
> StageNode::StageNode(int argc, char** argv, bool gui, const char* fname)
> {
> (...)
> markers_sub_ = n_.subscribe<visualization_msgs::Marker>("plumesim_markers",
> 10, boost::bind(&StageNode::markersReceived, this, _1));
> plume_model = new Stg::Model(world);
> plume_model->ClearBlocks();
> plume_model->SetObstacleReturn(0);
> }
> So I am creating a Stg::Model and I am also creating a callback for
> the visualization_msgs::Marker, and my idea was to push the incoming markers
> as Blocks into my Stg:Model and redraw it (not worrying for now how they
> look, just want them to show up).
> However so far I have had no luck. Does anyone have any experience with
> libstage? Am I missing something or is this entirely wrong?
> Thanks for the help,
> Gonçalo Cabrita
> ISR - University of Coimbra
> Portugal
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stageros_marker.patch
Type: application/octet-stream
Size: 2448 bytes
Desc: not available
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100614/a2472c50/attachment-0010.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stage-displaylist.patch
Type: application/octet-stream
Size: 367 bytes
Desc: not available
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100614/a2472c50/attachment-0011.obj>


More information about the ros-users mailing list