Thanks for you help Brian.<div><br></div><div>Unfortunately filling a model with a bunch of blocks did not have the behavior I was expecting :)</div><div><br></div><div>Now I'm trying an array or vector of Stg::Models but with little success, for the reason that I guess that Stg::Models where never meant to be deleted and drawn over and over again!</div>
<div><br></div><div>Let me explain what is the purpose of all this...</div><div><br></div><div>Here at the lab we work mainly with odor search. So a while ago we did a plugin driver for Player/Stage called PlumeSim. It is able to simulate odor plumes and draw them in Stage so we can simulate our odor search algorithms. The way we draw in Stage is by using a graphics3d interface. Plumes are shown as a cloud of particles.</div>
<div><br></div><div>Now we started to try ROS here at the lab so I ported PlumeSim to ROS. We looked for existing msg for outputting the arrays of points that PlumeSim creates and show them. We did this in rviz, using visualization_msgs::Marker. So our PlumeSim for ROS is working and we can see the output in rviz.</div>
<div><br></div><div>However we also want to be able to see the plume in stageros, where the simulated robots will be moving, so we decided to edit it. Our idea was to use the visualization_msgs::Marker pretty much like we used the graphics3d, however once we get the data inside stageros, which is the easy part, we have no idea on how to properly display the plume.</div>
<div><br></div><div>I though we should use Stg::Model cause it is the basic model. We also tried to understand how graphics3d works in Player/Stage when drawing in Stage but we can't figure it out.</div><div><br></div>
<div>Any thoughts on this? Probably using Stg::Model isn't even the best solution, is there any other way?</div><div><br></div><div>You can find some pics and movies of PlumeSim running on Stage at, we haven't updated the website with the ROS version yet.</div>
<div><br></div><div><a href="http://embedded.deec.uc.pt/~guardians/plumesim/Home.html">http://embedded.deec.uc.pt/~guardians/plumesim/Home.html</a></div><div><br></div><div>Thanks for your help,</div><div><br></div><div>Gonçalo Cabrita</div>
<div>ISR - University of Coimbra</div><div>Portugal</div><div><br><div class="gmail_quote">On Mon, Jun 14, 2010 at 6:04 PM, Brian Gerkey <span dir="ltr"><<a href="mailto:gerkey@willowgarage.com">gerkey@willowgarage.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">hi Gonçalo,<br>
<br>
This turned out to be more trouble than I expected, but I have a<br>
proof-of-concept working.  Attached is a patch against stageros that<br>
has your changes, plus one important addition: calling<br>
plume_model->Subscribe().  Stage doesn't bother to update models to<br>
which noone has subscribed.<br>
<br>
With that patch, I'm able to publish and see visualization_markers,<br>
e.g., using rostopic:<br>
<br>
rostopic pub /plumesim_markers visualization_msgs/Marker '{header:<br>
auto, ns: foo, id: 0, type: 8, action: 0., points: [{x: 1., y: 1., z:<br>
1.}, {x: 2., y: 2., z: 2.}], color: {r: 1., g: 0., b: 1., a: 1.}}'<br>
<br>
However, publishing again with different values didn't have any<br>
effect.  It looks like Stage's redraw logic is a little broken.<br>
Calling Model::NeedRedraw() doesn't actually cause the display list to<br>
be rebuilt.  I was able to make it work by applying the second<br>
attached patch to stage itself (apply in<br>
stage/build/Stage-3.2.2-Source, then 'make install' in<br>
stage/build/Stage-3.2.2-Source/build).  I don't know enough about<br>
OpenGL to know whether this is a good fix (e.g., will it leak<br>
memory?).<br>
<br>
Hopefully that gets you going.  If you get things working well, please<br>
send back patches and I'll integrate them.<br>
<br>
        brian.<br>
<br>
2010/6/8 Gonçalo Cabrita <<a href="mailto:goncabrita@gmail.com">goncabrita@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi everyone!<br>
> I've recently been trying to modify stageros to draw<br>
> visualization_msgs::Marker. After taking a look at Stage's API this is what<br>
> I came up with:<br>
> // Our node<br>
> class StageNode<br>
> {<br>
> private:<br>
><br>
>     (...)<br>
>     ros::Subscriber markers_sub_;<br>
>     Stg::Model * plume_model;<br>
>     (...)<br>
> }<br>
> void<br>
> StageNode::markersReceived(const<br>
> boost::shared_ptr<visualization_msgs::Marker const>& msg)<br>
> {<br>
> boost::mutex::scoped_lock lock(msg_lock);<br>
> plume_model->SetColor(Stg::Color(msg->color.r, msg->color.g, msg->color.b,<br>
> msg->color.a));<br>
> plume_model->ClearBlocks();<br>
> for(int i=0 ; i<msg->points.size() ; i++)<br>
> {<br>
> plume_model->AddBlockRect(msg->points[i].x, msg->points[i].y, 0.1, 0.1,<br>
> 0.1);<br>
> }<br>
> plume_model->NeedRedraw();<br>
> }<br>
> StageNode::StageNode(int argc, char** argv, bool gui, const char* fname)<br>
> {<br>
> (...)<br>
> markers_sub_ = n_.subscribe<visualization_msgs::Marker>("plumesim_markers",<br>
> 10, boost::bind(&StageNode::markersReceived, this, _1));<br>
> plume_model = new Stg::Model(world);<br>
> plume_model->ClearBlocks();<br>
> plume_model->SetObstacleReturn(0);<br>
> }<br>
> So I am creating a Stg::Model and I am also creating a callback for<br>
> the visualization_msgs::Marker, and my idea was to push the incoming markers<br>
> as Blocks into my Stg:Model and redraw it (not worrying for now how they<br>
> look, just want them to show up).<br>
> However so far I have had no luck. Does anyone have any experience with<br>
> libstage? Am I missing something or is this entirely wrong?<br>
> Thanks for the help,<br>
> Gonçalo Cabrita<br>
> ISR - University of Coimbra<br>
> Portugal<br>
</div></div><div><div></div><div class="h5">> _______________________________________________<br>
> ros-users mailing list<br>
> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
><br>
><br>
</div></div><br>_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
<br></blockquote></div><br></div>