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

Added better ontology interface. #223

Merged
merged 39 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ccd89c
[Ontology] Successfully removed old ontology. Started to work on bett…
tomsch420 Nov 21, 2024
123d192
[Ontology] BulletWorldTestCase now correctly interacts with individua…
tomsch420 Nov 21, 2024
f9d6fdc
[Ontology] Intermediate commit where changing the object type to conc…
tomsch420 Nov 21, 2024
a89e611
[Testing] Refactored Tests to be part of pycram and hence enable a cl…
tomsch420 Nov 22, 2024
86269e0
[Testing] Refactored test structure
tomsch420 Nov 22, 2024
2bd3604
[Testing] Refactored test structure
tomsch420 Nov 22, 2024
84e73ba
[ORM] ORM is updated to new ontology interface
tomsch420 Nov 22, 2024
7e29891
[ORM] Removed class without orm equivalent from tracking
tomsch420 Nov 22, 2024
ef3a46d
[CI] Added script for writing into the CI database
tomsch420 Nov 22, 2024
c257dc0
[Doc] Added script to locally test the notebooks
tomsch420 Nov 22, 2024
b9b84c8
[Doc] Added script to locally test the notebooks
tomsch420 Nov 22, 2024
62ca100
[Doc] Updated intro.md
tomsch420 Nov 22, 2024
e5a445e
[Doc] Updated action_designator.md
tomsch420 Nov 22, 2024
9f38f9a
[Doc] Updated bullet_world.md
tomsch420 Nov 22, 2024
f25a953
[Doc] Updated cram_plan_tutorial.md
tomsch420 Nov 22, 2024
36da3d1
[Doc] Updated language.md
tomsch420 Nov 22, 2024
80b9f73
[Doc] Updated local_transformer.md
tomsch420 Nov 22, 2024
2188188
[Doc] Updated location_designator.md
tomsch420 Nov 22, 2024
dd9dbb6
[Doc] Updated migrate_neems.md
tomsch420 Nov 22, 2024
ca18bb6
[Doc] Updated minimal_task_tree.md
tomsch420 Nov 22, 2024
1600d4d
[Doc] Updated motion_designator.md
tomsch420 Nov 22, 2024
d937151
[Doc] Updated orm_example.md
tomsch420 Nov 22, 2024
7aa5f6f
[Doc] Updated orm_querying_examples.md
tomsch420 Nov 22, 2024
b53576d
[Doc] Updated object_designator.md
tomsch420 Nov 22, 2024
4c2cb62
[Doc] Removed old ontology intro
tomsch420 Nov 22, 2024
5f34bed
[Doc] Added ontology doc
tomsch420 Nov 22, 2024
0db7261
[GitHub] Updated workflow
tomsch420 Nov 22, 2024
884396e
[Ontology] Fixed bug in removing of objects from worlds
tomsch420 Nov 26, 2024
0a37448
Merge remote-tracking branch 'pycram/dev' into dev
tomsch420 Nov 26, 2024
bf8bd7d
[Test] Fixed old import
tomsch420 Nov 26, 2024
43b9a1f
[Doc] More ontology documentation
tomsch420 Nov 26, 2024
741bd4b
[Crap] Ontology can now live without the manager.py
tomsch420 Nov 26, 2024
bd9242d
[Doc] Updated doc.
tomsch420 Nov 26, 2024
2a01a66
[Ontology] Every world instance in pycram has now its own ontology
tomsch420 Nov 27, 2024
687f3d1
[Doc] Increased performance of runtime
tomsch420 Nov 27, 2024
98e0376
[ObjectDesignator] Removed old ontology_concept_holders
tomsch420 Nov 27, 2024
d26f1fd
[Test] Moved designators to dedicated folder
tomsch420 Nov 27, 2024
06510a1
[Ontology] Ontological object designator now exists
tomsch420 Nov 27, 2024
d94547a
[Ontology] Updated doc
tomsch420 Nov 27, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/notebook-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ jobs:
run: |
source /opt/ros/overlay_ws/devel/setup.bash
roscd pycram/examples/tmp
treon --thread 1 -v --exclude=migrate_neems.ipynb
treon --thread 1 -v --exclude=migrate_neems.ipynb --exclude=improving_actions.ipynb
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ resources/cached/

