PiZero Bot V1.0 |
The tin is only slightly bigger then the Pi Zero |
A thin, PCB sandwich. |
Hardware is of little use without software to control it. Normally I'd be looking at connecting up a PS3 DualShock controller to drive the bot around, however that isn't quite so easy to set up over a serial link, so it was time to look at a different way to control a bot. A few weeks previous I had taken a look at the GPIO Zero python library and knew it had a variety of helper classes. Taking a look at the currently supported devices I found that it not only had a GPIO based Motor class but a fully implemented Robot class, allowing a 2 motor robot to be up and running in 3 lines of python.
from gpiozero import Robot
r = Robot(left=(23,22), right=(25,24))
r.forward(1)
r = Robot(left=(23,22), right=(25,24))
r.forward(1)
A couple of tweaks to the connections to make sure the motors were going in the right direction and it was time to fit everything inside the tin. Being a metal tin it was conductive on the inside and, as I didn't want a short, I covered it as best as I could with Kapton tape, adding extra tape to the PiZero itself for extra safety.
With the motors and ball caster glued into place, and the battery held in place with blu-tak, PiZero Bot V2 was almost ready to go. I extended the python code to listen for the WASD keys to drive the robot from my phone and it was off for a test drive.
A relatively successful trip, although the battery appeared to be dying towards the end as it was starting to struggle to move. I know the battery wasn't fully charged at the time, so I'll have to test again to see how well it lasts. I do have a larger battery that is around the size of the mint tin, but I was avoiding using it as it adds to the height of the robot, and that somewhat defeated the point of making the smallest robot I can.
Of course its also a little tricky to control when driving it via key presses alone, but it should be possible to write an Android app, or similar, that can implement an analogue controller that communicates over serial to the Raspberry Pi.
As ever there is always more to do. I still want to add at least one sensor to this bot, probably a proximity detection one, so it can be left to drive around by itself. However with all the wires stuffed inside it there's not much room to extend it cleanly. I may have to look at designing my own PCB so I can get rid of most of the wires, freeing up some space to connect up a sensor, punching some holes in the front of the tin to allow it to be connected up. But that will have to wait for V3, as I have some other projects that need finishing up first.
Leo
Nice work! Regarding the power: are you running the Pi and the motors from the one battery? If so, how have you connected them? Also, have you considered using a Wiimote for control, or did you specifically want to use the phone?
ReplyDeleteEverything is running off the one battery, with the Pi connected to it via the Zero LiPo board and the motors powered from the 5V pin on the Pi itself. Ideally the I'd connect the motors directly to the battery, but that was hard to squeeze into the space.
DeleteI'm currently using the phone as its not a full Bluetooth dongle on the Pi (Its serial only). To use a Wiimore, or other controller, I'd need something else to connect to it and pass the information over the serial link. A second PiZero with a bluetooth dongle would most likely work for that.
Hey, congrats on fitting it all in such a small package! Where did you get the motors, tyres and caster from?
ReplyDeleteThe motors I picked up for free at the Raspberry Pi Birthday Bash a few years ago. They are the vibration motors from a mobile phone.
DeleteThe tyres are from a Meccano race car set I grabbed in a Christmas sale and the caster is a Pololu ball caster, which can be found in various stores.