Skip to content

Commit 90691ac

Browse files
committed
Clean-up XType relations
1 parent 34a3699 commit 90691ac

File tree

6 files changed

+10
-340
lines changed

6 files changed

+10
-340
lines changed

doc/phobos.scripts.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ These can be used by simply calling them via the `phobos` command:
1212
Usage:
1313
phobos COMMAND ARGUMENTS
1414
Commands:
15-
assemble_smurfa Loads a SMURFS/SMURFA file and exports the urdf(s)/smurf of the assembly.
16-
assemble_xtype Assemble the given model to a urdf.
17-
check_hyrodyn Checks whether the model can be loaded in Hyrodyn.
18-
check_meshes Checks whether all meshes are available.
19-
convert Converts the given input robot file to SDF/URDF/PDF/SMURF.
20-
generate_xtype Creates the xtype database entry for the given model repository
21-
preprocess_cad_export Preprocess CAD->URDF exports to use with pipeline.
22-
run_pipeline Process simulation models automatically.
23-
smurfs_in_pybullet Loads a "smurfs" file in pyBullet.
24-
test_model Test the latest model using a CI-pipeline.
15+
assemble_smurfa Loads a SMURFS/SMURFA file and exports the urdf(s)/smurf of the assembly.
16+
check_meshes Checks whether all meshes are available.
17+
convert Converts the given input robot file to SDF/URDF/PDF/THUMBNAIL/SMURF/SMURFA/SMURFS.
18+
preprocess_cad_export Preprocess CAD->URDF exports to use with pipeline.
19+
reduce_mesh Reduces the given mesh's number of vertices by the given factor, while trying to maintain the geometry as similar as possible.
20+
run_pipeline Process simulation models automatically.
21+
setup_git Sets-up a git repository for a simulation/control model.
22+
smurfs_in_pybullet Loads a "smurfs" file in pyBullet.
23+
test_model Test the latest model using a CI-pipeline.
24+
check_hyrodyn Checks whether the model can be loaded in Hyrodyn.
2525

manifest.xml

-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
<depend package="opengl" optional="1"/>
4444
<!-- Optional because in most cases it's easier to install it manually-->
4545
<depend package="git-lfs" optional="1"/>
46-
<!-- Only for xtype models-->
47-
<depend package="representation/xtypes" optional="1"/>
48-
<depend package="database/xdbi" optional="1"/>
4946

5047
<keywords>
5148
<keyword>Simulation</keyword>

phobos/ci/base_model.py

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def __init__subclass__(self, configfile, pipeline, processed_model_exists=True):
3939
kwargs = {}
4040
if 'model' in self.cfg.keys():
4141
kwargs = self.cfg['model']
42-
# elif 'xtype_model' in self.cfg.keys():
43-
# kwargs = self.cfg['xtype_model']
4442
for (k, v) in kwargs.items():
4543
setattr(self, k, v)
4644
# check whether all necessary configurations are there

phobos/ci/pipeline.py

-185
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ def __init__(self, configfile, processed_model_exists, subclass=False):
102102
try:
103103
if list(cfg.keys())[0] == "model":
104104
self.models += [BaseModel(os.path.join(self.configdir, md), self, self.processed_model_exists)]
105-
# elif list(cfg.keys())[0] == "xtype_model":
106-
# self.models += [XTypeModel(os.path.join(self.configdir, md), self, self.processed_model_exists)]
107105
else:
108106
self.processing_failed[md[:-4]]["load"] = f"Skipping {md} as it is no valid model definition!\n"
109107
log.error(self.processing_failed[md[:-4]]["load"])
@@ -728,186 +726,3 @@ def _get_model_failure_state(self, modelname):
728726
state += NA_TEST
729727
return state
730728

