Automated Mesh Generation Toolchain & New SDF WorldsMaster#25
Automated Mesh Generation Toolchain & New SDF WorldsMaster#25thippeswammy wants to merge 28 commits intonaturerobots:mainfrom
Conversation
… path, need to fix the gap
… path, need to fix the gap, addin all the cmd and files required for running.
…cript - Added `--single-layer` flag to automatically configure density, flattening, and filtering for high-quality navigation meshes. - Implemented `clean_mesh_iterative` for robust topological repair (removing duplicates, degenerate faces, and non-manifold edges). - Added `--exclude` argument to filter out specific models (e.g., ceilings) by name. - Added `Stopwatch` class for precise timing of generation stages. - Improved memory management with explicit garbage collection and smart subdivision limits to prevent OOM errors. - Enhanced `find_lvr2_tool` to search more common workspace paths. - Exposed new parameters as ROS 2 launch arguments.
…h files, and refactor the mesh generation script for handeling the polyline geometry type.
…utilizing mesh and polyline geometries.
…, updating related launch configurations and documentation.
- Removed redundant scripts: sdf_to_ply_converter.py, generate_world_mesh.py - Updated generate_mesh_env.py: - Added --single-layer flag support - Implemented iterative mesh cleaning - Code cleanup and documentation - Updated SDF worlds (cleaned up models) - Updated README.md
|
Hi! First of all, thank you for contributing to MeshNav! I have a few questions to better understand your tool. I’m sure you can answer them more quickly than I can by reading the code.
|
|
Hi @amock , thank you for taking the time to review this and for the clear questions - happy to clarify.
This allows adjacent surfaces (e.g., ramps and ground) to become connected where possible, instead of remaining as isolated mesh buffers.
Internally, the tool uses
Without such a tool, users typically need to rely on external 3D engines such as Blender or Unity, which requires them to:
This workflow is time-consuming and error-prone, especially when the simulation environment changes frequently. This tool automates that synchronization by generating navigable PLY/HDF5 maps directly from the SDF world itself, ensuring that the simulation geometry and navigation map always stay consistent. Its value lies in:
In short, it lowers the barrier to entry for new users and provides a reproducible, end-to-end workflow for generating navigable meshes directly from Gazebo worlds. Happy to clarify or adapt the tool further based on feedback. |
|
Alright, thanks for the clarification. I checked the functionality, but a few things are still a bit confusing to me. Parking Garage MissingIt looks like the
Gazebo GUI DarkThe worlds that are already included seem to be rendered differently in the Gazebo GUI. Why is this relevant for your changes? More generally, why is it necessary to modify files that already exist at all? How to Execute Your ScriptI wanted to run your script to generate some meshes from sdf files I have, so I ran: python3 src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py src/mesh_navigation_tutorials/mesh_navigation_tutorials_sim/worlds/uneven_terrain.sdf --single-layerThis caused some errors. First, I had to manually install some Python dependencies. After that, I ran into an error that is likely caused by a different amock@amock-dell:~/meshnav_ws$ python3 src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py src/mesh_navigation_tutorials/mesh_navigation_tutorials_sim/worlds/uneven_terrain.sdf --single-layer
Auto-derived world_name: uneven_terrain
Input SDF: /home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials_sim/worlds/uneven_terrain.sdf
Maps output: /home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/maps
Models output: /home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials_sim/models/uneven_terrain
=== Stage 1: Extraction & Validation ===
[Stage 1: Extraction] START
Found 1 model(s) in SDF.
Processing Model: uneven_terrain_complete
/home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py:349: DeprecationWarning: Testing an element's truth value will raise an exception in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
if geom:
[Stage 1: Extraction] END - Duration: 0.0016s
Traceback (most recent call last):
File "/home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py", line 1427, in <module>
main()
File "/home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py", line 730, in main
mesh_data_list = extract_meshes_from_sdf(input_sdf, os.path.dirname(input_sdf), resolution=args.primitive_resolution, exclude_list=args.exclude)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py", line 414, in extract_meshes_from_sdf
m = create_high_res_primitive(geom, resolution=resolution)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/amock/meshnav_ws/src/mesh_navigation_tutorials/mesh_navigation_tutorials/launch/generate_mesh_env.py", line 241, in create_high_res_primitive
poly = trimesh.path.polygons.Polygon(points)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'trimesh.path' has no attribute 'polygons'Which system and setup are you using? I am using a pretty standard Ubuntu 24/Jazzy environment. Idea: Make a Standalone Package From Your ToolBefore trying to restore the previous state of the tutorials, I think it might not be a good idea to integrate this tool into My proposal would be:
If this works out and the tool becomes easy to use, I would be happy to add a reference in the documentation so that people can find it more easily. |
|
Thank you again for your guidance and detailed feedback. I wanted to let you know that I have now completely moved the tool into a standalone repository, as you suggested: I’ve also added a user guide that explains the purpose of the tool, basic usage, and input/output configuration. The aim was to keep it generic and easy to use, without tightly coupling it to mesh_navigation_tutorials. I’ve also taken your technical questions and the errors you encountered into account for the initial setup of this new package, particularly around dependencies and execution. |
… add corresponding entries to .gitignore.
Summary
This PR introduces a comprehensive toolchain to automate the generation of navigation meshes from Gazebo SDF world files. It streamlines the workflow for creating complex terrains for
mesh_navigation, allowing for direct conversion of SDF geometries (including primitives and includes) into high-quality PLY and H5 map files.Key Changes
1. New Tool:
generate_mesh_env.pyA new Python script located in
mesh_navigation_tutorials/launch/that handles the entire pipeline:<include>models and geometric primitives (Box, Cylinder, Sphere, Plane, Polyline).--single-layerflag that optimizes meshes for navigation by:.h5files usinglvr2tools if available.2. World Files
uneven_terrain.sdfanduneven_terrain_big.sdfto test and run the pipeline.3. Documentation
How to Test
Once you have cloned the repository, you can directly build and launch the simulation.
1. Build the Workspace
Rebuild the packages to ensure the new maps and models are installed correctly.
2. Launch the Simulation
Launch the tutorial to see the result.
Optional: Test Mesh Generation Tool
If you want to regenerate the mesh or test the tool manually: