World Structure Manipulation#

This exercise demonstrates adding and removing entities from the kinematic structure.

You will:

  • Create a simple world with a passive 6DoF connection and an active revolute joint

  • Remove the revolute connection and its child body in a single modification block

0. Setup#

1. Create a simple kinematic structure#

Your goal:

  • Create a World and three bodies named root, base, and body

  • Add a passive Connection6DoF between root (parent) and base (child)

  • Add a RevoluteConnection between base (parent) and body (child) using a Z axis on base

  • Store the world in a variable named world and the revolute connection in base_C_body

  • Add the Connections to the world.

world = World()
root = Body(name=PrefixedName(name="root", prefix="world"))
base = Body(name=PrefixedName("base"))
body = Body(name=PrefixedName("body"))
root_C_base = Connection6DoF(parent=root, child=base)
base_C_body_dof = DegreeOfFreedom(name=PrefixedName("joint_z"))
base_C_body = RevoluteConnection(
        parent=base,
        child=body,
        dof_name=base_C_body_dof.name,
        axis=Vector3.Z(reference_frame=base),
    )

with world.modify_world():
    world.add_connection(root_C_base)    
    world.add_connection(base_C_body)

2. Remove a connection and its child#

Your goal:

  • In a single with world.modify_world(): block, remove the revolute connection and the now disconnected child body body.

with symbolic_mode():
    base_C_body_query = the(entity(let(RevoluteConnection, world.connections)))

base_C_body = base_C_body_query.evaluate()
body = base_C_body.child

with world.modify_world():
    world.remove_connection(base_C_body)
    world.remove_kinematic_structure_entity(body)