731-
732-
# # [TODO v2.1.0] use inheritance to remove redundant code
733-
# class XTypePipeline(yaml.YAMLObject):
734-
# def __init__(self, configfile, processed_model_exists, only_create=False):
735-
# self.processing_failed = {}
736-
# self.test_results = {}
737-
# self.configdir = os.path.dirname(configfile)
738-
# self.processed_model_exists = processed_model_exists
739-
# if not os.path.isfile(configfile):
740-
# raise Exception('{} not found!'.format(configfile))
741-
# self.configfile = configfile
742-
# kwargs = load_json(open(configfile, 'r'))['assemble']
743-
#
744-
# self.modeltypes = {"xtype": kwargs}
745-
#
746-
# for (k, v) in kwargs.items():
747-
# setattr(self, k, v)
748-
#
749-
# self.root = os.getcwd()
750-
# print("Working from", self.root)
751-
# self.git_rev = git.revision(os.path.abspath(self.configdir))
752-
# self.temp_dir = os.path.join(self.root, "temp")
753-
# self.faillog = os.path.join(self.temp_dir, "failures.txt")
754-
# self.test_protocol = os.path.join(self.temp_dir, "test_protocol.txt")
755-
# if os.path.isfile(self.faillog) and processed_model_exists:
756-
# with open(self.faillog, "r") as f:
757-
# self.processing_failed = load_json(f.read())
758-
#
759-
# self.meshespath = self.meshes[self.output_mesh_format]
760-
#
761-
# print("Finished reading config", configfile)
762-
#
763-
# self.model = None
764-
# imported_meshes = []
765-
#
766-
# self.processing_failed = {"load": "N/A", "process": "N/A", "test": "N/A", "deploy": "N/A"}
767-
# try:
768-
# load_json(open(configfile, "r").read())["xtype_model"]
769-
# except KeyError as e:
770-
# self.processing_failed["load"] = ''.join(traceback.format_exception(None, e, e.__traceback__))
771-
# log.error("Could not load model config!")
772-
# traceback.print_exc()
773-
# fstate = self._get_model_failure_state()
774-
# self.processing_failed["load"] = ""
775-
# if bool(fstate & (F_PROC | NA_PROC)) and processed_model_exists:
776-
# log.warning("Model was not successfully processed")
777-
# self.processing_failed["load"] += \
778-
# "Model was not successfully processed!\n"
779-
# elif bool(fstate & (F_PROC | NA_PROC)):
780-
# # reset processing error
781-
# self.processing_failed["process"] = "N/A"
782-
# try:
783-
# self.model = XTypeModel(configfile, self, self.processed_model_exists, only_create=only_create)
784-
# self.model.typedef["meshespath"] = self.meshespath
785-
# for m in self.model.get_input_meshes():
786-
# for m2 in imported_meshes:
787-
# if os.path.basename(m) == os.path.basename(m2) and os.path.dirname(m) != os.path.dirname(m):
788-
# raise ("You can not import two different meshes with the same name!\n"
789-
# "In the model you tried to import:\n {} but\n {} already exists!".format(m, m2))
790-
# imported_meshes += self.model.get_input_meshes()
791-
# self.processing_failed["load"] = "Good"
792-
# except Exception as e:
793-
# self.processing_failed["load"] += "Loading failed with the following error:" + ''.join(
794-
# traceback.format_exception(None, e, e.__traceback__))
795-
# log.error(self.processing_failed["load"])
796-
# if os.path.exists(os.path.join(self.temp_dir)):
797-
# with open(self.faillog, "w") as f:
798-
# f.write(dump_json(self.processing_failed, default_flow_style=False))
799-
#
800-
# def _get_model_failure_state(self):
801-
# state = 0
802-
# if not self.processing_failed["load"].upper().startswith("GOOD") and\
803-
# not self.processing_failed["load"].upper().startswith("N/A"):
804-
# state += F_LOAD
805-
# if not self.processing_failed["process"].upper().startswith("GOOD") and\
806-
# not self.processing_failed["process"].upper().startswith("N/A"):
807-
# state += F_PROC
808-
# if not self.processing_failed["test"].upper().startswith("GOOD") and\
809-
# not self.processing_failed["test"].upper().startswith("N/A"):
810-
# state += F_TEST
811-
# if not self.processing_failed["deploy"].upper().startswith("GOOD") and\
812-
# not self.processing_failed["deploy"].upper().startswith("N/A"):
813-
# state += F_DEPL
814-
# if self.processing_failed["load"].upper().startswith("N/A"):
815-
# state += NA_LOAD
816-
# if self.processing_failed["process"].upper().startswith("N/A"):
817-
# state += NA_PROC
818-
# if self.processing_failed["test"].upper().startswith("N/A"):
819-
# state += NA_TEST
820-
# if self.processing_failed["deploy"].upper().startswith("N/A"):
821-
# state += NA_DEPL
822-
# return state
823-
#
824-
# def has_failure(self):
825-
# return self._get_model_failure_state() & (F_LOAD | F_PROC | F_TEST | F_DEPL)
826-
#
827-
# def get_coverage(self, phases=None):
828-
# if phases is None:
829-
# phases = []
830-
# if len(phases) == 0:
831-
# phases = ["process", "test", "deploy"]
832-
# log = load_json(open(self.faillog, "r").read())
833-
# all_models = float(len(log.keys()))
834-
# fails = 0.0
835-
# all_models *= len(phases)
836-
# for p in phases:
837-
# fails += not log[p].upper().startswith("GOOD")
838-
# return 1 - fails / all_models
839-
#
840-
# def print_fail_log(self, file=sys.stdout):
841-
# log = load_json(open(self.faillog, "r").read())
842-
# print("\nPipeline Report:\n---------------------", file=file)
843-
# report = log
844-
# order_val = ["load", "process", "test", "deploy"]
845-
# if len(report) == 0:
846-
# print("Nothing done that could be reported!", file=file)
847-
# print(self.model.modelname + ":", file=file)
848-
# values = [(k, v) for k, v in report.items()]
849-
# values = sorted(values, key=lambda x: order_val.index(x[0]))
850-
# for v in values:
851-
# print(" " + v[0] + ": \t",
852-
# str(v[1]) if v[1].upper().startswith("GOOD") or v[1].upper().startswith("N/A") else "Error",
853-
# file=file)
854-
# if not v[1].upper().startswith("GOOD") and not v[1].upper().startswith("N/A"):
855-
# for line in v[1].split("\n"):
856-
# print(" " + line, file=file)
857-
#
858-
# def process_models(self):
859-
# # delete the temp_dir if there is already one
860-
# misc.recreate_dir(self, self.temp_dir)
861-
# with open(self.faillog, "w") as f:
862-
# f.write(dump_json(self.processing_failed, default_flow_style=False))
863-
#
864-
# # create the central mesh folders
865-
# misc.create_dir(self, os.path.join(self.temp_dir, self.meshespath))
866-
# if hasattr(self, "also_export_bobj") and self.also_export_bobj is True:
867-
# misc.create_dir(self, os.path.join(self.temp_dir, self.meshes["bobj"]))
868-
# if hasattr(self, "export_kccd") and self.export_kccd:
869-
# misc.create_dir(self, os.path.join(self.temp_dir, self.meshes["iv"]))
870-
# log.info("\nProcessing model...")
871-
# if self._get_model_failure_state() & (F_LOAD | NA_LOAD):
872-
# self.processing_failed["process"] = "Skipping as it model definition file wasn't loaded successfully!"
873-
# log.warning(self.processing_failed["process"])
874-
# else:
875-
# try:
876-
# self.model.process()
877-
# self.model.export()
878-
# os.remove(os.path.join(self.model.exportdir, self.model.typedef["meshespath"]))
879-
# os.rename(
880-
# os.path.join(self.temp_dir, self.model.typedef["meshespath"]),
881-
# os.path.join(self.model.exportdir, self.model.typedef["meshespath"]))
882-
# if len(os.listdir(os.path.dirname(os.path.join(self.temp_dir, self.model.typedef["meshespath"])))) == 0:
883-
# os.removedirs(os.path.dirname(os.path.join(self.temp_dir, self.model.typedef["meshespath"])))
884-
# if self.model.typedef["also_export_bobj"] is True:
885-
# os.remove(os.path.join(self.model.exportdir, self.meshes["bobj"]))
886-
# os.rename(
887-
# os.path.join(self.temp_dir, self.meshes["bobj"]),
888-
# os.path.join(self.model.exportdir, self.meshes["bobj"]))
889-
# if len(os.listdir(os.path.dirname(os.path.join(self.temp_dir, self.meshes["bobj"])))) == 0:
890-
# os.removedirs(os.path.dirname(os.path.join(self.temp_dir, self.meshes["bobj"])))
891-
# if hasattr(self.model, "export_kccd") and self.model.export_kccd:
892-
# os.remove(os.path.join(self.model.exportdir, self.meshes["iv"]))
893-
# os.rename(
894-
# os.path.join(self.temp_dir, self.meshes["iv"]),
895-
# os.path.join(self.model.exportdir, self.meshes["iv"]))
896-
# if len(os.listdir(os.path.dirname(os.path.join(self.temp_dir, self.meshes["iv"])))) == 0:
897-
# os.removedirs(os.path.dirname(os.path.join(self.temp_dir, self.meshes["iv"])))
898-
# self.processing_failed["process"] = "Good"
899-
# except Exception as e:
900-
# log.error(f"\nFailed processing model with the following error and skipped to next:\n {e}")
901-
# self.processing_failed["process"] = ''.join(traceback.format_exception(None, e, e.__traceback__))
902-
# traceback.print_exc()
903-
# with open(self.faillog, "w") as f:
904-
# f.write(dump_json(self.processing_failed, default_flow_style=False))
905-
#
906-
# def test_models(self):
907-
# raise NotImplementedError
908-
#
909-
# def deploy_models(self):
910-
# raise NotImplementedError
911-
#
912-
# def relpath(self, path):
913-
# return os.path.relpath(path, self.root)

phobos/data/assembly_config.yml.in

-131
This file was deleted.

phobos/defs.py

-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@
4141
except ImportError:
4242
log.info("Pybullet tests not available.")
4343

44-
XDBI_AVAILABLE = False
45-
try:
46-
import xtypes_py
47-
import xdbi_py
48-
XDBI_AVAILABLE = True
49-
log.info("XDBI available.")
50-
except ImportError:
51-
log.info("XDBI not available.")
52-
5344

5445
def dump_json(obj, **kwargs):
5546
import json

0 commit comments

Comments
 (0)