Regions#
This exercise demonstrates how to define a Region and connect it into the kinematic tree so it moves with a body.
You will:
Load the table URDF from the loading worlds exercise
Create a region representing the table surface and attach it to the table surface named “top”
Move the table and observe that the region follows
0. Setup#
1. Load the table and attach a surface region#
Your goal:
Parse
table.urdfinto a variable namedworldFind the table body named
topinworld.bodiesCreate a thin Region named
table_surfaceand attach it totopvia aFixedConnectionStore the region in a variable named
surface_regionSave its initial position in a variable named
before_pos
world = URDFParser.from_file(table_urdf).parse()
# Find the table surface body named "top"
top = [b for b in world.bodies if b.name.name == "top"][0]
# Create a thin region at the table surface and attach it to the body "top"
surface_region = Region(name=PrefixedName("table_surface"))
surface_shape = Box(origin=TransformationMatrix(reference_frame=surface_region), scale=Scale(1.0, 1.0, 0.001))
surface_region.area = [surface_shape]
with world.modify_world():
world.add_kinematic_structure_entity(surface_region)
world.add_connection(FixedConnection(parent=top, child=surface_region, _world=world))
# Remember the initial pose
before_pos = surface_region.global_pose.to_position().to_np()[:3]
2. Move the table and check the region#
Your goal:
Add a
Connection6DoFbetween a new body namedrootand the current root of the table worldMove the table by setting the 6DoF connection’s
origintoTransformationMatrix.from_xyz_rpy(x=1.0, y=2.0, reference_frame=world.root)inside a modification block
new_root = Body(name=PrefixedName("root"))
with world.modify_world():
root_to_table = Connection6DoF(parent=new_root, child=world.root, _world=world)
world.add_connection(root_to_table)
with world.modify_world():
root_to_table.origin = TransformationMatrix.from_xyz_rpy(x=1.0, y=2.0, reference_frame=world.root)