Skip to content

Commit

Permalink
Merge pull request #263 from sorinar329/dev
Browse files Browse the repository at this point in the history
Updated PyCrap
  • Loading branch information
tomsch420 authored Feb 13, 2025
2 parents 76e2643 + 780fbb0 commit d95f0c8
Show file tree
Hide file tree
Showing 64 changed files with 1,573 additions and 417 deletions.
2 changes: 1 addition & 1 deletion demos/pycram_bullet_world_demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pycram.world_concepts.world_object import Object
from pycram.datastructures.dataclasses import Color
from pycram.ros_utils.viz_marker_publisher import VizMarkerPublisher
from pycrap import Robot, Apartment, Milk, Cereal, Spoon, Bowl
from pycrap.ontologies import Robot, Apartment, Milk, Cereal, Spoon, Bowl
import numpy as np


Expand Down
2 changes: 1 addition & 1 deletion demos/pycram_multiverse_demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pycram.robot_description import RobotDescription
from pycram.world_concepts.world_object import Object
from pycram.worlds.multiverse import Multiverse
from pycrap import PhysicalObject
from pycrap.ontologies import PhysicalObject


world = Multiverse()
Expand Down
2 changes: 1 addition & 1 deletion demos/pycram_multiverse_demo/fallschool_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pycram.worlds.bullet_world import BulletWorld
from pycram.worlds.multiverse import Multiverse
from pycram.ros_utils.viz_marker_publisher import VizMarkerPublisher
from pycrap import PhysicalObject
from pycrap.ontologies import PhysicalObject


@with_simulated_robot
Expand Down
8 changes: 4 additions & 4 deletions examples/action_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +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
from pycrap.ontologies import Robot, Milk, Apartment

