Skip to content
Snippets Groups Projects
Commit c99e0e48 authored by Ugo Albanese's avatar Ugo Albanese
Browse files

Merged in fix-bodyModel-precedence (pull request #138)

[NRRPLT-7911] The SDF file in a BIBI bodyModel tag has precedence over the SDF of a template model.

Approved-by: erdisayar
Approved-by: Vahid Zolfaghari
parent ba7d8217
Branches
Tags
No related merge requests found
...@@ -168,29 +168,27 @@ class GazeboSimulationAssembly(SimulationAssembly): # pragma: no cover ...@@ -168,29 +168,27 @@ class GazeboSimulationAssembly(SimulationAssembly): # pragma: no cover
For each robot model in sim_config checks that the model sdf file exists in SDFFileAbsPath For each robot model in sim_config checks that the model sdf file exists in SDFFileAbsPath
:return: - :return: -
""" """
# TODO: the logic implemented here is unnecessarily complex. The model sdf file should
# exists at SDFFileAbsPath as set in bibi file or fail. Differences in custom and public
# models behavior is also weird. Eg. 'model' attribute is ignored for public models and
# 'SDFFileAbsPath' ignored for custom models. Not a nice solution.
# pylint: disable=too-many-branches
if not self.sim_config.robot_models: if not self.sim_config.robot_models:
return return
for robot in self.sim_config.robot_models.values(): for robot in self.sim_config.robot_models.values():
robot_handler = RobotCallHandler(self) robot_handler = RobotCallHandler(self)
if robot.model:
status, ret = robot_handler.prepare_robot(robot.model)
if not status:
raise Exception("Could not prepare custom robot {err}".format(err=ret))
sdf_abs_path = ret
else: # model files are inside the experiment folder
sdf_abs_path = SimUtil.find_file_in_paths( sdf_abs_path = SimUtil.find_file_in_paths(
robot.SDFFileAbsPath, robot.SDFFileAbsPath,
[os.path.join(self.sim_dir, robot.id)] [os.path.join(self.sim_dir, robot.id)]
) )
# By default, model assets are assumed to be in the experiment folder.
# If the model attribute of bodyModel is specified,
# assets must be fetched from the template Models instead.
if robot.model:
status, ret = robot_handler.prepare_robot(robot.model)
if not status:
raise Exception("Could not prepare custom robot {err}".format(err=ret))
# if no SDF is specified in the BIBI's bodyModel tag
# use the SDF of the fetched model
sdf_abs_path = ret if not robot.SDFFileAbsPath else sdf_abs_path
# still couldn't find the SDF, abort! # still couldn't find the SDF, abort!
if not sdf_abs_path: if not sdf_abs_path:
raise Exception("Could not find robot file: {0}".format(robot.SDFFileAbsPath)) raise Exception("Could not find robot file: {0}".format(robot.SDFFileAbsPath))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment