Object Designator

Object designators are used to describe objects located in the BulletWorld or the real environment and then resolve them during runtime to concrete objects.

Object designators are different from the Object class in bullet_world.py in the way that they just describe an object and do not create objects or provide methods to manipulate them. Nevertheless, object designators contain a reference to the BulletWorld object.

An Object designator takes two parameters, of which at least one has to be provided. These parameters are:

  • A list of names

  • A list of types

Object Designators work similar to Location designators, they get constrains describing a set of objects and when resolved return a specific instance.

For all following examples we need a BulletWorld, so let’s create one.

[1]:
from pycram.bullet_world import BulletWorld, Object
from pycram.enums import ObjectType
from pycram.pose import Pose

world = BulletWorld()
Unknown tag "material" in /robot[@name='plane']/link[@name='planeLink']/collision[1]
Unknown tag "contact" in /robot[@name='plane']/link[@name='planeLink']
Unknown tag "material" in /robot[@name='plane']/link[@name='planeLink']/collision[1]
Unknown tag "contact" in /robot[@name='plane']/link[@name='planeLink']
[7]:
world.exit()

Believe Object

This object designator is used to describe objects that are located in the BulletWorld. So objects that are in the belief state, hence the name. In the future when there is a perception interface, there will be a RealObject description which will be used to describe objects in the real world.

Since BelieveObject describes Objects in the BulletWorld we create a few.

[2]:
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]))
Scalar element defined multiple times: limit
Scalar element defined multiple times: limit

Now that we have objects we can create an object designator to describe them. For the start we want an object designator only describing the milk. Since all objects have unique names we can create an object designator using a list with only the name of the object.

[3]:
from pycram.designators.object_designator import BelieveObject

object_description = BelieveObject(names=["milk"])

print(object_description.resolve())
BelieveObject.Object(name='milk', type=<ObjectType.MILK: 1>, bullet_world_object=Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>}), _pose=<bound method Object.get_pose of Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>})>)

You can also use the type to describe objects, so now we want to have an object designator that describes every food in the world.

[4]:
from pycram.designators.object_designator import BelieveObject

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

print(object_description.resolve())
BelieveObject.Object(name='milk', type=<ObjectType.MILK: 1>, bullet_world_object=Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>}), _pose=<bound method Object.get_pose of Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>})>)

Object Part

Part of object designators can be used to describe something as part of another object. For example, you could describe a specific drawer as part of the kitchen. This is necessary since the drawer is no single BulletWorld Object but rather a link of the kitchen which is a BulletWorld Object.

For this example we need just need the kitchen, if you didn’t spawn it in the previous example you can spawn it with the following cell.

[ ]:
kitchen = Object("kitchen", ObjectType.ENVIRONMENT, "kitchen.urdf")
[ ]:
from pycram.designators.object_designator import ObjectPart, BelieveObject

kitchen_desig = BelieveObject(names=["kitchen"]).resolve()

object_description = ObjectPart(names=["sink_area_left_upper_drawer_main"], part_of=kitchen_desig)

print(object_description.resolve())

Object Designators as Generators

Similar to location designators object designators can be used as generators to iterate through every object that they are describing. We will see this at the example of an object designator describing every type of food.

For this we need some objects, so if you didn’t already spawn them you can use the next cell for this.

[ ]:
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]))
[6]:
from pycram.designators.object_designator import BelieveObject

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

for obj in object_description:
    print(obj, "\n")
BelieveObject.Object(name='milk', type=<ObjectType.MILK: 1>, bullet_world_object=Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>}), _pose=<bound method Object.get_pose of Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=milk,
type=ObjectType.MILK,
color=[1, 1, 1, 1],
id=3,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/milk.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=milk_3,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 742550373
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 1.0
    z: 0.9
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'milk_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "milk_3"
transform:
  translation:
    x: 1.3
    y: 1.0
    z: 0.9
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[ 4.15300950e-04 -6.29518181e-05  8.96554102e-02],
link_to_geometry={'milk_main': <urdf_parser_py.urdf.Mesh object at 0x7fd84739abe0>})>)

BelieveObject.Object(name='froot_loops', type=<ObjectType.BREAKFAST_CEREAL: 4>, bullet_world_object=Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=froot_loops,
type=ObjectType.BREAKFAST_CEREAL,
color=[1, 1, 1, 1],
id=4,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/breakfast_cereal.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=froot_loops_4,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'cereal_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'cereal_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "froot_loops_4"
transform:
  translation:
    x: 1.3
    y: 0.9
    z: 0.95
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[0.00124406 0.00101732 0.1038567 ],
link_to_geometry={'cereal_main': <urdf_parser_py.urdf.Mesh object at 0x7fd849555520>}), _pose=<bound method Object.get_pose of Object(world=<pycram.bullet_world.BulletWorld object at 0x7fd84c0f46a0>,
local_transformer=<pycram.local_transformer.LocalTransformer object at 0x7fd84c0f4f70>,
name=froot_loops,
type=ObjectType.BREAKFAST_CEREAL,
color=[1, 1, 1, 1],
id=4,
path=/home/jdech/workspace/ros/src/pycram-1/src/pycram/../../resources/cached/breakfast_cereal.urdf,
joints: ...,
links: ...,
attachments: ...,
cids: ...,
original_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
tf_frame=froot_loops_4,
urdf_object: ...,
_current_pose=header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0,
_current_link_poses={'cereal_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 849018335
  frame_id: "map"
pose:
  position:
    x: 1.3
    y: 0.9
    z: 0.95
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_link_transforms={'cereal_main': header:
  seq: 0
  stamp:
    secs: 1699448681
    nsecs: 999615669
  frame_id: "map"
child_frame_id: "froot_loops_4"
transform:
  translation:
    x: 1.3
    y: 0.9
    z: 0.95
  rotation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0},
_current_joint_states={},
base_origin_shift=[0.00124406 0.00101732 0.1038567 ],
link_to_geometry={'cereal_main': <urdf_parser_py.urdf.Mesh object at 0x7fd849555520>})>)