world = BulletWorld(WorldMode.DIRECT)
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]))
pr2 = Object("pr2", Robot, "pr2.urdf", pose=Pose([1, 2, 0]))
apartmet = Object("apartment", Apartment, "apartment.urdf")
milk = Object("milk", 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
8 changes: 4 additions & 4 deletions examples/bullet_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +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
from pycrap.ontologies import Milk, Cereal, Robot

world = BulletWorld(mode=WorldMode.DIRECT)
```
Expand All @@ -42,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", pycrap.Milk, "milk.stl", pose=Pose([0, 0, 1]))
milk = Object("milk", Milk, "milk.stl", pose=Pose([0, 0, 1]))
```

<!-- #region -->
Expand Down Expand Up @@ -92,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", pycrap.Cereal, "breakfast_cereal.stl", pose=Pose([1, 0, 1]))
cereal = Object("cereal", Cereal, "breakfast_cereal.stl", pose=Pose([1, 0, 1]))
```

```python
Expand Down Expand Up @@ -120,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", pycrap.Robot, "pr2.urdf")
pr2 = Object("pr2", Robot, "pr2.urdf")
print(pr2.links)
```

Expand Down
13 changes: 6 additions & 7 deletions examples/cram_plan_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ from pycram.world_concepts.world_object import Object
import anytree
import pycram.failures
import numpy as np
import pycrap
from pycrap.ontologies import Milk, Cereal, Robot, Kitchen, Spoon, Apartment, Bowl

np.random.seed(4)

Expand All @@ -49,9 +49,9 @@ else:
world = BulletWorld()
viz_marker_publisher = VizMarkerPublisher()

robot = Object("pr2", pycrap.Robot, "pr2.urdf")
robot = Object("pr2", Robot, "pr2.urdf")
robot_desig = ObjectDesignatorDescription(names=['pr2']).resolve()
apartment = Object("apartment", pycrap.Apartment, "apartment.urdf")
apartment = Object("apartment", Apartment, "apartment.urdf")
apartment_desig = ObjectDesignatorDescription(names=['apartment']).resolve()
table_top_name = "stove" if use_multiverse else "cooktop"
table_top = apartment.get_link_position(table_top_name)
Expand Down Expand Up @@ -90,7 +90,7 @@ def get_n_random_positions(pose_list, n=4, dist=0.5, random=True):
```python
import pycrap
from tf.transformations import quaternion_from_euler
import pycrap

from pycram.costmaps import SemanticCostmap
from pycram.pose_generator_and_validator import PoseGenerator

Expand All @@ -104,7 +104,7 @@ poses_list = list(PoseGenerator(edges_cm, 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]
object_types = [Bowl, Cereal, Spoon]
objects = {}
object_desig = {}
for obj_name, obj_type, obj_pose in zip(object_names, object_types, object_poses):
Expand Down Expand Up @@ -141,7 +141,6 @@ Finally, we create a plan where the robot parks his arms, walks to the kitchen c
execute the plan.

```python
import pycrap
from pycram.external_interfaces.ik import IKError
from pycram.datastructures.enums import Grasp

Expand All @@ -161,7 +160,7 @@ def plan(obj_desig: ObjectDesignatorDescription.Object, torso=None, place=counte
ParkArmsActionPerformable(Arms.BOTH).perform()
good_torsos.append(torso)
picked_up_arm = pose.reachable_arms[0]
grasp = Grasp.TOP if issubclass(obj_desig.world_object.obj_type, pycrap.Spoon) else Grasp.FRONT
grasp = Grasp.TOP if issubclass(obj_desig.world_object.obj_type, Spoon) else Grasp.FRONT
PickUpActionPerformable(object_designator=obj_desig, arm=pose.reachable_arms[0], grasp=grasp,
prepose_distance=0.03).perform()

Expand Down
4 changes: 2 additions & 2 deletions examples/improving_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ session = sqlalchemy.orm.sessionmaker(bind=engine)()
Now we construct an empty world with just a floating milk, where we can learn about PickUp actions.

```python
from pycrap import Robot, Milk
from pycrap.ontologies import Robot, Milk

world = BulletWorld(WorldMode.DIRECT)
print(world.prospection_world)
Expand Down Expand Up @@ -167,7 +167,7 @@ Next, we put the learned model to the test in a complex environment, where the m
area.

```python
from pycrap import Apartment
from pycrap.ontologies import Apartment
kitchen = Object("apartment", Apartment, "apartment.urdf")

milk.set_pose(Pose([0.5, 3.15, 1.04]))
Expand Down
12 changes: 6 additions & 6 deletions examples/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +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
from pycrap.ontologies import Milk, Cereal, Robot, Kitchen

world = BulletWorld(mode=WorldMode.DIRECT)

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]))
milk = Object("milk", Milk, "milk.stl")
pr2 = Object("pr2", Robot, "pr2.urdf")
cereal = Object("cereal", 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 @@ -91,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", pycrap.Kitchen, "kitchen.urdf")
kitchen = Object("kitchen", Kitchen, "kitchen.urdf")
```

## Costmaps
Expand Down Expand Up @@ -294,7 +294,7 @@ 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=[pycrap.Robot]).resolve()
robot_desig = BelieveObject(types=[Robot]).resolve()
milk_desig = BelieveObject(names=["milk"]).resolve()
location_desig = CostmapLocation(target=milk_desig, visible_for=robot_desig)

Expand Down
2 changes: 1 addition & 1 deletion examples/knowledge_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ from pycram.datastructures.enums import WorldMode, ObjectType
from pycram.knowledge.knowledge_engine import KnowledgeEngine
from pycram.datastructures.pose import Pose
from pycram.datastructures.property import ReachableProperty, SpaceIsFreeProperty
from pycrap import Robot
from pycrap.ontologies import Robot

world = BulletWorld(WorldMode.GUI)
pr2 = Object("pr2", Robot, "pr2.urdf")
Expand Down
4 changes: 2 additions & 2 deletions examples/language.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +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
from pycrap.ontologies import Robot

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

```python
Expand Down
8 changes: 4 additions & 4 deletions examples/local_transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ 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 All @@ -55,10 +54,11 @@ These objects will be used in subsequent tasks, to provide the frames to which w
```python
from pycram.worlds.bullet_world import Object
from pycram.datastructures.enums import ObjectType
from pycrap.ontologies import Kitchen, Milk, Bowl

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]))
kitchen = Object("kitchen", Kitchen, "kitchen.urdf")
milk = Object("milk", Milk, "milk.stl", pose=Pose([0.9, 1, 0.95]))
bowl = Object("bowl", Bowl, "bowl.stl", pose=Pose([1.6, 1, 0.90]))
```

## Creating a Local Transfomer
Expand Down
10 changes: 5 additions & 5 deletions examples/location_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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
from pycrap.ontologies import Apartment, Robot, Milk

use_multiverse = False
viz_marker_publisher = None
Expand All @@ -57,8 +57,8 @@ else:
world = BulletWorld()
viz_marker_publisher = VizMarkerPublisher()

apartment = Object("apartment", pycrap.Apartment, "apartment.urdf")
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
apartment = Object("apartment", Apartment, "apartment.urdf")
pr2 = Object("pr2", 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 @@ -91,7 +91,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", pycrap.Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
milk = Object("milk", Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))

```

