|Watch An Inverted Pendulum - Arduino-Driven|
|Written by Mike James|
|Saturday, 02 June 2018|
If you have never seen an inverted pendulum in action - it's fun. What is even more fun is implementing one. Is it IoT? Is it control theory? Is it AI? It can be any and all - and did I mention it's fun?
What is an inverted pendulum?
Well if you pick up a stick and try and balance it on your finger you have the right idea. Most inverted pendulums are implemented as a small driven cart with a lever pivoted at a hinge on the cart. The cart can move left and right and by doing so it can apply an acceleration - or if you like a force - to the end of the pendulum:
There are a number of variations on the basic idea - the one in the video, for example, has a 360 degree pivot and so starts from a hanging down position.
This is a classic problem in control theory and it was one of the first problems I solved using reinforcement learning - but it was only a simulated inverted pendulum, the real thing is so much better.
Ben Wiener and Philip Zucker built ZIPY - Zippy Inverted Pendulum Yakshave - after taking a course in under-actuated robots and wanted something that wasn't just a "lame simulation".
The real world also has a way of making things more difficult than a simulation. The hardware is a 3D printed cart with a DC motor and belt drive. The pendulum, a paint stirrer, is hinged on a rotary encoder which measures the angle. A second rotary encoder is attached to the belt and gives the position of the cart. The controller is an Arduino Uno, which limited the precision to 600 positions per revolution.
The software implements two controllers - one to get the pole swung up into position and another to keep it there. The balancing controller is based on a linear quadratic regulator (LQR) implemented in Python.
You can see the results:
So far it is interesting to discover what didn't work. Monitoring the position using markers and OpenCV vision system sort of worked, but was more difficult than expected due to spurious objects in the frame and the processing delay. So far they haven't implemented a reinforcement learning algorithm.
If you fancy trying your hand all of the code and the 3D printer files are available. It is worth doing projects like this just to find out what the world is really like.
or email your comment to: email@example.com
|Last Updated ( Monday, 04 June 2018 )|