Step 5
Clear the table
Generalise your program: perceive every ball, pick each one, verify, retry, and survive a new layout on every run.
From a script to a skill
Step 4's program only worked for one ball at one position. Real robots face a new scene every time, so this step reshuffles the balls on every run. Hard-coded coordinates won't survive.
Robust manipulation code follows a loop that roboticists call sense → plan → act → verify:
- Sense: ask the world where things are (
world.balls()). - Plan: compute the pre-grasp, grasp and place poses from those measurements.
- Act: run the phases.
- Verify: did
gripper.close()returnTrue? If not, back off, re-sense (the ball may have been nudged) and try again, up to a limit.
Wrap Step 4 in a function:
def pick_and_place(name) -> bool:
...
Then call it for each ball.
Stacking
The cup fills up. Three balls fit on the floor and the fourth sits on top, so release a little higher than before. That way a new ball never lands on a finger.
Your task
Get all four balls into the cup. For a bonus, drop them in rainbow order: red, yellow, green, blue.
The layout changes on every run, so press Run a few times to make sure your program really generalises.