Converter of meshes from STL to SDF format.
Takes as input a mesh file (STL) and generates the corresponding .SDF file for importing the model into Gazebo.
It uses the TriMesh library.
It also allows to resize a mesh.
# Usage
python stl2sdf.py <FILENAME> <SCALING_FACTOR>
# Example:
python stl2sdf.py mesh.stl 1.5
The SDF files contain hard-coded references to STL meshes, which means STL meshes should stay in their directory. Otherwise, you have to re-generate the SDF files.
# Generate the SDF description file for your mesh (without re-sizing it)
python stl2sdf.py mesh.stl 1.0
# Launch Gazebo:
roslaunch gazebo_ros empty_world.launch gui:=true
# Spawn the object inside Gazebo
rosrun gazebo_ros spawn_model -sdf -file /path/to/sdf/file/mesh.sdf -model myModelName
To install Trimesh, open a terminal and write:
pip install --user trimesh