Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbiering committed Dec 20, 2024
1 parent 66a526b commit 5f6a079
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
9 changes: 6 additions & 3 deletions examples/02_plan_and_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ async def main():
home_joints = (0, -pi / 4, -pi / 4, -pi / 4, pi / 4, 0)

# Connect to the controller and activate motion groups
async with controller[0] as mg:
async with controller[0] as motion_group:
tcp_names = await motion_group.tcp_names()
tcp = tcp_names[0]

# Get current TCP pose and offset it slightly along the x-axis
current_pose = await mg.tcp_pose("Flange")
current_pose = await motion_group.tcp_pose(tcp)
target_pose = current_pose @ Pose((1, 0, 0, 0, 0, 0))

actions = [
Expand All @@ -36,7 +39,7 @@ async def main():
jnt(home_joints),
]

await mg.run(actions, tcp="Flange", movement_controller=move_forward)
await motion_group.run(actions, tcp=tcp, movement_controller=move_forward)


if __name__ == "__main__":
Expand Down
14 changes: 7 additions & 7 deletions examples/03_move_and_set_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ async def main():
nova = Nova()
cell = nova.cell()
controllers = await cell.controllers()
controller = controllers[0]

# Define a home position
home_joints = (0, -pi / 4, -pi / 4, -pi / 4, pi / 4, 0)

# Connect to the controller and activate motion groups
async with controller:
motion_group = controller.motion_group()
async with controllers[0] as motion_group:
tcp_names = await motion_group.tcp_names()
tcp = tcp_names[0]

# Get current TCP pose and offset it slightly along the x-axis
current_pose = await motion_group.tcp_pose("Flange")
current_pose = await motion_group.tcp_pose(tcp)
target_pose = current_pose @ Pose((100, 0, 0, 0, 0, 0))
actions = [
jnt(home_joints),
Expand All @@ -39,9 +39,9 @@ async def main():
def print_motion(motion):
print(motion)

await motion_group.run(actions, tcp="Flange", initial_movement_consumer=print_motion)
await motion_group.run(actions, tcp="Flange")
await motion_group.run(ptp(target_pose), tcp="Flange")
await motion_group.run(actions, tcp=tcp, initial_movement_consumer=print_motion)
await motion_group.run(actions, tcp=tcp)
await motion_group.run(ptp(target_pose), tcp=tcp)


if __name__ == "__main__":
Expand Down
9 changes: 6 additions & 3 deletions examples/04_move_multiple_robots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
async def move_robot(controller: Controller):
home_joints = (0, -pi / 4, -pi / 4, -pi / 4, pi / 4, 0)

async with controller[0] as mg:
current_pose = await mg.tcp_pose("Flange")
async with controller[0] as motion_group:
tcp_names = await motion_group.tcp_names()
tcp = tcp_names[0]

current_pose = await motion_group.tcp_pose(tcp)
target_pose = current_pose @ (100, 0, 0, 0, 0, 0)
actions = [jnt(home_joints), ptp(target_pose), jnt(home_joints)]

await mg.run(actions, tcp="Flange", movement_controller=speed_up_movement_controller)
await motion_group.run(actions, tcp=tcp, movement_controller=speed_up_movement_controller)


async def main():
Expand Down
11 changes: 6 additions & 5 deletions examples/05_selection_motion_group_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import asyncio


async def move_robot(motion_group: MotionGroup):
async def move_robot(motion_group: MotionGroup, tcp: str):
home_pose = Pose((200, 200, 600, 0, pi, 0))
target_pose = home_pose @ (100, 0, 0, 0, 0, 0)
actions = [
Expand All @@ -27,16 +27,17 @@ async def move_robot(motion_group: MotionGroup):
ptp(home_pose),
]

await motion_group.run(actions, tcp="Flange")
await motion_group.run(actions, tcp=tcp)


async def main():
nova = Nova()
cell = nova.cell()
ur = await cell.controller("ur")
kuka = await cell.controller("kuka")
tcp = "Flange"

flange_state = await ur[0].get_state("Flange")
flange_state = await ur[0].get_state(tcp=tcp)
print(flange_state)

# activate all motion groups
Expand All @@ -53,13 +54,13 @@ async def main():

# activate motion group 0 from two different controllers
async with ur[0] as ur_0_mg, kuka[0] as kuka_0_mg:
await asyncio.gather(move_robot(ur_0_mg), move_robot(kuka_0_mg))
await asyncio.gather(move_robot(ur_0_mg, tcp), move_robot(kuka_0_mg, tcp))

# activate motion group 0 from two different controllers
mg_0 = ur.motion_group(0)
mg_1 = kuka.motion_group(0)
async with mg_0, mg_1:
await asyncio.gather(move_robot(mg_0), move_robot(mg_1))
await asyncio.gather(move_robot(mg_0, tcp), move_robot(mg_1, tcp))


if __name__ == "__main__":
Expand Down

0 comments on commit 5f6a079

Please sign in to comment.