It's cute, It's polite and it is really deadly. It's a turret from Portal. It moves, has light, has sound, and something that my previous Portal project did not have: Camera tracking.
The turret is controlled with an Arduino and a PC. The arduino handles the movement and the light, the PC processes the video from a webcam to decide where the turret needs to aim and provides the sounds for the turret.
When no computer is present, the turret automatically switches to manual control. In this mode the turret can be controlled by a joystick, though there will be no sound.
The turret is full 3D printable and requires very little additional tools to make. This does not mean that this is an easy project, but it is manageable with some basic 3D printer, electronics and programming skills.
For more projects like this, go to my site: http://ytec3d.com/
Step 1: Design (and Design Flaws)
The design was the the hardest part of this project. Not because there are no reference images or because the turret is that difficult in its design. It is because the turret does things that are not physically possible.
At first I wanted to make this turret so it could open and close as well. The issue is (as you can see in the images) that the guns of the turret almost touch each other when the turret is closed. There simply is no room to have a turret with all movement that can also open and close. The solution was a compromise where the turret only moves and doesn't open.
Also the design doesn't include a real space for the electronics (as seen in all the photos and videos). After I built mine i did a last wave of improvements where I hollowed out the top of the turret. There is some space there now to place electronics if you can manage to make them small enough.
The rest of the design was only a matter of time. First the turret was designed in one piece in Solidworks to get the design right. Then this part was cut up into smaller pieces and mechanisms were added to make the guns and eye move. All in all the design took between 40 and 60 hours (I don't really track the time).
(Reference image to the right made by: Tyler Garrison, for another turret project by CitizenSnips and modified by me to show the flaws in the turret's original design)
Step 2: Gathering Materials
To build the turret you will need several materials:
- roughly 500g of 3D printing filament
- several grams of clear filament (for the eye)
- 2 micro servo's
- 2 standard servo's
- 1 Arduino
- 1 5mm red led
- 4 5mm white leds
- 1 laser diode (6mm diameter)
- 4 npn transistor
- 4 220ohm resistors
- 4 100ohm resistors
- 5 100uF electrolytic capacitors (or similar)
- M3 screws
- 2x M4 25mm screws
- 2x M4 self locking nuts
- 1 608 bearing
- 115mm aluminum tube 8mm diameter
- 1 5V voltage regulator (at least several amps)
- 1 Joystick module for arduino
- 1 Beefy battery to power (I used a 3cell 3000mAh LiPo battery)
- White, green and dark gray paint
- A PC with a webcam (for the automatic tracking)
- (1 speaker (to make the turret talk))
- Iron wire for the antenna and legs
Also you will need some tools
- Basic tools (screwdrivers, pliers)
- 3D printer
- Soldering iron
- A breadboard
Step 3: Start Printing
The next step is to start printing. For this you will need (you'll never expect this...) a 3D printer. Now not every printer will do. I take great care to design things that require as little support as possible, but in some cases splitting up the design into even more pieces is too much additional trouble. For the turret you will need a 3D printer of at least 120mm x 120mm x 120mm (roughly 5"x5"x5") that is comfortable with support material. I used my UP Plus 3D printer that I won last year at the UP2013 contest. I has served me well the last year.
For a complete turret you will need the following parts:
- Turret body bottom bottom
- Turret body bottom left
- Turret body bottom right
- Turret body coupler (2x)
- Turret body top
- Turret eye swivel pan (in clear plastic)
- Turret eye swivel V2 (in clear plastic)
- Turret gun left bottom
- Turret gun left gun
- Turret gun left top
- Turret gun right bottom
- Turret gun right gun
- Turret gun right top
- Turret swivel tilt
- Turret swivel V2
- leg front left
- leg front right
- leg back
All of these parts required about 20 hours to print on my UP! at 0.3mm layer thickness. It took about 500g of PLA filament.
Step 4: Putting It Together
With all the parts printed it's time to assemble the turret. Most of the assembly is too complicated to explain in just words, but the pictures also do a great part of the explaining.
The first thing to do is to tap all of the M3 holes with an ordinary M3 screw or bolt. Most screws screw directly into the plastic, reducing the amount of nuts needed. (photo of all M3 holes)
One of the micro servo's needs to be modified so it has the wires com from the bottom instead of the side. There simply wasn't enough room to have the wires com from the side. This servo also needs to get on of it's flanges trimmed so it will fit, bus this will show itself when you are mounting the servo.
Both sides of the shells of the guns (turret gun top and bottom) were linked with 2 M3 screws. Because 3D printing leaves a small amount of shrink in the first layers, the bottom is slightly warped. This left an ugly gap between the two shells. I fixed this by welding the two pieces together after linking them.
The 608 bearing was press fitted in the part named "Turret swivel V2". Then the servo circular mount was attached to the bottom of the swivel. This swivel assembly was attached to a centered standard servo.
When assembling the eye, first press fit the laser into the eye hole. Center the micro servo with the hole at the bottom an mount the eye swivel on top. Then use some small pieces of 3mm rod (I used pieces of M3 thread) to fix the eye in the swivel. Some glue was used to fix the rod in the eye.
The remaining servo's are centered and horns are attached that will be connected to the moving parts with linkages.
Next the servo's are attached in the frame. The standard servo's are attached by screwing them to on of the halves of the body, the micro servo's simply slide in place. When later the body is done and both halves are joined, the micro servo's will be stuck in between.
When all servo's are centered and everything is in place, the linkages can be placed. I used wire to connect the servo arms to the holes in the eye and gun swivel. there are no real measurement here to follow, just make sure that the linkage holds the part in the middle.
Lastly the led in the eye and the leds in the guns are placed. The leds in the gun should fit quite well, but you can use glue to stick them in place. The led for the eye is jammed between the two halves and doesn't require any glue.
The legs are cut out of 4mm rod and 3mm thick aluminum. I simply followed the guides to get all parts in the right shape. The aluminum legs slot in the 3D printed leg pieces, though some force may be required. The wires of the leg fit in the 3D printed base and legs pieces without too much trouble. Next use 2k epoxy glue to glue the legs into place. This was the hardest part because the parts keep moving before the glue sets.
Lastly the antennas are cut from some 1-2mm wire and bent according to the guides. The biggest antenna goes in the outer most hole, the shorter straight antenna goes more towards the center.
Step 5: Make a Base
For the turret I made a base out of some plywood I had laying around. The turret refused to stand on its own legs and the added mass makes it all just a tiny bit more stable.
First I cut the base out the plywood with a jigsaw, then I used a router to bevel the edges.
The legs were glued into place with 2 component epoxy glue. The small drops do show at the bottom, but the turret is never ever getting away from the base anymore.
Step 6: Wiring the Turret
Most of the paths of the wires are defined. I have included a picture where I show all of the designed parts.
I did my turret with the electronics outside of the turret. There is a hole in the bottom of the turret where the wires can go through. It should be possible to mount a small Arduino and all electronics in the top of the head, but with my version of the design the space wasn't there yet.
I added connectors to all loose wires and added additional wire to the wires that were too short. The arduino, regulator and battery are on the base, covered by a nice piece of cloth.
Step 7: Painting and Decals
Normally with these project I would use filler primer before painting. This process takes a lot of time, is a pain in the butt to do and doesn't even add that much to the quality. Because the turret is only smooth shapes I decided to only sand the turret and then paint it.
The turret has only 3 colors: White, dark gray and green. I did print all the parts in white but I painted the white parts white again to get the colors right and to mask imperfections.
Print the decal sheet on a color laser or inkjet printer and cut 2 of the left most decals out of the paper. Use clear adhesive to glue the decals on the side. Then use some of the green paint to blend the decals to the rest of the paintwork. On the pictures the decals seem way too shiny, but in reality the match almost perfectly. The camera does not capture it like the human eye does.
Step 8: Electronics
The electronics control the turret. It consists of connections to servo´s, transistors to power the leds and laser, a joystick to give the turret input an a voltage regulator to convert the voltage of the battery to a nice 5 volts.
Everything was done on a breadboard 1: because I didn't have time to make a circuit and 2: because after I finish this project I don't think I will do that much with the turret again. I have included a schematic so anyone can repeat the result.
Simply follow the schematic to connect all the correct wires to the right ports. Alternatively you can wire it up your own way and modify the ports in the firmware.
The resistors might have a fairly low value, but otherwise the led and laser don't give off enough light. It will shorten the life a bit. If this is a problem you can replace the 100ohm resistors for the eye and laser with 220ohm or 330 ohm.
Step 9: Firmware and Software
Step zero, if you have never used an Arduino, go to their site and install the software.
Download the firmware and flash it on to your Arduino. If you connected everything the right way the lights in the eye should power up when you power the system.
The firmware has two modes:
Mode 1 is the follow joystick mode. It reads the analog reading coming from the joystick and converts it to a servo position.
Mode 2 is the serial slave mode. It reads the serial stream of data transmitted by the software and converts it to servo movement. The turret will automatically switch to serial slave mode when the software starts. It will however not change back automatically.
Additionally the firmware protects the turret from rapid movement by slowing down the movement to an acceptable speed.
For the full experience download the software and run it. The software handles the camera tracking and sounds.
The camera can be anything, but I used my laptop camera since it is the only camera I have that worked. Simply plug the camera in. In the ini file you can change the camera the software picks by changing the number.
Simply put it looks for a color in the HSV color model. It looks for this color on the screen, filters the color away from the other colors and filters the noise away. Then it takes the average and sends this over the serial line to the Arduino. It also makes the appropriate noises depending on what happens, from firing to acquiring a target.
The serial port can be selected in the ini file, go to device manager and see what port the Arduino is on. The software only supports com ports up to 9, so if the Arduino is on a higher com port, you will need to change the Arduino com port manually to a lower number.
You can select the color by moving the sliders. It isn't RGB because HSV differentiates a lot better between colors. It is a bit hard to use if you don't know what to do, so a simple manual. Open all lines (move min to left and max to right) so the screen is completely white. Then slide the top 2 bars until you have the color you want (don't worry about the noise yet). Next you can filter the noise out by dragging the remaining 4 sliders. The software is now tracking any object in the color you selected.
The software is hugely based on this example http://youtu.be/bSeFrPrqZ2A of color tracking in Open CV. Another shout out to my colleague (He who does not want to be named) who did the software. Without him I would not have been able to have this turret done in time.
This software (and firmware) have been written in a fairly short time frame. both have a tendency to crash or jam. For the software, simply restart until it works, for the firmware, push reset to set the Arduino.
Step 10: Final Thoughts
The turret project was not a straight forward project. I have started and stopped it twice before I got it good enough to finish. The design was extraordinary difficult because of the original design in portal and my demands for this project. Even after many drawing hours the design still wasn't technically finished. Some features like the legs and "where are the electronics going" were not tackled until the assembly was halfway done. This does show if you know where to look.
Having said that, the turret has been one of the more rewarding projects. It was a fairly small print with only 20 hours, it was quick to build and it has a surprising amount of functionality. It also has something that the GlaDOS lamp did not have, but was requested a lot afterwards: tracking. This time I had someone near me who was capable and willing to write the code to track a person. At this point I am capable of writing such a piece of code, but not in the short amount of time I had left before the deadline. Yes both the firmware and software crash fairly often but both do work.
All in all the turret was a great project with just the right amount of problems to keep it interesting.
Second Prize in the
Battery Powered Contest
Participated in the
Epilog Challenge VI
Participated in the