fix(nav2): improve mkmini gazebo steering simulation
This commit is contained in:
@@ -220,21 +220,33 @@ def create_mkmini_world(gazebo_dir):
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
# The MKMini lidar is centered at 0.52 m. Raise the original 0.5 m white
|
||||
# pillars so they remain observable obstacles instead of falling below the
|
||||
# scan plane.
|
||||
for element in (*model.findall('.//collision'), *model.findall('.//visual')):
|
||||
cylinder = element.find('./geometry/cylinder')
|
||||
if cylinder is None:
|
||||
continue
|
||||
if cylinder.findtext('radius') != '0.15' or cylinder.findtext('length') != '0.5':
|
||||
continue
|
||||
cylinder.find('length').text = '1.2'
|
||||
pose = element.find('pose')
|
||||
if pose is None:
|
||||
continue
|
||||
values = pose.text.split()
|
||||
if len(values) == 6:
|
||||
# Keep only the centre post from TurtleBot3 World's 3x3 white-pillar grid.
|
||||
# This is applied to the generated MKMini world only; Burger keeps the
|
||||
# original obstacle layout. Remove both visual and collision shapes so the
|
||||
# Gazebo scene and Nav2 costmap describe the same space.
|
||||
for link in model.findall('.//link'):
|
||||
for element in list(link):
|
||||
if element.tag not in {'collision', 'visual'}:
|
||||
continue
|
||||
cylinder = element.find('./geometry/cylinder')
|
||||
if cylinder is None:
|
||||
continue
|
||||
if cylinder.findtext('radius') != '0.15' or cylinder.findtext('length') != '0.5':
|
||||
continue
|
||||
pose = element.find('pose')
|
||||
values = pose.text.split() if pose is not None and pose.text else []
|
||||
if len(values) != 6:
|
||||
continue
|
||||
try:
|
||||
x, y = float(values[0]), float(values[1])
|
||||
except ValueError:
|
||||
continue
|
||||
if abs(x) > 1e-6 or abs(y) > 1e-6:
|
||||
link.remove(element)
|
||||
continue
|
||||
# The MKMini lidar is centered at 0.52 m. Raise the remaining
|
||||
# centre post so it stays observable instead of below the scan.
|
||||
cylinder.find('length').text = '1.2'
|
||||
values[2] = '0.6'
|
||||
pose.text = ' '.join(values)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user