How to import PLY/PCD to Gazebo world for simulation?
robot-mh opened this issue · 2 comments
RT
I'm not sure if you can import them directly, but you can convert the PLY file to a COLLADA, and include it as a mesh in the SDF file, for example. Here you have a simple example:
<?xml version="1.0" ?>
<sdf version="1.6">
<model name="<DAE filename>">
<pose>0 0 0 0 0 0</pose>
<link name="link">
<inertial>
<mass>100</mass>
</inertial>
<collision name="collision">
<geometry>
<mesh>
<uri>file://<DAE file path relative to the ROS package>/<DAE filename>.dae</uri>
<scale>1 1 1</scale>
</mesh>
</geometry>
<surface>
<friction>
<ode>
<mu>100</mu>
<mu2>50</mu2>
</ode>
</friction>
</surface>
</collision>
<visual name="visual">
<geometry>
<mesh>
<uri>file://<DAE file path relative to the ROS package>/<DAE filename>.dae</uri>
</mesh>
</geometry>
<meta>
<layer>1</layer>
</meta>
</visual>
</link>
<static>1</static>
</model>
</sdf>
I also share the steps to convert from PLY to COLLADA (.dae), keeping textures, with MeshLab in Ubuntu:
-
Install meshlab.
sudo apt update sudo apt install meshlab
-
Open meshlab.
-
'File' > 'Import Mesh (Ctrl+I)'.
-
'Filters' > 'Texture' > 'Parametrization: Trivial Per-Triangle'.
If you get 'Inter-Triangle border is too much', increase 'Texture Dimension (px)'. -
'Filters' > 'Texture' > 'Transfer Vertex Attributes to Texture (between 2 meshes)'.
Check: 'Assign Texture' and 'Fill Texture'. -
'Export Mesh As...'.
Select 'Collada File Format (*.dae)' and ensure to check 'TexCoord'.
I hope it helps!
Thanks for answering this question @iker-lluvia!
As there as been no activity since, I assume the issue is resolved. If not, feel free to open a new issue @robot-mh.