0
$\begingroup$

Rosanswers logo

Hello,

I am new to ROS and I am having problems importing a 3D Model of a formula car (COLLADA file) i got from 3D warehouse to RVIZ. This is the COLLADA file:

FILE

This is my code. It is working for a simple cube as marker. Now I wanted to change the cube to this formula car using the marker type "visualization_msgs::Marker::MESH_RESOURCE"

visualization_msgs::Marker marker;
marker.header.frame_id = "/my_frame";
marker.header.stamp = ros::Time::now();
marker.ns = "myns";
marker.id = k+current_cone_pos.left.x.size()+current_cone_pos.right.x.size()+1;
marker.type = visualization_msgs::Marker::MESH_RESOURCE;
marker.action = visualization_msgs::Marker::ADD;
marker.mesh_resource = "file://models/v1-01/model.dae";
marker.pose.position.x = 0;
marker.pose.position.y = 0;
marker.pose.position.z = 0;
marker.pose.orientation.x = 0.0;
marker.pose.orientation.y = 0.0;
marker.pose.orientation.z = 0.0;
marker.pose.orientation.w = 1.0;
marker.scale.x = 0.1;
marker.scale.y = 0.5;
marker.scale.z = 0.5;
marker.color.b = 0.0f;
marker.color.g = 0.0f;
marker.color.r = 1.0;
marker.color.a = 1.0;
marker.lifetime = ros::Duration();
visualizer_.publish(marker);

The error that i get using "rosrun rviz rviz" while running my C++ Node is:

Could not load resource [file://models/v1-01/model.dae]: Unable to open file "file://models/v1-01/model.dae".

Thank you guys for your support!

Greetings, Alex


Originally posted by AlexROS on ROS Answers with karma: 11 on 2017-07-27

Post score: 1


Original comments

Comment by David_ROS on 2021-11-24:
Hi, Alex, do you solved this problem?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

if models is a ROS package, then you should use package://, not file://.

if it's a directory somewhere on your filesystem, use an absolute path (ie: file:///path/to/where/models/is/..).

See the documentation for wiki/rviz/DisplayTypes/Marker - Mesh Resource which explains all of this.


Originally posted by gvdhoorn with karma: 86574 on 2017-07-28

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by AlexROS on 2017-07-28:
Still not working.

I have tried the absolute path with the following line of code:

marker.mesh_resource = "file://home/alex/catkin_ws/models/v1-01/model.dae";

It still does not work. Do i need any additional urdf file or so? Models ist just a file in which the model is stored, not a ros package

Comment by gvdhoorn on 2017-07-28:
Note the additional /: this may seem strange, but file:// (with two /) is the scheme, the path starts only after that. So for an absolute path, you need to have three consecutive forward slashes.

Comment by AlexROS on 2017-07-28:
Okay now the error has gone away. But the car is still not visible in rviz

Comment by gvdhoorn on 2017-07-28:
one thing to check: ROS uses meters for everything, so make sure your mesh is scaled to that as well (most exports from 3D modellers are in mm).

Comment by AlexROS on 2017-07-28:
I tried to set the scale parameters to 1000. But that still does not solve the problem. :-/ Did you have a look at the link of the formula car? Is the file format suitable? Do i need an urdf file maybe?

Comment by gvdhoorn on 2017-07-28:
Let's eliminate some variables here: try to get things to work with a very simple Collada file (a cube with a single colour). Once that works, we can look at the car model.

Comment by AlexROS on 2017-07-28:
It worked with this simple cube: [LINK] (https://3dwarehouse.sketchup.com/model/b3e0972ece48c304664cc17fe2c6413a/Yla-Eason-double-cube)

So maybe it is because of the texture that the car has. I tried to do this with the car:

marker.mesh_use_embedded_materials = true;

But it didnt help.

Comment by AndyZe on 2017-08-01:
Try installing Meshlab. Import the dae then export it as binary.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Based on the visualization_msgs markers of RViz I wrote a small package that makes it easy to load meshes into RViz as textured objects.

It simply loads all files which were put inside its meshes folder and publishes them to the visualization_marker topic. And even dynamically! When a new object is added to the folder, it appears (or is published) in RViz. If an object is deleted, it also disappears from the published models.

It also contains a launch file which just takes everything which is inside the meshes folder, opens up RViz with a suitable perspektive and visualizes the 3D files.

Just check it out here: https://github.com/vonunwerth/RVizMeshVisualizer

image description


Originally posted by vonunwerth with karma: 66 on 2022-08-20

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.