Of course, what we're talking about here isn't Jeepers Creepers, or I Know What You Did Last Summer. Simply put, Rosie disappointed in her last outing. We promised you "crawly creepy", and instead, we got "a slightly bizarre demonstration of a robot pretending to crawl across an anonymous hotel room floor. Badly." (which incidentally isn't a great film title). No, definitely not Halloween. More Mr. Bean.
But everything / everyone / every wannabe robot deserves a second chance to
Apologies in advance to all STEM educationalists; this is perhaps one blog post too far for your budding school curriculum!
You don't want to be the tool without the tooling:
- A Raspberry Pi 3, running Raspbian OS
- As before. Yes, you will need your very own 3D-printed humanoid, equipped with servos, and a servo controller of some description. We did eventually come to upgrade our servos in this episode, as you'll read about later.
- We'll be back again using our 3D printer; this time to print out a "scary" mask
- All fearsome mechanical things require bright red LED eyes. And slightly less scary Resistors (we used 330Ω).
- We try desperately to make the mask look "realistic" using sandpaper, primer, acrylic paint and some varnish (the last one, we actually forgot to buy). Oh yes, and we also used bristles from a brush for the facial hair. Quite clearly, the highlight of our achievement.
- You could go the extra mile and give your creation a costume. We became quite lazy by this point (a similar pattern that emerges across our posts), and gave it something that resembles a... erm... cape. That's ok, because - it turns out - capes are quite creepy.
- Some sticky tape to attach loose stuff together... Gorilla Tape will do.
Chequered history:
Building Rosie 2.0 - naturally - assumes that there is a Rosie 1.0. For that reason, casting your eyes over the organised chaos that was Rosie and Rosie Patrol is highly recommended.Having said that, most of the material here is based on what was attempted using Mr. Ted-E U, and more recently, Crawly Creepy.
Bit by byte:
- Get Rosie 2.0 all ready. Again. Maybe it's best not to have any kids nearby this time.
- 3D print a scary mask found on the internet. Thigiverse is a good bet.
- Solder resistors to the LEDs, and cable them up to the GPIO pins of the Pi
- Dress the robot with the appropriate attire
- Make the resulting thing crawl (again), preferably to eerie music. We tried to use Tubular Bells from The Exorcist... and found out that it is copyrighted for use on YouTube... Thanks Mike Oldfield.
You ain't seen nothing yet:
The mission here is to try and re-use Rosie 2.0's basic frame to make a monster that can crawl across the floor. We ought to take this a little more seriously than usual, and go all out with the dramatic effect.To this end, we'll print off and paint a scary mask, and attach some red LEDs to it. Then we'll beef up the servos we have, and attempt to get the robot to crawl across the floor.
Erm... all in the name of science (or so we keep telling ourselves).
Detail:
First of all, all creepy things have a hideous face, or wear a mask (which incidentally looks like a hideous face)... according to the laws of scary movies at least. You may have noticed that we abandoned the big, clunky "box head" of Rosie's pretty early on. The advantage is that we can now - more easily - attach random stuff to the head via the rather anonymous-looking rear face plate. A supposedly scary mask is no exception.Now, we need some inspiration.
What if there was this thing that roamed around uninvited while you sleep, study, work, and harvested all the things that you think, write and say, with the specific aim to brainwash you. All while their masters huddle together in a now abandoned office (something about bankruptcy?), discussing how best to engineer you into thinking what they want you to think. Nope, we're not talking about LinkedIn Influencers. And besides, this plot is too far-fetched, and quite frankly, a little too scary to ever be real. Instead, we'll simply resort to calling our prototype Cambridge Troublitica, as apparently, Raspberry Pi are based in Cambridge, and in this instance, it will be used solely to create the illusion of some impending trouble (if by trouble, we mean making a Raspberry Pi-powered robot crawl using Python, while wearing a 3D-printed mask).
Firstly, for the mask itself, we turned to a trusted source of printable models... Thingiverse. And we stumbled upon this mask that looks adequately scary.
Thanks Killonious (Peter Snyder) for this great design. It's even got a convenient gap for its mouth, which could quite easily be used in the future to carry a concealed Pi Camera for some top-notch snooping. If you like his work, you can support him on Patreon.
We want the mask printed in a decent size, so we've sliced this demon horizontally at its forehead using our 3D print software (FlashPrint). This way, we can exceed our build volume when the pieces are amateurishly glued together (amateurish - because we don't quite manage to conceal the parting). We also don't need the full depth of the mask, so it's been truncated in height as well, and the bottom half discarded. The model itself is pretty complex with lots of overhang, so the 3D print will be spewed out of the printer with a raft and support. In other words, it's not going to look very pretty immediately after being printed, and we'll have to use our pliers and palette knife to remove all the excess demon fat.
What? 12 hours to print? Yes, that's unfortunately how long we had to wait for this happy chap's expression to materialise on the build plate of our FlashForge Finder. And once it did, we still had to spend a good 10 minutes removing all the supports and raft from the rather large heap of white PLA.
But once all this is done, it starts to resemble something that perhaps we ought to start to think about running away from, rather than patting it on its head.
Now, unlike all the Rosie parts we've printed to date, we would also like to put some effort for once into making this mask look half presentable. The "fresh white PLA" look just isn't going to cut it this time.
From reading various articles about this online, like this one, we think this is what we need to do:
- Drill a few holes so that we can attach the mask to Rosie's head. Ours are 2mm holes, drilled 90mm apart at the eyeline.
- Glue the bits together
- Use coarse sandpaper to try and smooth the 3D print
- Spray on some primer
- Use less coarse sandpaper to smooth the print once again
- Repeat the primer and sandpaper-ing (using a finer grade each time), until you're basically bored
- Paint the model using acrylic paint. Repeatedly re-paint to get the colour thick.
- Coat with varnish (this is a step we didn't actually complete... due to the fact that we went shopping for some varnish, and ended up getting something totally not varnish). We may decide to revisit this step at some point.
Don't worry about the cables protruding out from the mask in the last picture. Actually, please do. As we might as well talk about *them* now.
All naughty robots have red LED eyes; yet another one of Einstein's super-clever observations that have shaped robotics ever since.
We won't be using Rosie's LED dot matrix display here. It just doesn't have that necessary scare factor. Better - we thought - might simply be two red LEDs.
There's plenty available online about how to light up simple LEDs using the Pi, Python and GPIO pins - such as this excellent tutorial from the The Pi Hut. There are several golden rules when doing this:
- Always use a resistor in series with the LED, otherwise, you will damage your Pi by drawing too much current
- The longer leg of the LED needs to be connected to positive voltage (i.e. Pi's GPIO pin which provides a "high" signal of 3.3V), and shorter one to the Ground (0V)
V (Voltage) = I (Current) × R (Resistance)
...which can also be shuffled around to be:
V (Voltage) / R (Resistance) = I (Current)
As the GPIO "high" signal of the Pi dishes out 3.3V, using a 330Ω resistor should mean that - in theory - we'll be drawing only 0.01A (10mA) of current from each GPIO pin. This should be enough to power the LEDs, but also stay within the limits of the Raspberry Pi which are detailed in the FAQs.
The GPIO pins can draw 50mA safely (note that that means 50mA distributed across all the pins: an individual GPIO pin can only safely draw 16mA)
Next up, this is how we cabled the LEDs - although you're free to chose any combination of GPIO and Ground (0V) pins.
Pi GPIO | LED |
---|---|
37 (BCM 26) | LED Right + |
39 (Ground - 0V) | LED Right - |
36 (BCM 16) | LED Left + |
34 (Ground - 0V) | LED Left - |
Don't forget to check this excellent resource at pinout.xyz if you are unsure about the pins.
There really isn't much else to this; so let's launch straight into IPython and run a few commands.
ipython3
We should be familiar with all of these commands. All we're doing here is setting up GPIO pins 16 and 26 to be used as standard GPIO outputs, and address them using the BCM numbering. Then we set them high to send out our 3.3V signals to both the LEDs.
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(26, GPIO.OUT) GPIO.setup(16, GPIO.OUT) GPIO.output(26, GPIO.HIGH) GPIO.output(16, GPIO.HIGH)
Yep, that's it. Sorry.
Hopefully we've managed to turn both LEDs on... and feel gravely disappointed that there wasn't much else involved.
Clearly, setting GPIO.LOW will allow you to turn them off. You could also flash them in a loop with time.sleep().
GPIO.output(26, GPIO.LOW) GPIO.output(16, GPIO.LOW)
This bit of code clearly needs to be embedded into a larger Python application at a later point. But - for now - we've proven that we can control the LEDs in the mask's eyes. And we don't plan to do any more with this.
We finally attach the LEDs to a 3D-printed bar that runs across the back of the mask. Our 2mm holes happen to be drilled 90mm apart, so all we did here was print out a crude piece with holes that fitted these dimensions.
And that's about it for the mask. You could quite happily power the LEDs off a battery, and hang this up on the door at Halloween time if you don't want to bother with the extra robotics stuff. As it happens, our blog is still called Rosie the Red Robot, and so we're unable to use that excuse.
It's now time to try and address another failure of the previous episode: motion. We established pretty early on that Rosie would not be going anywhere, anytime quick. And it was all down to torque (or the lack of). We discussed several ways to overcome this. But in the end, we procured additional horsepower in the form of some beefier servos.
The particular servos we targetted on eBay were the HS-645MG, its digital sibling HS-5645MG and HS-5625MG. As you can see below, these have significantly more torque than the HS-311s and HS-422s we were playing with... hence officially stamped with the "oh yeah, this is what we're talking about" quality rating.
These are still "standard size" HiTEC servos. So thankfully, it's a like for like replacement without the need to modify any of our servo brackets. And we continue to use an Adafruit PWM / servo HAT and its PCA9685 chip that specialises in handling PWM signals, and send it instructions via Pi's I2C serial protocol. We're close to exceeding 16 channels (i.e. servos) with the two additional neck motors...
Armed with a dozen of these servos, we might reach another unfortunate milestone... one in which we're unable to draw sufficient current from our 5V / 10A mains power supply. However, we'll cross that bridge when it comes... Clearly, when Rosie 2.0 eventually moves onto some form of batteries, this might become an enormous issue.
Here are the various schematics for the servos.
So what does this all give us? Something that looks a little like this, as it happens. Now, we don't often congratulate ourselves for making something that meets our objectives (because most of the time we fall short!), but here's something that looks unnervingly spookier than we anticipated.
And now for the moment we've been waiting for. Let's re-run the crawling routine once again, using Python, to see what happens. Notice the perturbing cape that Rosie (oh sorry, Cambridge Troublitica) is now wearing. It transpires that it's perfectly suited to conceal all the robotics that make up her body, together with the USB battery pack and the mains adaptor.
You'll see that we didn't make many changes to the crawling motion from before (we probably should have), but the improved power of the servos allow the limbs to overcome gravity and friction better. With further tuning of the servo positions, it should be possible to make the crawling action smoother - and faster.
The music is Papua New Guinea by The Future Sound of London.
And this is exactly where we'll leave this little detour... as quite frankly, this might be one sequel that managed to better the original. Moreover, it's actually getting quite creepy. Maybe, we'll wheel it out again at Halloween. After all, this should teach the kids not to trick or treat.
Doing the devil's work(out):
We did eventually atone for our mistake, and purchased a clear acrylic varnish to coat over the paint with. We went for the "gloss" effect, and as a result, ended up with a monster that looks like it is on its way back home to a hellish afterlife, after a particularly gruelling session at the gym where the Lucozade was on tap.More importantly, the varnish does also play a crucial role in protecting the painted finish, with a super thick, hard layer of hydrocarbon solvents produced from oil. If you want less sheen, "satin" or "matt" finishes should also be available from your brand.
Here's a little noddy reminder to ourselves for the future (i.e. thinners are not varnish). Although we can't promise that we won't walk out of the shop again with something that we were totally not intending to get.
All these chemical products are quite clearly not good for your health. Always follow the instructions that come with the product, and take the precautions that are prescribed. For example, do not touch, inhale or ingest thinners, varnish, primer, glue or paint. Instead, invest in the appropriate precautions - such as gloves, mask and protective eyewear - and carry out the work in a well ventilated area, which is likely to mean outside.
Sorry kids - other than possibly the acrylic paint - these things are strictly off limits.
Go and see the doc:
Here's the "oni" mask on Thingiverse that we're using:The actual "thing" we made can be found on Thingiverse here:
The Pi Hut has an excellent tutorial on how to work with LEDs with the Pi. It's important to read one of these as you can end up frying your Pi.
Yes, we know there are other servo manufacturers, but we do (rightly or wrongly) appear to be hooked on those made by HiTEC.
We're continuing to use the Adafruit 16-channel PWM / Servo HAT, for which the documentation is here:
There are detailed instructions on how to paint your 3D-printed PLA model here (which we tried to follow):
Comments
Post a Comment