# Example checkpoints
examples/.ipynb_checkpoints/
*/tmp/*
7 changes: 4 additions & 3 deletions examples/action_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose
import pycrap

world = BulletWorld(WorldMode.GUI)
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf", pose=Pose([1, 2, 0]))
apartmet = Object("apartment", ObjectType.ENVIRONMENT, "apartment.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([2.3, 2, 1.1]))
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf", pose=Pose([1, 2, 0]))
apartmet = Object("apartment", pycrap.Apartment, "apartment.urdf")
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([2.3, 2, 1.1]))
```

To move the robot we need to create a description and resolve it to an actual Designator. The description of navigation
Expand Down
7 changes: 4 additions & 3 deletions examples/bullet_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ First we need to import and create a BulletWorld.
from pycram.worlds.bullet_world import BulletWorld
from pycram.datastructures.pose import Pose
from pycram.datastructures.enums import ObjectType, WorldMode
import pycrap

world = BulletWorld(mode=WorldMode.GUI)
```
Expand All @@ -41,7 +42,7 @@ To spawn new things in the BulletWorld we need to import the Object class and cr
```python
from pycram.world_concepts.world_object import Object

milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([0, 0, 1]))
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([0, 0, 1]))
```

<!-- #region -->
Expand Down Expand Up @@ -91,7 +92,7 @@ parameter. Since attachments are bi-directional it doesn't matter on which Objec
First we need another Object

```python
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1, 0, 1]))
cereal = Object("cereal", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1, 0, 1]))
```

```python
Expand Down Expand Up @@ -119,7 +120,7 @@ which contain every link or joint as key and a unique id, used by PyBullet, as v
We will see this at the example of the PR2:

```python
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
print(pr2.links)
```

Expand Down
16 changes: 8 additions & 8 deletions examples/cram_plan_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ from pycram.world_concepts.world_object import Object
import anytree
import pycram.failures
import numpy as np
import pycrap

np.random.seed(4)

world = BulletWorld()
robot = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
robot = Object("pr2", pycrap.Robot, "pr2.urdf")
robot_desig = ObjectDesignatorDescription(names=['pr2']).resolve()
apartment = Object("apartment", "environment", "apartment.urdf", pose=Pose([-1.5, -2.5, 0]))
apartment = Object("apartment", pycrap.Apartment, "apartment.urdf", pose=Pose([-1.5, -2.5, 0]))
apartment_desig = ObjectDesignatorDescription(names=['apartment']).resolve()
table_top = apartment.get_link_position("cooktop")
# milk = Object("milk", "milk", "milk.stl", position=[table_top[0]-0.15, table_top[1], table_top[2]])
Expand Down Expand Up @@ -98,6 +99,7 @@ def get_n_random_positions(pose_list, n=4, dist=0.5, random=True):
```

```python
import pycrap
from pycram.costmaps import SemanticCostmap
from pycram.pose_generator_and_validator import PoseGenerator

Expand All @@ -106,17 +108,15 @@ poses_list = list(PoseGenerator(scm, number_of_samples=-1))
poses_list.sort(reverse=True, key=lambda x: np.linalg.norm(x.position_as_list()))
object_poses = get_n_random_positions(poses_list)
object_names = ["bowl", "breakfast_cereal", "spoon"]
object_types = [pycrap.Bowl, pycrap.Cereal, pycrap.Spoon]
objects = {}
object_desig = {}
for obj_name, obj_pose in zip(object_names, object_poses):
print(obj_name)
print(obj_pose)
objects[obj_name] = Object(obj_name, obj_name, obj_name + ".stl",
for obj_name, obj_type, obj_pose in zip(object_names, object_types, object_poses):
objects[obj_name] = Object(obj_name, obj_type, obj_name + ".stl",
pose=Pose([obj_pose.position.x, obj_pose.position.y, table_top.z]))
objects[obj_name].move_base_to_origin_pose()
objects[obj_name].original_pose = objects[obj_name].pose
object_desig[obj_name] = ObjectDesignatorDescription(names=[obj_name], types=[obj_name]).resolve()
print(object_poses)
object_desig[obj_name] = ObjectDesignatorDescription(names=[obj_name], types=[obj_type]).resolve()
```

If You want to visualize all apartment frames
Expand Down
17 changes: 9 additions & 8 deletions examples/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ It is possible to spawn objects and robots into the BulletWorld, these objects c
A BulletWorld can be created by simply creating an object of the BulletWorld class.

```python
import pycrap
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose

world = BulletWorld(mode=WorldMode.GUI)

milk = Object("Milk", ObjectType.MILK, "milk.stl")
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1.4, 1, 0.95]))
milk = Object("milk", pycrap.Milk, "milk.stl")
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
cereal = Object("cereal", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1.4, 1, 0.95]))
```

The BulletWorld allows to render images from arbitrary positions. In the following example we render images with the
Expand Down Expand Up @@ -90,7 +91,7 @@ Since everything inside the BulletWorld is an Object, even a complex environment
in the same way as the milk.

```python
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
kitchen = Object("kitchen", pycrap.Kitchen, "kitchen.urdf")
```

## Costmaps
Expand Down Expand Up @@ -270,7 +271,7 @@ Designators are used, for example, by the PickUpAction to know which object shou
```python
from pycram.designators.object_designator import *

milk_desig = BelieveObject(names=["Milk"])
milk_desig = BelieveObject(names=["milk"])
milk_desig.resolve()
```

Expand All @@ -281,7 +282,7 @@ Location Designator can create a position in cartisian space from a symbolic des
```python
from pycram.designators.object_designator import *

milk_desig = BelieveObject(names=["Milk"])
milk_desig = BelieveObject(names=["milk"])
milk_desig.resolve()
```

Expand All @@ -293,8 +294,8 @@ Location Designators can create a position in cartesian space from a symbolic de
from pycram.designators.location_designator import *
from pycram.designators.object_designator import *

robot_desig = BelieveObject(types=[ObjectType.ROBOT]).resolve()
milk_desig = BelieveObject(names=["Milk"]).resolve()
robot_desig = BelieveObject(types=[pycrap.Robot]).resolve()
milk_desig = BelieveObject(names=["milk"]).resolve()
location_desig = CostmapLocation(target=milk_desig, visible_for=robot_desig)

print(f"Resolved: {location_desig.resolve()}")
Expand Down
3 changes: 2 additions & 1 deletion examples/language.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ plan.
If you are performing a plan with a simulated robot, you need a BulletWorld.

```python
import pycrap
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType

world = BulletWorld()
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
```

```python
Expand Down
7 changes: 4 additions & 3 deletions examples/local_transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ from pycram.world_concepts.world_object import Object
from pycram.datastructures.pose import Transform, Pose
from pycram.local_transformer import LocalTransformer
from pycram.datastructures.enums import WorldMode
import pycrap
```

## Initializing the World
Expand Down Expand Up @@ -55,9 +56,9 @@ These objects will be used in subsequent tasks, to provide the frames to which w
from pycram.worlds.bullet_world import Object
from pycram.datastructures.enums import ObjectType

kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([0.9, 1, 0.95]))
bowl = Object("bowl", ObjectType.BOWL, "bowl.stl", pose=Pose([1.6, 1, 0.90]))
kitchen = Object("kitchen", pycrap.Kitchen, "kitchen.urdf")
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([0.9, 1, 0.95]))
bowl = Object("bowl", pycrap.Bowl, "bowl.stl", pose=Pose([1.6, 1, 0.90]))
```

## Creating a Local Transfomer
Expand Down
9 changes: 5 additions & 4 deletions examples/location_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose
import pycrap

world = BulletWorld(WorldMode.GUI)
apartment = Object("apartment", ObjectType.ENVIRONMENT, "apartment.urdf")
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
apartment = Object("apartment", pycrap.Apartment, "apartment.urdf")
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
```

Next up we will create the location designator description, the {meth}`~pycram.designators.location_designator.CostmapLocation` that we will be using needs a
Expand Down Expand Up @@ -78,7 +79,7 @@ PR2 will be set to 0.2 since otherwise the arms of the robot will be too low to

```python
pr2.set_joint_position("torso_lift_joint", 0.2)
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))

```

Expand Down Expand Up @@ -181,7 +182,7 @@ from pycram.datastructures.enums import ObjectType

apartment_desig = BelieveObject(names=["apartment"])
handle_desig = ObjectPart(names=["handle_cab10_t"], part_of=apartment_desig.resolve())
robot_desig = BelieveObject(types=[ObjectType.ROBOT])
robot_desig = BelieveObject(types=[pycrap.Robot])

access_location = AccessingLocation(handle_desig.resolve(), robot_desig.resolve()).resolve()
print(access_location.pose)
Expand Down
9 changes: 5 additions & 4 deletions examples/migrate_neems.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ from pycram.tasktree import with_tree
from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.designators.object_designator import *
import pycrap


class ExamplePlans:
def __init__(self):
self.world = BulletWorld("DIRECT")
self.pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
self.kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
self.milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
self.cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1.3, 0.7, 0.95]))
self.pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
self.kitchen = Object("kitchen", pycrap.Kitchen, "kitchen.urdf")
self.milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
self.cereal = Object("cereal", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1.3, 0.7, 0.95]))
self.milk_desig = ObjectDesignatorDescription(names=["milk"])
self.cereal_desig = ObjectDesignatorDescription(names=["cereal"])
self.robot_desig = ObjectDesignatorDescription(names=["pr2"]).resolve()
Expand Down
9 changes: 5 additions & 4 deletions examples/minimal_task_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ from pycram.datastructures.pose import Pose
from pycram.datastructures.enums import ObjectType, WorldMode
import anytree
import pycram.failures
import pycrap
```

Next we will create a bullet world with a PR2 in a kitchen containing milk and cereal.

```python
world = BulletWorld(WorldMode.DIRECT)
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
cereal = Object("cereal", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1.3, 0.7, 0.95]))
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
kitchen = Object("kitchen", pycrap.Kitchen, "kitchen.urdf")
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
cereal = Object("cereal", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1.3, 0.7, 0.95]))
milk_desig = ObjectDesignatorDescription(names=["milk"])
cereal_desig = ObjectDesignatorDescription(names=["cereal"])
robot_desig = ObjectDesignatorDescription(names=["pr2"]).resolve()
Expand Down
9 changes: 5 additions & 4 deletions examples/motion_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose
import pycrap

world = BulletWorld(WorldMode.GUI)
pr2 = Object("pr2", ObjectType.ROBOT, "pr2.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.5, 0, 1]))
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([1.5, 0, 1]))
```

## Move
Expand Down Expand Up @@ -115,7 +116,7 @@ from pycram.process_module import simulated_robot
with simulated_robot:
LookingMotion(target=Pose([1.5, 0, 1], [0, 0, 0, 1])).perform()

motion_description = DetectingMotion(object_type=ObjectType.MILK)
motion_description = DetectingMotion(object_type=pycrap.Milk)

obj = motion_description.perform()

Expand Down Expand Up @@ -150,7 +151,7 @@ from pycram.designators.motion_designator import WorldStateDetectingMotion
from pycram.process_module import simulated_robot

with simulated_robot:
motion_description = WorldStateDetectingMotion(object_type=ObjectType.MILK)
motion_description = WorldStateDetectingMotion(object_type=pycrap.Milk)

obj = motion_description.perform()

Expand Down
16 changes: 9 additions & 7 deletions examples/object_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ from pycram.worlds.bullet_world import BulletWorld
from pycram.world_concepts.world_object import Object
from pycram.datastructures.enums import ObjectType, WorldMode
from pycram.datastructures.pose import Pose

import pycrap
world = BulletWorld(WorldMode.GUI)
```

Expand All @@ -49,10 +49,12 @@ description which will be used to describe objects in the real world.
Since {meth}`~pycram.designators.object_designator.BelieveObject` describes Objects in the BulletWorld we create a few.

```python
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
milk = Object("milk", ObjectType.MILK, "milk.stl", pose=Pose([1.3, 1, 0.9]))
cereal = Object("froot_loops", ObjectType.BREAKFAST_CEREAL, "breakfast_cereal.stl", pose=Pose([1.3, 0.9, 0.95]))
spoon = Object("spoon", ObjectType.SPOON, "spoon.stl", pose=Pose([1.3, 1.1, 0.87]))
import pycrap

kitchen = Object("kitchen", pycrap.Kitchen, "kitchen.urdf")
milk = Object("milk", pycrap.Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
cereal = Object("froot_loops", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1.3, 0.9, 0.95]))
spoon = Object("spoon", pycrap.Spoon, "spoon.stl", pose=Pose([1.3, 1.1, 0.87]))
```

Now that we have objects we can create an object designator to describe them. For the start we want an object designator
Expand All @@ -73,7 +75,7 @@ the world.
```python
from pycram.designators.object_designator import BelieveObject

object_description = BelieveObject(types=[ObjectType.MILK, ObjectType.BREAKFAST_CEREAL])
object_description = BelieveObject(types=[pycrap.Milk, pycrap.Cereal])

print(object_description.resolve())
```
Expand Down Expand Up @@ -107,7 +109,7 @@ For this we need some objects, so if you didn't already spawn them you can use t
```python
from pycram.designators.object_designator import BelieveObject

object_description = BelieveObject(types=[ObjectType.MILK, ObjectType.BREAKFAST_CEREAL])
object_description = BelieveObject(types=[pycrap.Milk, pycrap.Cereal])

for obj in object_description:
print(obj, "\n")
Expand Down
Loading
Loading