⟵ Back to projects

Self-Balancing Sea Lion

May 202611 min read

Self-Balancing Sea Lion cover

In a team of four, we built a sea lion that balances objects on his nose. I owned the capstan drive and the electronics-to-mechanical integration. Cadding and electronics packaging were shared.

  • Inverted pendulum control: a BNO055 IMU reads tilt at 100 Hz, an Arduino Nano runs PID, and a 4:1 Dyneema capstan swings a 2 lb hammer head against the tilt.
  • PID tuned on hardware: gyro-fed D term, anti-windup, deadbands.
  • Creo surface modeling: boundary blends over a cylindrical belly, mechanism animated in CAD to catch interferences.
  • All four requirements passed: at least one non-trivial mechanism, recovery faster than the free wobble, re-leveling with ~200 g, sealed but serviceable electronics.

Without the loop closed, this toy just wobbles. With it closed, it fights back!

Context

Final project for ME 444, Computer Aided Design and Prototyping (Spring 2026). The end product was an action toy with at least one non-trivial mechanism, inside a 12 x 12 x 12 inch envelope and a $70 budget. We built a sea lion that balances things on his nose. He has wanted to join the circus since he was a pup!

Cuteness alone was not enough. Our team set three more goals:

How It Works

Under the fur, this is a one-degree-of-freedom inverted pendulum, a broomstick balanced on your palm that can only tip one way. The body rocks on a perfectly cylindrical bottom. Inside, a counterweight swings to cancel whatever the world does to him.

  1. Sense. A BNO055 IMU reads the tilt angle 100 times a second over I2C, doing the job a real sea lion’s inner ear does for free!
  2. Compute. An Arduino Nano runs a PID loop on that tilt error.
  3. Actuate. A servo rated for 25 kg-cm of stall torque spins a helical screw. A Dyneema cable winds a capstan drum for a 4:1 reduction.
  4. Counterbalance. The drum swings a 2 lb hammer head opposite the tilt. Yes, a real hammer head. More on that later.

The heart of the control loop fits in three lines:

float error  = event.orientation.y;                  // tilt from the IMU
float u = P*error + I*integral_error + D*gyro.y();   // gyro feeds the D term directly
myservo.write(constrain(u + 90 + error*GEAR_RATIO, 0, 180)); // 90 = level, x4 keeps the arm world-frame

Those gains only mean something if you know what you are fighting. Sum torques about the line where the belly meets the table. The whole equation of motion condenses to this:

Iθ¨=−Mgdsin⁡θ+mgrsin⁡ϕ+τdistI\ddot{\theta} = -Mgd\sin\theta + mgr\sin\phi + \tau_{dist}

Take the terms left to right. Rotational inertia II resists angular acceleration. Gravity re-centers a center of mass hanging a distance dd below the belly’s center of curvature. The counterweight of mass mm swings to angle ϕ\phi on an arm of radius rr. The last term is whatever torque the world adds.

Two insights fell out of this napkin model:

In code, the D term reads angular rate straight off the gyro instead of differentiating a noisy angle. Anti-windup stops the integral from ballooning when the servo saturates. Deadbands keep the sea lion from twitching when he is already level. Final gains landed at Kp=1.5K_p = 1.5, Ki=1.5K_i = 1.5, Kd=0.2K_d = 0.2. We tuned them through trial, error, and a lot of pushing the sea lion over. Be assured that no sea lions were harmed in the production of this toy!

Concept sketch of the sea lion with plate, capstan, counterweight, and protoboard labeled
The concept sketch of the sea lion. Plate on the nose, capstan and counterweight in the chest, protoboard in the belly.

Design Choices

Building It

Every structural component is PLA, modeled in Creo Parametric. The body was our excuse to try free-hand surface modeling. Boundary blends, the Creo tool that stretches a smooth skin across a set of guide curves, wrap over the cylindrical bottom. The sea lion looks organic and still rocks predictably. Modeling the capstan screw as a gear with a helical sweep let us animate the whole mechanism in CAD and catch interferences before printing a single part.

Creo model of the capstan drive mechanism
The capstan drive modeled in Creo. Servo on top, helical screw, cable, drum, and the counterweight arm hanging below. We modeled the mechanism as a gear system because Creo cannot model strings.
Capstan v1, the proof of concept. The Dyneema had to be tensioned by hand and by feel until the drum stopped slipping.
Capstan v2, with bearings in the arm and the servo attached. Smoother, stronger, ready for the body.
Capstan frame, helical screw, and counterweight arm on the 3D printer bed
Capstan frame, helical screw, and counterweight arm fresh off the printer.

The build itself was a crash course in design for assembly:

Final assembly and exploded view The final CAD assembly and its exploded view. Plate, top shell, and the bottom shell carrying the whole mechanism.

Power comes from a 2S LiPo, a 7.4V battery pack. A buck converter steps it down to 6V for the servo. The Nano takes the full 7.4V on Vin. The IMU runs off the Nano’s 5V pin. Everything lives on a protoboard at the bottom of the cavity. The board conveniently doubles as ballast.

Inside the sea lion: capstan drive and wired protoboard in the bottom shell
The internals, as built. Servo and capstan up top, protoboard and wiring settled into the hull.

Shell open, loop closed, and a little jittery. We tuned every gain with the full shell installed. With the top half off, the body is lighter and carries less rotational inertia. The same corrections come on too strong and the capstan twitches around level. PID gains are married to the exact body they were tuned on.

Results

The sea lion works! Push him and he pops back upright faster than the free wobble. Stack a weight on the edge of his plate and the hammer head quietly slides the other way until he levels out. The side-by-side tests in our final video say it better than I can:

Made with the rest of the team. Shout out to Shidan Wan, Samantha Walz, and Brant Peng.

RequirementOutcome
Non-trivial mechanismCustom capstan drive, 4:1 reduction
Recover from a push faster than the free responsePID actively damps it instead of letting it ring
Re-balance with ~200 g at the plate edgeCounterweight shifts and he settles upright
Electronics secured but serviceableSnap-fit shell, heat set inserts, M3 screws
Demo day table with the poster, laptop, prototype parts, and the finished sea lion
Demo day. Poster, video demo, prototype parts, and one very composed sea lion!

What I’d Change Next Time

The Ultimate Takeaway

The closed loop is what makes the sea lion fight back. Servos saturate. Loops have latency. Neither shows up in a block diagram. But wind a cable around a 3D-printed screw, swing a hammer head, and let PID do the rest. The sea lion balances. The circus should be calling any day now!