Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI bug fix #336

Open
wants to merge 7 commits into
base: phobos-ci-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions phobos/ci/model_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def __init__(self, new_model, compare_model=None):
self.old_hyrodyn = None
self.new_hml_test = get_load_report(self.new.robot.xmlfile, self.new.robot.submechanisms_file)
self.new_sm_hml_test = []
if len([x for x in self.new.robot.submodel_defs if not x["name"].startswith("#submech#")]) > 0:
if len([x for x in self.new.robot.submodel_defs if not x.startswith("#submech#")]) > 0:
hwiedPro marked this conversation as resolved.
Show resolved Hide resolved
sm_path = os.path.join(self.new.exportdir, "submodels")
for au in self.new.robot.submodel_defs:
if au["name"].startswith("#submech#"):
if au.startswith("#submech#"):
continue
self.new_sm_hml_test += [{
"name": au["name"],
"urdf": os.path.join(sm_path, au["name"], "urdf", au["name"] + ".urdf"),
"submech": os.path.normpath(os.path.join(sm_path, au["name"], "smurf", au["name"] + "_submechanisms.yml"))
"name": au,
"urdf": os.path.join(sm_path, au, "urdf", au + ".urdf"),
"submech": os.path.normpath(os.path.join(sm_path, au, "smurf", au + "_submechanisms.yml"))
}]
self.new_sm_hml_test[-1]["report"] = get_load_report(
self.new_sm_hml_test[-1]["urdf"],
Expand Down Expand Up @@ -267,10 +267,11 @@ def test_compare_amount_joints(self):
return len(self.new.robot.joints) == len(self.old.joints)

def test_load_in_pybullet(self):
if not PYBULLET_AVAILABLE:
if not check_pybullet_available():
log.warning('Pybullet not present')
return True
try:
import pybullet as pb
hwiedPro marked this conversation as resolved.
Show resolved Hide resolved
client = pb.connect(pb.DIRECT)
pb.loadURDF(os.path.join(self.new.robot.xmlfile), physicsClientId=client)
pb.disconnect(client)
Expand Down
19 changes: 13 additions & 6 deletions phobos/core/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def export_xml(self, outputdir=None, format="urdf", filename=None, float_fmt_dic

def export_smurf(self, outputdir=None, outputfile=None, robotfile=None,
check_submechs=True, with_submodel_defs=False,
with_meshes=True, mesh_format=None, additional_meshes=None, rel_mesh_pathes=None):
with_meshes=True, mesh_format=None, additional_meshes=None, rel_mesh_pathes=None,
submodels=None):
""" Export self and all annotations inside a given folder with structure
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a new feature, could you please open a separate PR for this?

"""
assert self.check_linkage()
Expand Down Expand Up @@ -355,9 +356,14 @@ def export_smurf(self, outputdir=None, outputfile=None, robotfile=None,
# submodel list
if with_submodel_defs and len(self.submodel_defs) > 0:
out_submodel_defs = {}
for name, definition in self.submodel_defs.items():
out_submodel_defs[name] = deepcopy(definition)
out_submodel_defs[name]["export_dir"] = os.path.relpath(out_submodel_defs[name]["export_dir"], smurf_dir)
if submodels is not None:
for name in submodels:
out_submodel_defs[name] = deepcopy(self.submodel_defs[name])
out_submodel_defs[name]["export_dir"] = os.path.relpath(out_submodel_defs[name]["export_dir"], smurf_dir)
else:
for name, definition in self.submodel_defs.items():
out_submodel_defs[name] = deepcopy(definition)
out_submodel_defs[name]["export_dir"] = os.path.relpath(out_submodel_defs[name]["export_dir"], smurf_dir)
with open(os.path.join(smurf_dir, "{}_submodels.yml".format(self.name.replace('/','_'))), "w+") as stream:
stream.write(dump_json({"submodels": out_submodel_defs}, default_style=False))
export_files.append(os.path.split(stream.name)[-1])
Expand Down Expand Up @@ -722,7 +728,7 @@ def export(self, outputdir, export_config=None, rel_mesh_pathes=None, ros_pkg_na
name=export["name"],
start=export.get("start", None),
stop=export.get("stop", None),
include_unstopped_branches=export.get("include_unstopped_branches", None),
include_unstopped_branches=export.get("include_unstopped_branches", False),
no_submechanisms=export.get("no_submechanisms", False),
abstract_model=export.get("abstract_model", False),
remove_fixed=export.get("remove_fixed", False),
Expand Down Expand Up @@ -785,7 +791,8 @@ def export(self, outputdir, export_config=None, rel_mesh_pathes=None, ros_pkg_na
robotfile=xml_file_in_smurf,
check_submechs=check_submechs,
with_submodel_defs=True,
with_meshes=False # has been done before
with_meshes=False, # has been done before
submodels=[filtered_item['name'] for filtered_item in filter(lambda item: item["type"] == "submodel", export_config)]
)
# export ros package files
if ros_pkg and not ros_pkg_later:
Expand Down
6 changes: 5 additions & 1 deletion phobos/io/xmlrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def __init__(self, name=None, version=None, links: List[representation.Link] = N
materials: List[representation.Material] = None,
transmissions: List[representation.Transmission] = None,
sensors=None, motors=None, plugins=None, root=None,
is_human=False, urdf_version=None, xmlfile=None, _xmlfile=None):
is_human=False, urdf_version=None, xmlfile=None, _xmlfile=None,
sensors_that_dont_belong_to_links_or_joints=None):
hwiedPro marked this conversation as resolved.
Show resolved Hide resolved
self._related_robot_instance = self
super().__init__()
self.joints = []
Expand Down Expand Up @@ -65,10 +66,13 @@ def __init__(self, name=None, version=None, links: List[representation.Link] = N
self.materials = materials if materials is not None else []
self.transmissions = transmissions if transmissions is not None else []
self.sensors = sensors if sensors is not None else []
if sensors_that_dont_belong_to_links_or_joints is not None:
self.sensors_that_dont_belong_to_links_or_joints = sensors_that_dont_belong_to_links_or_joints
self.motors = motors if motors is not None else []
if plugins is not None:
self.motors += [m for m in _plural(plugins) if isinstance(m, representation.Motor)]


if is_human:
self.annotate_as_human()

Expand Down