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
No related branches found
No related tags found
No related merge requests found
...@@ -168,28 +168,26 @@ class GazeboSimulationAssembly(SimulationAssembly): # pragma: no cover ...@@ -168,28 +168,26 @@ 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)
sdf_abs_path = SimUtil.find_file_in_paths(
robot.SDFFileAbsPath,
[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: if robot.model:
status, ret = robot_handler.prepare_robot(robot.model) status, ret = robot_handler.prepare_robot(robot.model)
if not status: if not status:
raise Exception("Could not prepare custom robot {err}".format(err=ret)) raise Exception("Could not prepare custom robot {err}".format(err=ret))
sdf_abs_path = ret # if no SDF is specified in the BIBI's bodyModel tag
else: # model files are inside the experiment folder # use the SDF of the fetched model
sdf_abs_path = SimUtil.find_file_in_paths( sdf_abs_path = ret if not robot.SDFFileAbsPath else sdf_abs_path
robot.SDFFileAbsPath,
[os.path.join(self.sim_dir, robot.id)]
)
# still couldn't find the SDF, abort! # still couldn't find the SDF, abort!
if not sdf_abs_path: if not sdf_abs_path:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment