Skip to content

Commit

Permalink
fix after merge with devel: rem spawning plane object due to existing…
Browse files Browse the repository at this point in the history
… floor
  • Loading branch information
duc than committed May 28, 2024
1 parent aef78a2 commit ff5d61f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
79 changes: 39 additions & 40 deletions examples/ontology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825829.020764]: Ontology [http://www.ease-crc.org/ont/SOMA-HOME.owl#]'s name: SOMA-HOME has been loaded\n",
"[INFO] [1716825829.021493]: - main namespace: SOMA-HOME\n",
"[INFO] [1716825829.021986]: - loaded ontologies:\n",
"[INFO] [1716825829.022472]: http://www.ease-crc.org/ont/SOMA-HOME.owl#\n",
"[INFO] [1716825829.022944]: http://www.ease-crc.org/ont/DUL.owl#\n",
"[INFO] [1716825829.023414]: http://www.ease-crc.org/ont/SOMA.owl#\n"
"[INFO] [1716911825.215667]: Ontology [http://www.ease-crc.org/ont/SOMA-HOME.owl#]'s name: SOMA-HOME has been loaded\n",
"[INFO] [1716911825.216314]: - main namespace: SOMA-HOME\n",
"[INFO] [1716911825.216700]: - loaded ontologies:\n",
"[INFO] [1716911825.216988]: http://www.ease-crc.org/ont/SOMA-HOME.owl#\n",
"[INFO] [1716911825.217239]: http://www.ease-crc.org/ont/DUL.owl#\n",
"[INFO] [1716911825.217476]: http://www.ease-crc.org/ont/SOMA.owl#\n"
]
}
],
Expand Down Expand Up @@ -207,15 +207,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825829.147923]: -------------------\n",
"[INFO] [1716825829.148712]: SOMA.DesignedContainer <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716825829.149332]: Super classes: [DUL.DesignedArtifact, DUL.DesignedArtifact, SOMA.hasDisposition.some(SOMA.Containment), SOMA.hasDisposition.some(SOMA.Containment)]\n",
"[INFO] [1716825829.149857]: Ancestors: {SOMA.DesignedContainer, DUL.DesignedArtifact, DUL.Entity, DUL.PhysicalArtifact, DUL.Object, owl.Thing, DUL.PhysicalObject}\n",
"[INFO] [1716825829.150294]: Subclasses: [SOMA.Bottle, SOMA.Crockery, SOMA.Box, SOMA.Building, SOMA.Carafe, SOMA.Cupboard, SOMA.Dishwasher, SOMA.Dispenser, SOMA.Drawer, SOMA.Jar, SOMA.Pack, SOMA.Oven, SOMA.Shaker, SOMA.Refrigerator, SOMA.TrashContainer, SOMA-HOME.CustomContainerConcept, SOMA-HOME.AnotherCustomContainerConcept, SOMA-HOME.OntologyPlaceHolderObject, SOMA-HOME.OntologyLiquidHolderObject]\n",
"[INFO] [1716825829.150810]: Properties: [SOMA.hasDisposition, rdf-schema.label, rdf-schema.isDefinedBy, rdf-schema.comment]\n",
"[INFO] [1716825829.208589]: Instances: [SOMA-HOME.ontology_custom_container_concept, SOMA-HOME.another_custom_container_concept, SOMA-HOME.table_concept, SOMA-HOME.stool_concept, SOMA-HOME.shelf_concept, SOMA-HOME.egg_tray_concept, SOMA-HOME.cup_concept, SOMA-HOME.bowl_concept, SOMA-HOME.pitcher_concept]\n",
"[INFO] [1716825829.209226]: Direct Instances: []\n",
"[INFO] [1716825829.209784]: Inverse Restrictions: []\n",
"[INFO] [1716911825.339363]: -------------------\n",
"[INFO] [1716911825.340001]: SOMA.DesignedContainer <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716911825.340401]: Super classes: [DUL.DesignedArtifact, DUL.DesignedArtifact, SOMA.hasDisposition.some(SOMA.Containment), SOMA.hasDisposition.some(SOMA.Containment)]\n",
"[INFO] [1716911825.340892]: Ancestors: {SOMA.DesignedContainer, DUL.DesignedArtifact, owl.Thing, DUL.PhysicalArtifact, DUL.Object, DUL.Entity, DUL.PhysicalObject}\n",
"[INFO] [1716911825.341236]: Subclasses: [SOMA.Bottle, SOMA.Crockery, SOMA.Box, SOMA.Building, SOMA.Carafe, SOMA.Cupboard, SOMA.Dishwasher, SOMA.Dispenser, SOMA.Drawer, SOMA.Jar, SOMA.Pack, SOMA.Oven, SOMA.Shaker, SOMA.Refrigerator, SOMA.TrashContainer, SOMA-HOME.CustomContainerConcept, SOMA-HOME.AnotherCustomContainerConcept, SOMA-HOME.OntologyPlaceHolderObject, SOMA-HOME.OntologyLiquidHolderObject]\n",
"[INFO] [1716911825.341683]: Properties: [rdf-schema.isDefinedBy, rdf-schema.comment, SOMA.hasDisposition, rdf-schema.label]\n",
"[INFO] [1716911825.400233]: Instances: [SOMA-HOME.ontology_custom_container_concept, SOMA-HOME.another_custom_container_concept, SOMA-HOME.table_concept, SOMA-HOME.stool_concept, SOMA-HOME.shelf_concept, SOMA-HOME.egg_tray_concept, SOMA-HOME.cup_concept, SOMA-HOME.bowl_concept, SOMA-HOME.pitcher_concept]\n",
"[INFO] [1716911825.401077]: Direct Instances: []\n",
"[INFO] [1716911825.401662]: Inverse Restrictions: []\n",
"DUL.PhysicalObject\n",
"[SOMA.Affordance, SOMA.Disposition]\n"
]
Expand Down Expand Up @@ -337,15 +337,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825829.277244]: -------------------\n",
"[INFO] [1716825829.278241]: SOMA-HOME.CustomContainerConcept <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716825829.278839]: Super classes: [SOMA.DesignedContainer, owl.Thing]\n",
"[INFO] [1716825829.279422]: Ancestors: {SOMA.DesignedContainer, DUL.DesignedArtifact, DUL.Entity, DUL.PhysicalArtifact, SOMA-HOME.CustomContainerConcept, DUL.Object, owl.Thing, DUL.PhysicalObject}\n",
"[INFO] [1716825829.280004]: Subclasses: []\n",
"[INFO] [1716825829.280732]: Properties: []\n",
"[INFO] [1716825829.282059]: Instances: [SOMA-HOME.ontology_custom_container_concept]\n",
"[INFO] [1716825829.282827]: Direct Instances: [SOMA-HOME.ontology_custom_container_concept]\n",
"[INFO] [1716825829.283545]: Inverse Restrictions: []\n",
"[INFO] [1716911825.469569]: -------------------\n",
"[INFO] [1716911825.470353]: SOMA-HOME.CustomContainerConcept <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716911825.470808]: Super classes: [SOMA.DesignedContainer, owl.Thing]\n",
"[INFO] [1716911825.471233]: Ancestors: {SOMA-HOME.CustomContainerConcept, SOMA.DesignedContainer, DUL.DesignedArtifact, owl.Thing, DUL.PhysicalArtifact, DUL.Object, DUL.Entity, DUL.PhysicalObject}\n",
"[INFO] [1716911825.471560]: Subclasses: []\n",
"[INFO] [1716911825.471912]: Properties: []\n",
"[INFO] [1716911825.472469]: Instances: [SOMA-HOME.ontology_custom_container_concept]\n",
"[INFO] [1716911825.472774]: Direct Instances: [SOMA-HOME.ontology_custom_container_concept]\n",
"[INFO] [1716911825.473048]: Inverse Restrictions: []\n",
"custom_container_concept is SOMA-HOME.ontology_custom_container_concept: True\n"
]
}
Expand Down Expand Up @@ -385,15 +385,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825829.297186]: -------------------\n",
"[INFO] [1716825829.298009]: SOMA.Cup <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716825829.298485]: Super classes: [SOMA.Crockery, SOMA.hasPhysicalComponent.some(SOMA.DesignedHandle)]\n",
"[INFO] [1716825829.298891]: Ancestors: {SOMA.DesignedContainer, DUL.DesignedArtifact, DUL.Entity, DUL.PhysicalArtifact, SOMA.DesignedTool, DUL.Object, SOMA.Crockery, owl.Thing, SOMA.Tableware, DUL.PhysicalObject, SOMA.Cup}\n",
"[INFO] [1716825829.299265]: Subclasses: []\n",
"[INFO] [1716825829.299691]: Properties: [SOMA.hasPhysicalComponent, rdf-schema.isDefinedBy, rdf-schema.comment]\n",
"[INFO] [1716825829.300347]: Instances: []\n",
"[INFO] [1716825829.300837]: Direct Instances: []\n",
"[INFO] [1716825829.301184]: Inverse Restrictions: []\n"
"[INFO] [1716911825.485656]: -------------------\n",
"[INFO] [1716911825.486269]: SOMA.Cup <class 'owlready2.entity.ThingClass'>\n",
"[INFO] [1716911825.486616]: Super classes: [SOMA.Crockery, SOMA.hasPhysicalComponent.some(SOMA.DesignedHandle)]\n",
"[INFO] [1716911825.486935]: Ancestors: {SOMA.Crockery, SOMA.DesignedContainer, SOMA.Tableware, DUL.DesignedArtifact, SOMA.Cup, owl.Thing, DUL.PhysicalArtifact, SOMA.DesignedTool, DUL.Object, DUL.Entity, DUL.PhysicalObject}\n",
"[INFO] [1716911825.487221]: Subclasses: []\n",
"[INFO] [1716911825.487572]: Properties: [rdf-schema.isDefinedBy, rdf-schema.comment, SOMA.hasPhysicalComponent]\n",
"[INFO] [1716911825.488186]: Instances: []\n",
"[INFO] [1716911825.488503]: Direct Instances: []\n",
"[INFO] [1716911825.488776]: Inverse Restrictions: []\n"
]
}
],
Expand Down Expand Up @@ -793,7 +793,6 @@
"from pycram.designators.location_designator import *\n",
"\n",
"world = BulletWorld()\n",
"plane = Object(\"floor\", ObjectType.ENVIRONMENT, \"plane.urdf\")\n",
"kitchen = Object(\"kitchen\", ObjectType.ENVIRONMENT, \"kitchen.urdf\")\n",
"pr2 = Object(\"pr2\", ObjectType.ROBOT, \"pr2.urdf\")\n",
"kitchen_designator = ObjectDesignatorDescription(names=[\"kitchen\"])\n",
Expand Down Expand Up @@ -852,10 +851,11 @@
"output_type": "stream",
"text": [
"Unknown tag \"rgba_color\" in /robot[@name='milk_object']/link[@name='milk_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='cup_object']/link[@name='cup_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='milk_object']/link[@name='milk_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='cup_object']/link[@name='cup_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='bowl_object']/link[@name='bowl_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='cup_object']/link[@name='cup_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='bowl_object']/link[@name='bowl_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='pitcher_object']/link[@name='pitcher_main']/visual[1]/material[@name='white']\n"
]
}
Expand Down Expand Up @@ -895,7 +895,6 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Unknown tag \"rgba_color\" in /robot[@name='bowl_object']/link[@name='bowl_main']/visual[1]/material[@name='white']\n",
"Unknown tag \"rgba_color\" in /robot[@name='pitcher_object']/link[@name='pitcher_main']/visual[1]/material[@name='white']\n"
]
}
Expand Down Expand Up @@ -985,12 +984,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825831.876724]: Waiting for IK service: /pr2_left_arm_kinematics/get_ik\n",
"[INFO] [1716911828.077699]: Waiting for IK service: /pr2_left_arm_kinematics/get_ik\n",
"CostmapLocation.Location(pose=header: \n",
" seq: 0\n",
" stamp: \n",
" secs: 1716825831\n",
" nsecs: 857461929\n",
" secs: 1716911828\n",
" nsecs: 58246850\n",
" frame_id: \"map\"\n",
"pose: \n",
" position: \n",
Expand Down Expand Up @@ -1056,7 +1055,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[INFO] [1716825839.151754]: Ontologies have been saved to /home/ducthan/ontologies/NewSOMA-HOME.owl\n"
"[INFO] [1716911835.388276]: Ontologies have been saved to /home/ducthan/ontologies/NewSOMA-HOME.owl\n"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions src/pycram/ontology/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ class OntologyManager(object, metaclass=Singleton):
Singleton class as the adapter accessing data of an OWL ontology, largely based on owlready2.
"""

def __init__(self, main_ontology_iri: str = "", ontology_search_path: str = f"{Path.home()}/ontologies"):
def __init__(self, main_ontology_iri: str = "", ontology_search_path: str = ""):
"""
Create the singleton object of OntologyManager class
:param main_ontology_iri: Ontology IRI (Internationalized Resource Identifier), either a URL to a remote OWL file or the full name path of a local one
:param ontology_search_path: directory path from which a possibly existing ontology is searched. This is appended to `owlready2.onto_path`, a global variable containing a list of directories for searching local copies of ontologies (similarly to python `sys.path` for modules/packages).
:param ontology_search_path: directory path from which a possibly existing ontology is searched. This is appended to `owlready2.onto_path`, a global variable containing a list of directories for searching local copies of ontologies (similarly to python `sys.path` for modules/packages). If not specified, the path is "$HOME/ontologies"
"""
if owlready2:
if not ontology_search_path:
ontology_search_path = f"{Path.home()}/ontologies"
Path(ontology_search_path).mkdir(parents=True, exist_ok=True)
owlready2.onto_path.append(ontology_search_path)
else:
Expand Down

0 comments on commit ff5d61f

Please sign in to comment.