Files
wall_reflector_detection_ac…/sim/gen_wall_models.py
duongtd b5da961449 feat(sim): Gazebo wall model, detection sweep and evaluation scripts
- sim/models/wall_reflector_pair: wall with two 3 cm strips 9 cm apart
  (laser_retro 2000 on the strips, 0 on the wall), generated by
  gen_wall_models.py; spawn_wall_reflector.launch places it.
- sim/eval_wall_reflector.py: compares the published marker/target with the
  Gazebo ground truth, read from the handler success log because the nav
  core TF never reaches ROS; --align-by-robot when map != Gazebo world.
- sim/sweep_wall_detection.py: places the wall at several distances and
  angles behind the robot, sends DetectWallReflectors, writes a CSV and
  dumps the scan of every failed case.
- Handler success log now prints marker, target and frame (debug/state).
- Install sim/ in both catkin and standalone builds.
2026-11-12 13:44:16 +07:00

63 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Sinh model SIM-ONLY; các tọa độ đều trong frame model."""
from pathlib import Path
MODEL_DIR = Path(__file__).resolve().parent / 'models' / 'wall_reflector_pair'
WALL_FACE_X = -0.050
TAPE_FACE_X = -0.052
# Dải rộng 0.03 m, tâm cách 0.09 m: kích thước người dùng đang thử ngày 12/11/2026.
TAPE_WIDTH = 0.03
TAPE_CENTRES_Y = (-0.045, 0.045)
def main():
MODEL_DIR.mkdir(parents=True, exist_ok=True)
config = '''<?xml version="1.0"?>
<model><name>wall_reflector_pair</name><version>1.0</version>
<sdf version="1.6">model.sdf</sdf>
<description>SIM-ONLY: wall with two reflective tape strips.</description>
</model>
'''
parts = []
for index, centre_y in enumerate(TAPE_CENTRES_Y):
parts.append(f''' <collision name="tape_{index}_collision">
<pose>-0.051 {centre_y} 0.20 0 0 0</pose>
<geometry><box><size>0.002 {TAPE_WIDTH} 0.20</size></box></geometry>
<laser_retro>2000</laser_retro>
</collision>
<visual name="tape_{index}_visual">
<pose>-0.051 {centre_y} 0.20 0 0 0</pose>
<geometry><box><size>0.002 {TAPE_WIDTH} 0.20</size></box></geometry>
<material><ambient>1 1 1 1</ambient><diffuse>1 1 1 1</diffuse></material>
</visual>''')
sdf = '''<?xml version="1.0"?>
<sdf version="1.6">
<model name="wall_reflector_pair">
<static>true</static>
<link name="wall">
<collision name="wall_collision">
<pose>0 0 0.30 0 0 0</pose>
<geometry><box><size>0.10 2.0 0.60</size></box></geometry>
<laser_retro>0</laser_retro>
</collision>
<visual name="wall_visual">
<pose>0 0 0.30 0 0 0</pose>
<geometry><box><size>0.10 2.0 0.60</size></box></geometry>
<material><ambient>0.35 0.35 0.35 1</ambient><diffuse>0.35 0.35 0.35 1</diffuse></material>
</visual>
''' + '\n'.join(parts) + '''
</link>
</model>
</sdf>
'''
(MODEL_DIR / 'model.config').write_text(config, encoding='utf-8')
(MODEL_DIR / 'model.sdf').write_text(sdf, encoding='utf-8')
print(f'Mặt tường dùng làm ground truth: x={WALL_FACE_X:.3f} m')
print(f'Mặt tape: x={TAPE_FACE_X:.3f} m; tâm tape (x,y,z) [m]:')
for centre_y in TAPE_CENTRES_Y:
print(f' ({TAPE_FACE_X:.3f}, {centre_y:.3f}, 0.200)')
if __name__ == '__main__':
main()