ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

collada dae resource not updated in rviz

asked 2011-11-09 03:19:58 -0500

Miguel Riem de Oliveira gravatar image

Hello

I am using colladadom to produce a dae file of a simple 3D structure (a simple polygon with a color)

Then I send a visualization_msgs::Marker to rviz of the type MESH_RESOURCE pointing to that dae file.

I all works great, the polygon is drawn on rviz.

My problem is that I want to be able to change this 3D structure in real time (no so fast, but to change it in runtime)

So what I do is rewrite a the dae file and then send a new visualization_msgs::Marker message to rviz so that it draws the new polygon (the new rewritten dae file)

The problem is that after the first draw, which goes well, rviz seems never to update the marker again, even if I change the dae file to a different polygon the old one is drawn.

I was thinking and it could be one of the following things:

  1. the header.stamp of the marker msgs: I checked and the new polygon marker message has a newer timestamp, so it should override the old polygon.
  2. the action field in the msg. I tried ADD and MODIFY (although I think now they are the same). Nothing changed.
  3. the id field of the marker_msg. I was wondering if it was a problem of receiving always the same id. I tried changing this and nothing happens.

If the problem is not related to any of the previous points, I was wondering if rviz has some behaviour of loading the collada files just the first time. Or could it have something to do with the resource retriever?

Thanks for the help

Miguel Oliveira

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2011-11-09 03:51:03 -0500

Miguel Riem de Oliveira gravatar image

updated 2011-11-09 04:13:50 -0500

I think I found the problem

In the rviz code, at /rviz/default_plugin/markers/mesh_resource_marker.cpp

line 101,

there is something like this

void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message) { ROS_ASSERT(new_message->type == visualization_msgs::Marker::MESH_RESOURCE);

scene_node_->setVisible(false);

if (!entity_ || old_message->mesh_resource != new_message->mesh_resource)
{ //DO THE WHOLE PROCESSING HERE }

(...)

I think that for efficiency reasons the rviz author decided not to reload a dae file, and that if test checks just that.

I am able to solve the problem using two different files and alternating between both.

The problem now is that the rviz also loads the mesh once. In rviz package

rviz/src/rviz/mesh_loader.cpp, line 532 the following code

if(Ogre::MeshManager::getSingleton().resourceExists(resource_path))
{ return Ogre::MeshManager::getSingleton().getByName(resource_path); } else { //LOAD THE MESH HERE NORMALY

Also prevents a previously loaded file to be reloaded. Is there any way I can force rviz to reload files?

Thank you Miguel Oliveira

edit flag offensive delete link more
1

answered 2011-11-16 03:50:00 -0500

hersh gravatar image

Something like this has come up before, the desire to essentially send a "Mesh Message", which has not yet been written.

To work around it with rviz as is, you are almost there. You will need to actually write a brand new file name for each new mesh. Then MeshManager::getByName() will never find your new file to be a duplicate and will always load the new mesh.

Whatever node is publishing the Marker messages and writing the mesh files can also delete each old file. You might leave a buffer of a few mesh files in case rviz gets behind.

This is probably not a very efficient solution, but you said it's not happening all that fast.

Another way to handle it is to use the TRIANGLE_LIST marker type. You would need to write something to pull the triangles out of the mesh, and you couldn't texture it, just set the color of each triangle.

Longer term, it probably makes sense to implement a MeshMarker message for rviz which actually transmits the mesh data right in the message, and thus updates the shape every time.

edit flag offensive delete link more

Comments

Ok I'll do the delete the old one and create a new file in every iteration, as you suggest. Thanks for the repply :)
Miguel Riem de Oliveira gravatar image Miguel Riem de Oliveira  ( 2011-11-16 06:25:45 -0500 )edit
0

answered 2023-01-03 13:44:42 -0500

Combinacijus gravatar image

updated 2023-01-04 14:27:17 -0500

Pressing Reset in RViz bottom left corner (and probably republishing marker) seems to the job

You can test it by renaming mesh file and checking if after reset mesh disappears and after renaming back and reset reappears

EDIT 1: It seems to only work for geometry. Material colors does not update

image description

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-11-09 03:19:58 -0500

Seen: 1,290 times

Last updated: Jan 04 '23