Expand Down Expand Up @@ -195,7 +195,7 @@ from pycram.designators.location_designator import *
apartment_desig = BelieveObject(names=["apartment"])
handle_name = "cabinet10_drawer1_handle" if use_multiverse else "handle_cab10_t"
handle_desig = ObjectPart(names=[handle_name], part_of=apartment_desig.resolve())
robot_desig = BelieveObject(types=[pycrap.Robot])
robot_desig = BelieveObject(types=[Robot])

access_location = AccessingLocation(handle_desig.resolve(), robot_desig.resolve(),
prepose_distance=0.03).resolve()
Expand Down
13 changes: 6 additions & 7 deletions examples/migrate_neems.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +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 *
from pycram.datastructures.enums import TorsoState
import pycrap
from pycrap.ontologies import Robot, Kitchen, Milk, Cereal


class ExamplePlans:
def __init__(self):
self.world = BulletWorld("DIRECT")
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.pr2 = Object("pr2", Robot, "pr2.urdf")
self.kitchen = Object("kitchen", Kitchen, "kitchen.urdf")
self.milk = Object("milk", Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
self.cereal = Object("cereal", 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 All @@ -76,7 +75,7 @@ class ExamplePlans:
def pick_and_place_plan(self):
with simulated_robot:
ParkArmsAction([Arms.BOTH]).resolve().perform()
MoveTorsoAction([TorsoState.HIGH]).resolve().perform()
MoveTorsoAction([0.3]).resolve().perform()
pickup_pose = CostmapLocation(target=self.cereal_desig.resolve(), reachable_for=self.robot_desig).resolve()
pickup_arm = pickup_pose.reachable_arms[0]
NavigateAction(target_locations=[pickup_pose.pose]).resolve().perform()
Expand Down
10 changes: 5 additions & 5 deletions examples/minimal_task_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ from pycram.datastructures.pose import Pose
from pycram.datastructures.enums import ObjectType, WorldMode, TorsoState
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
from pycrap.ontologies import Milk, Cereal, Robot, Kitchen
world = BulletWorld(WorldMode.DIRECT)
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]))
pr2 = Object("pr2", Robot, "pr2.urdf")
kitchen = Object("kitchen", Kitchen, "kitchen.urdf")
milk = Object("milk", Milk, "milk.stl", pose=Pose([1.3, 1, 0.9]))
cereal = Object("cereal", 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
11 changes: 5 additions & 6 deletions examples/motion_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +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
from pycrap.ontologies import Robot, Milk

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

## Move
Expand Down Expand Up @@ -116,7 +116,6 @@ from pycram.designators.motion_designator import DetectingMotion, LookingMotion
from pycram.process_module import simulated_robot
from pycram.datastructures.pose import Pose
from pycram.datastructures.enums import DetectionTechnique, DetectionState
from pycrap import Milk
from pycram.designators.object_designator import BelieveObject


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

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

obj = motion_description.perform()

Expand All @@ -185,4 +184,4 @@ The following cell can be used after testing the examples, to close the BulletWo

```python
world.exit()
```
```
Loading

0 comments on commit d95f0c8

Please sign in to comment.