I wanted to learn modern machine learning by building a small walking robot and have it controlled by a neural network. I will get to that, eventually. That's the primary reason I chose the Teensy 4 over other platforms, it has the computing power to run some decently sized neural networks in real time.

So far it has been a project about servos, mechanics, robotics, kinematics, electronics, etc.

What it has become, so far, is a neat walking robot that is quite capable of slowly walking difficult terrain https://youtu.be/a22FzKibE3c. It is somewhat capable of trotting at a higher speed too but the software needs some love. https://youtu.be/MDsygNth5o0

Click image for larger version. 

Name:	Pose.jpg 
Views:	107 
Size:	152.1 KB 
ID:	19051

The heart of the beast is a Teensy 4.0 where I have used all pins but one on the normal side pinouts. 12 PWMs are controlling the servos, 4 ADCs read the foot sensors, 2 I2C pins talk to the MPU6050 gyro/accelerometer modules and 5 pins do SPI to the NRF24 radio.
The robot is powered by a 4 cell LiPo pack, which is total overkill, a 2 cell would be work perfectly fine. I have one switching voltage regulator for the servos to supply the 5-6V and one regulator for the fine electronics, Teensy and others. Since I didn't know if the Teensy supplied 3.3V would be enough there is another 3.3V linear regulator as well. I could probably skip that but I know that the NRF24 radio module is very very picky when it comes to getting a stable 3.3V.

Click image for larger version. 

Name:	Electronics.jpg 
Views:	119 
Size:	136.4 KB 
ID:	19052

The NRF24 radio sends all sensor data it has back to and old Arduino that relays it via serial to my PC, at 100Hz. The PC sends back commands from the game controller I use to tell the bot what to do. I'm working on modding and old PS2 controller to talk directly to the bot.


The leg mechanics is a bit strange. It's not like Boston Dynamics spot legs or most other bots you see people build. If it was a horizontal arm, and not a leg, the boston leg would be called a scara arm. My leg is a 5-bar parallel, or 5-bar scara arm, with an extension. The 5-bar is quite strong mechanically and it was easy to place the servos to fit all 3 axis per leg in a small package. The math is quite hairy though. I was considering a delta leg, but fitting the servos on a reasoanable way was not possible.

Click image for larger version. 

Name:	Leg.jpg 
Views:	98 
Size:	230.9 KB 
ID:	19053

It is very handy that the bot is pretty small, it's just 20cm long and weighs about 600g. It is totally harmless to both itself and it's operator. It has pinched my fingers quite a few times (those tiny 14g servos are strong) but never anything serious. I happily upload code that is never simulated, bugs out totally and sends all servos to their extreme, no harm done. It's just a funny pose. The digital servos cuts the power after a while if they can't reach their position.


The magic to getting it walk as good as it does is all in the software. The MPU and the foot sensors are critical input to be able to walk good, but it takes software to process that data and control the servos.
I have spent many hours coding on the kinematics, i.e. converting from x,y,z to motor positions (and back), and lots of 3D algebra, rotations, translations, etc. I am a CS major though, my home turf

For now it can only walk slow and stable, and do some shaky trotting. I have only implemented static balancing, it has no idea about speed and inertia. I quickly tried some simple stand on 2-leg balancing but failed. I hope that the servo lag/gearbox play does not make this totally impossible. It might. Boston Dynamics Spot can easily lift two legs and with (what looks like) no effort stand two legs.
If there existed tiny brushless motors, play-free gearboxes and reasonable motor controlles I would get them in a heartbeat. The RC servos are blunt machines.

Back to machine learning, the starting point of the project. My idea for now is to make it walk decently with hand coding, record a lot of walking and use that data to train a neural network. Once it can imitate reasonably I can let it control the physical robot, walk around and learn by itself. I just have to figure out a reasonable arena for it to train in, and how to get it back on it's feet when it falls over. And the magic of network design, reward functions etc. It was easier back in the 90's when I last played with neural networks, kohonen and 3 layers.