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
Worldand three bodies namedroot,base, andbodyAdd a passive
Connection6DoFbetweenroot(parent) andbase(child)Add a
RevoluteConnectionbetweenbase(parent) andbody(child) using a Z axis onbaseStore the world in a variable named
worldand the revolute connection inbase_C_bodyAdd 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 bodybody.
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)