Spider robot powered by Adafruit Feather boards.
I got the gait code to work on the small crab robot -- actually it only needed some adjustments for the smaller legs. I'm a bit disappointed about how slow the code runs on the M0 -- I didn't even need to add delays for the servos, the calculations take enough time for them to move into place. Oh well. That means the gait is still jerky (because I couldn't do the continuous servo updates), but it works fine.
Then I worked a little bit on the robot's "intelligence". Right now it only has only one sensor, the distance sensor in front. So its behavior is as follows:
And that's it. I also added exception catching, so when the legs get tangled into an impossible position (that happens sometimes), they are moved into their home positions, and then the program resumes.
This procedure gives the robot a nice behavior. It will walk towards things to examine them, and follow people, but if the things don't move, it will get bored with them and walk away, looking for other interesting things.
I'm considering adding one more state, for when it gets bored with scanning -- perhaps it could just shut down and go to sleep then.
I'm slowly porting all my robot code to CircuitPython for the little crab robot, and I got as far as body kinematics before I ran out of memory on the Feather M0, so next step is some optimizations.
I also decided to put a distance sensor on this little guy, so that it can react to the environment -- since it doesn't have wireless connectivity, I can't make it just a remote controlled drone (and I don't want to).
So I finally sat down and ported that Arduino driver for the VL53L0X sensor to MicroPython. Well, mostly ported -- there are still some parts that I need to implement, but it already does some readings. The code is at https://bitbucket.org/thesheep/micropython-vl53l0x but it's definitely too big to fit on the M0. So I decided to look for another sensor, preferably with I²C interface, and I found the SHARP GP2Y0E03 in my drawers -- the same sensor that #µBob biped robot uses right now. I quickly wrote a simple driver for CircuitPython for it -- the code is at https://bitbucket.org/thesheep/circuitpython-gp2y0e03 -- and I attached the sensor to the robot:
You can see I also arranged the cables neatly, and added the rubber socks on the legs.
Even though I had a ready library for the sensor, getting it to work took some time. You see, the PCA9685 chip that I'm using here for controlling the servos uses two I²C addresses: 0x40 and 0x70 (one for the individual chip, and one for a roll-call for all chips on the bus). But the GP2Y0E03 sensor also uses address 0x40 by default. I could mess with the PCB, solder some wires to the address pins od the PCA9685 and make it use a different address (I think I will in the next version of the PCB), but a quicker route was to change the sensor's address -- you do that by burning e-fuses on it to specify the new address. The procedure is a bit complex, but there is a ready Arduino sketch that does it for you, so I gave it a try. Without much thinking I changed the address to the 0xE0, which was the default in that sketch.
Wait, aren't I²C addresses only 7-bit? Where did 0xE0 come from? Well, that's the 8-bit notation, including the read/write bit. To get the 7-bit address you need to shift it right by one.
I tested the sensor with the changed address, and it works beautifully. Now, time to put on the robot and make it do some things. But wait, it stops working on the robot, just returns 0 all the time. Wait a moment, what is 0xE0 shifter right by one bit? Isn't it 0x70, the other address my servo driver uses? Argh!
Fortunately, I had a second GP2Y0E03 sensor in my stock, so I changed the address in another one (this time paying more attention) and everything works perfectly now.
Now I only need to rewrite all this code into as few functions as possible, to make it all fit in there.
I'm slowly moving along with this robot, despite the long silence. A few iterations of the PCBs, a few changes of direction, a hour of coding here and there, a lot of frustration -- but I finally have the first, very shaky and suboptimal, gait.
You can see in the video that I'm experimenting with different leg proportions -- basically trying to make this robot faster. The SG92R servos seem to be handling the longer legs without problems, even at the standard 50Hz signal. I can always increase the frequency to get some more power from them, since they are underpowered anyways.
Of course a lot remains to be done there, most importantly I want to update the servo positions all the time, controlling their speed and exact path -- and not just give the end position and wait for them to get there, like I'm doing now. This way it should be much less shaky and also able to respond to any sensors faster.
However, I realized there is a fatal flaw in my world domination plans. Those robots are much too unreliable to actually enslave the humanity properly, so I need something to give them an edge over puny humans. My original plan of making them wear hats seemed to be a move in the right direction, so I decided to expand on that and make at least some of the robots as cute as possible -- this way the humans should be less likely to fight back, even if they get a chance due to some miscalculation.
I recently received a pack of new type of servos, SG50. They are not actually new, but I never used them before, so they are new to me. They are in the category of sub-micro servos, smaller than the popular SG90 and other 9g servos. They make nice stubby legs:
Apart from the childish proportions, I also added a pair of RGB LEDs as "eyes". Of course they will change color according to the status of the robot. I am also using a smaller Feather board here, the M0 Basic, which means it runs on CircuitPython, and not MicroPython.
The plan is to finish it within a week, so that I can take it with me to PyCon.US and show it off there.