From 71b8cd7dc044f57596bcd673eabbf9de3333d33a Mon Sep 17 00:00:00 2001 From: chyoo Date: Thu, 6 Aug 2026 09:12:07 +0900 Subject: [PATCH] fix: refine indoor mailbox collision --- .../launch/simulator.launch.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/nav2_turtlebot_simulator/launch/simulator.launch.py b/src/nav2_turtlebot_simulator/launch/simulator.launch.py index 480b007..9c2e5d8 100644 --- a/src/nav2_turtlebot_simulator/launch/simulator.launch.py +++ b/src/nav2_turtlebot_simulator/launch/simulator.launch.py @@ -54,6 +54,38 @@ def replace_house_visual_meshes_with_boxes(house_model): visual_pose = ET.SubElement(visual, 'pose') visual_pose.text = pose + # The house references Gazebo's external mailbox asset, which is not shipped + # with the module image. Replace both its visual and collision with the same + # local box so it remains visible and navigable in the flat indoor world. + mailbox = next( + (model for model in house_model.findall('.//model') if model.attrib.get('name') == 'Mailbox'), + None, + ) + if mailbox is None: + return + + mailbox_link = mailbox.find('link') + if mailbox_link is None: + return + + for element in list(mailbox_link): + if element.tag in {'visual', 'collision'}: + mailbox_link.remove(element) + + # The laser is roughly 17 cm above the ground. Keep the mailbox body above + # that plane and retain the single thin support from mailbox.dae. + mailbox_parts = ( + ('body', '0.133 0.355 0.29', '0.002 0.017 0.922 0 0 0'), + ('leg', '0.043 0.044 0.803', '0.000 0.012 0.401 0 0 0'), + ) + for element_type in ('collision', 'visual'): + for name, size, pose in mailbox_parts: + element = ET.SubElement(mailbox_link, element_type, name=f'mailbox_{element_type}_{name}') + ET.SubElement(element, 'pose').text = pose + geometry = ET.SubElement(element, 'geometry') + box = ET.SubElement(geometry, 'box') + ET.SubElement(box, 'size').text = size + def create_flat_house_world(gazebo_dir): """Create a texture-free house copy with box-rendered furniture."""