I decided to work on something smaller, using all the experience I gained with Kubik. This one is as small as I could make it, uses an Arduino Pro Micro for the brains, SG90 servos for the muscles, a 2S LiPo pack for power, and I plan on adding a Bluetooth later (for now it's tethered on a serial cable). Since I have some room in there, and the case is transparent, I'm also thinking about a Sharp distance sensor.
Because I don't like the relatively low level language that Arduino gives you, the code is basically just a servo controller -- listening on the serial for positions to set the servos to. This way I can put all the logic I need on the big computer and program it in Python. It will also let me use a wired gamepad for controlling it -- no need to muck about with the wireless ones.
So far I'm pretty happy with the mechanical design, especially with the fact, that it required no extra parts -- just the horns and screws that came with the servos, and an iPod Shuffle box.
An "exploded" view with all the parts:
I made a page with instructions and the code for it at http://sheep.art.pl/Micro-Kubik.
The Bluetooth module just came, and I see an obvious problem with it. It's slow. Extremely so. I will improve the protocol I use to send the servo positions, but I'm afraid that I will just need to put a lot more code on the arduino side, and send higher-level commands. Turns out that sending all servo positions at once and not reading the reply made it fast enough, so I don't have to learn how to use AT commands to switch the module into higher baud rate.
I hereby announce this project finished.
I want to slowly make the Arduino part of this robot smarter, gradually moving the inverse kinematics, and maybe even gait, code into it, and adding higher-level commands. But developing on the whole robot is quite annoying -- I have to open the robot, disconnect the arduino, connect it to the programmer, program, then connect everything back to try it. That's because the servo power and the arduino power are hardwired together. I might need to add a jumper in there, but in the mean time, I build this simple leg code testing facility:
Since I want to be able to recover the servos, no glue this time.
I played with OpenScad a little today:
I did some more work on the electronics. I removed the IR distance sensor, and replaced it with a 3 axis accelerometer, connected to the analog pins of the arduino -- I have more uses for that. I also designed a much smaller breakout board:
and that lets me fit an UBEC in there -- so that the servos will get a much more consitent voltage now and the battery will hopefully last longer. I still need to improve the arduino code.
I made some progress today. First, I managed to correctly use the AT commands to set the bluetooth module to 115200 baud rate, so now it can all work faster. Second, I connected a simple resistor bridge to the battery, and connected that to an analog input -- so now I can read the battery voltage. This will let me to fold up, disable all servos and just sit there when the battery gets too low.
On the bad side, I just discovered that Servo.writeMicroseconds() doesn't work the way I expected in the Arduino library, and that I was using just regular write() with angles the whole time (but throught I was using writeMicroseconds()). I need to use the latter for smoother movement.
The problem with writeMicroseconds turned out to be an off-by-one buffer overflow in some other part of the code, so all is well now. The movement got much smoother now. I also have some battery-saving mechanisms in there now. If the voltage of the lipo cells drops below 3.72V for longer than 2s, it will start beeping. When it drops for longer than 4s, it will curl up into a ball, shut down all the servos and refuse to do anything.