NokiMo
Pybricks
Pybricks

patreon


Building a ball balancing robot with SPIKE Prime

I’ve always been fascinated by robots that can balance themselves on a ball.

It’s one of those builds that looks like magic, but it’s ultimately just a fast feedback loop. The robot constantly measures the tilt of the robot using the gyro sensor and adjusts the motors to keep the robot upright.

I've published a tutorial for the MINDSTORMS Robot Inventor set previously, but it was high time for a SPIKE Prime Edition! You can find the step-by-step instructions here.

Pybricks contains several unique features to make this possible. Not only does it run about 20x faster than the original MINDSTORMS software, it also contains dedicated commands and blocks to measure the right (unfiltered) gyro angles, which is critical to make a robot like this work.

Leave a note if you give this a try!

Building a ball balancing robot with SPIKE Prime

Comments

It comes in several Duplo sets and Mindstorms sets, including the most recent one. Something similarly sized might work. https://brickset.com/sets/containing-part-4156530

Laurens Valk

DWoes it work on any ball?

Patrick Studios

Where can i get the ball and what size is it?

Patrick Studios

Totally! The 20x speed increase compared to the Mindstorms app is not an exaggeration. I worked with Dimitri to add his balancer to the official app, where we struggled to do all the math in under 30 ms, and that was just one axis! In Pybricks it takes about 1 ms. You can make a looptime equal to randint(0, 30) and it will still work :-) However, for this ball balancer specifically, the computation time is not the limit. The hard plastic ball has about zero grip. This means less opportunity to dissipate energy (which is important for stability). Also, since the wheels are so small, it is already close to maximum speed, so you couldn't make it drive very fast and have speed left for balancing. I'll also be adding a few tutorials for good old balancers with wheels. Those can go really fast and totally work with the Xbox Controller.

Laurens Valk

Will the feedback loop be robust to adding the XBOX controller readings?

Daniele Benedettelli


Related Creators