Skip to content

Teaching a Robot Arm to Throw

One wrist camera, a black foam ball, and a 1/5th of a second to get the release right

Jithendra Puppala 6 min read179 views
Built with Python OpenCV NumPy Viam Intel RealSense D435 UFactory xArm pytest

The preview run, from sorting to closing the drawer

The ball is in the air for a fifth of a second.

In the video below, one robot arm sorts colored blocks into a three-drawer organizer and leaves the last drawer open. A second arm across the table finds a black foam ball with a camera on its wrist, picks it up, and throws it into that drawer.

The full run, from sorting to closing the drawer.

We built this at Viam's Code That Moves hackathon in New York in October 2026, a team of four: Sandeep, Waj, Riyaj, and me. I led the team and built the throwing arm: how it sees the ball, holds it, and lets go. This post is about that arm, because that's where almost everything went wrong first.

Why throwing is hard

Picking up a ball is a classic robotics demo. Throwing it into a drawer stacks three problems, and a small error in any one of them ruins the rest. The arm has to find the ball with a single camera while its wrist moves. It has to hold the ball by the fingertips, loosely enough to let go instantly. And it has to let go at an exact moment in a swing it can barely make fast enough, because its controller shuts the arm down when the tool passes about 1.3 m/s.

Seeing the ball

The wrist camera is an Intel RealSense D435, which gives a color image and a matching depth image. The starting point was Waj's first pick-and-throw script for this arm, which looks for dark pixels and reads their depth. A black ball on a white table seems easy to find that way: keep the dark, low-saturation pixels, clean up the mask, and take the blobs.

On one of the first runs, the detector found a blob, sent the arm to it, and I hit the E-stop above an empty patch of table. The blob was the robot's own fingertip, poking into the bottom edge of the frame.

An early mistake
An early run through the wrist camera. The red circle is the detector's pick: the robot's own fingertip at the bottom edge. The ball isn't in view.

Anything dark in the frame is a suspect, so now a blob only counts as the ball if it passes three checks:

  • It sits whole inside the frame. The fingertips always enter from the edge.
  • Its size matches its depth. A 6 cm ball at a measured distance covers a predictable number of pixels. A speck or a fingertip doesn't.
  • It holds still. Two looks 0.6 seconds apart must agree within 8 mm, so the arm never grabs at a ball that's still rolling or a hand that's still placing it.

A pixel only becomes a place to put the gripper if the camera's own position is right. I rebuilt the camera's pose from the arm's joint angles and the camera's mounting offsets, and checked it against Viam's frame system: the two match to a tenth of a millimeter. Before committing, the arm moves the camera straight over the ball and looks once more, since a straight-down view has the least error.

After the checks
After the checks: the ball, seen from straight above, just before the grab. Ignore the fingertips at the bottom edge.

Grabbing it

Depth cameras measure a soft, dark foam ball badly. Its top read about a centimeter differently from one pick to the next, and a centimeter is the difference between holding a ball by the fingertips and holding it deep in the hand. My first grips went too deep. Others crushed the ball, because the gripper squeezes to whatever width it's told.

So the arm no longer trusts the ball's surface. It measures the table instead: the median depth in a ring of pixels just outside the ball gives the table's height right where the ball sits. Add the ball's radius, and you have its equator. The fingertips close 4 mm below it, at a width that barely holds a 6 cm foam ball, tuned on the real ball a few millimeters at a time.

After lifting, the camera looks back at the table. If the ball is still lying there, the pick failed, and the arm says so. The gripper's own "holding" signal couldn't be trusted for this.

After lifting
After lifting: the table is empty and the ball is in the fingers, so the pick counts.

Letting go

A good throw needs speed the arm doesn't have. The answer was an underarm swing driven by the elbow and wrist together, with the wrist turning 1.5 times as fast as the elbow. The wrist's snap adds speed at the ball that the tool itself never reaches. In testing, the ball left at about 1.75 m/s with the tool held under 1.25 m/s, and landed about 1.25 m from the arm's base, well past the 0.85 m the arm can reach.

Then the release. The gripper takes about 0.14 seconds to open, which is about 20 cm of travel at full swing. Send the command when the ball is in the right place, and it leaves 20 cm late: my early throws fell off the end of the swing instead of flying. Now the arm reads its joint angles every 6 ms during the swing, predicts where the swing will be one gripper-delay later, and sends the open command early. It fires within about 2 ms of plan. The fingers also open only 2 cm past the ball, at the gripper's top speed, so the ball is free sooner.

The release
The release, from the video. The ball is free by +133 ms and inside the drawer by +267 ms.

None of this moved the real arm first. The system checks every planned motion along its whole path against the table, the overhead light, the walls, and the arm's own body. The full pick-and-throw also ran against a simulated arm and gripper in more than two hundred automated tests before the real arm swung.

The other arm

The sorting arm is the team's work. Waj built the block picking, Sandeep the drawer handling and the sorting run in the video, and Riyaj the checks that look inside each drawer after a block goes in. They plug into a world model I built: the robot keeps a belief about where every block is, including those hidden in closed drawers, and flags a surprise when the camera disagrees with its expectations.

In the final run, the sorting arm puts the black block in the first drawer and the yellow blocks in the second, opens the third, and waits. The throwing arm doesn't look for that drawer. Its throw is planned to land at a fixed spot, and the organizer sits there. After the throw, the sorting arm comes back and closes the drawer.

What's next

  • A camera that checks itself. If the wrist turns 90° between two looks, the camera's own mounting error turns with it while the ball stays put, and that separates the two. In simulation, an 8.6 mm camera error still left the grip within 1 mm. It hasn't run on the real arm yet.
  • Closing the loop. The wrist camera already looks at where each throw lands. Feeding those landings back would let the arm correct its own throw.
  • A catch. The second arm, holding something to catch with.

Thanks to Viam for the hackathon and the arms, and to Sandeep, Waj, and Riyaj for two very long days. The code is on GitHub: github.com/jithendra1798/WorldArm.

Get In Touch

I'll respond within 24-48 hours