Skip to content

Commit

Permalink
[Ontology] Fixed doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsch420 committed Dec 12, 2024
1 parent 5da6d6c commit b9e2dfa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
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 @@ -89,7 +89,7 @@ def get_n_random_positions(pose_list, n=4, dist=0.5, random=True):

```python
from tf.transformations import quaternion_from_euler
import pycrap

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

Expand All @@ -103,7 +103,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 @@ -140,7 +140,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 @@ -159,7 +158,7 @@ def plan(obj_desig: ObjectDesignatorDescription.Object, torso=0.2, place=counter
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
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
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
5 changes: 2 additions & 3 deletions examples/motion_designator.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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
import pycrap.ontologies as pycrap

world = BulletWorld(WorldMode.DIRECT)
pr2 = Object("pr2", pycrap.Robot, "pr2.urdf")
Expand Down Expand Up @@ -116,14 +116,13 @@ 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


with simulated_robot:
LookingMotion(target=Pose([1.5, 0, 1], [0, 0, 0, 1])).perform()

motion_description = DetectingMotion(technique=DetectionTechnique.TYPES,state=DetectionState.START, object_designator_description=BelieveObject(types=[Milk]),
motion_description = DetectingMotion(technique=DetectionTechnique.TYPES,state=DetectionState.START, object_designator_description=BelieveObject(types=[pycrap.Milk]),
region=None)

obj = motion_description.perform()
Expand Down

0 comments on commit b9e2dfa

Please sign in to comment.