This tutorial makes use of the Adafruit 16-channel raspberry pi servo hat, although any PWM servo driver will do. Detailed instructions on how to solder on the headers, attach the servos, and affix the hat on the raspberry pi are included here:
This tutorial assumes you have connected 6 servos to the servo hat (positions 0:5).
A point of note: The MG996R Servos recommended above can draw several amps of current. Please ensure that the power supply you are using for your RPI is isolated from the servo power, or else large current draws can cause brownouts on the pi. I used my desktop DC power supply (Long Wei PS-305D) because I had it laying around, but it is likely overkill:
Detailed installation instructions are included in the README.md. In short, you will generally start at the bottom of the list and work up. You can set different servo positions directly using menu option #3, selecting a servo, then inputting a position. Once you have the robot in the location of interest, you can list the servo positions. These positions can then be added to create a teachpoint.
Blanks indicate not to change a given servo position, while values will move the servos in parallel to the location(s) of interest. A human readable name (Position) is what will show up in the menu for selection.
In this file, semi-colon is the delimiter, and commas represent lists within a given cell. You can have a series of teachpoints for a given sequence, and a list of similar length with associated delays.
Every project leaves some work undone. It might be useful to provide teachpoint or sequence addition via the cli menu, instead of hand editing the CSVs. Any other good ideas on how to improve the software, please submit a PR!
This is a maker guide for creating a robotic shark that you can drive with an android mobile device. The body is comprised of three separate pieces of acrylic, that are surrounded with oscillating el-wire to give the appearance of motion/chomping as they flash. The base is built on top of the Cherokey 4WD robot chassis. This chassis will work with a variety of microcontrollers, of which I chose to use an Arduino Uno. Complete bill of materials and build instructions are included below. If you are going to fire in an recreate, please pre-read the lessons learned in the appendix so you can avoid some of my mistakes!
I made a few small modifications to the default build. First, I added an additional standoff to make the interior section slightly taller, to allow for a little more space for the relays, inverter, and Arduino shield.
I made a small plastic piece to hold the relays in place. Originally I had 4 here, however 3 ended up being sufficient for the final project. These screw into the acrylic holes using M2.5 screws, then the whole assembly is screwed to the underside of the top plate of the Cherokey:
The inverter fits directly behind the Arduino in the center of the chassis, and can be affixed using small zip ties to hold it in place:
Relays are essentially electrically operated switches. In normally open (NO) configuration, if the input signal goes high, it closes the switch, and vice versa when the input signal is low. Relays isolate the input trigger signal, from the switch on the right hand side. Here I chose a mechnical relay, which physically moves an internal component to connect the circuit. Other options include MOSFET relays, which are better for high speed switching (e.g. PWM) applications. The Tinkerkit relay shown here is discontinued I believe, but at the time of writing this article, there are still some in stock at Mouser. Any other mechanical relay should do just as well.
According to the diagram above, we need to provide +5V, Ground, and the input signal. For each relay, we also need to have the middle input pin connected to a digital output pin on the Arduino, such that we can control the state of the switch through software. These are shown as green, orange, and yellow wires in the diagram, and are connected t0 pins 8-10, as pins 0-7 were used for controlling motors and talking with the bluetooth adapter. In order to make the relay connections, I used the standard Tinkerkit wire, and soldered headers onto the Arduino shield for quick disconnect.
Additionally, we need to wire up the opposite end of the relay to turn on the el wire when the input wire is active. In order for the lights to be active, we need to complete the circuit with the inverter. The lights will turn off, if even one portion of that loop is broken. We will be using the relays in normally open position. This means that if there is no signal on the input, the switch is open, and the el wire is off. If the input wire on the left is active, the switch will be closed, and the el wire will light up. At the completion of this stage, we have three independent software addressable el wire pieces that we will later use to flash different shark outlines in sequence.
Motor / Bluetooth wiring
The Cherokey chassis has a nice PCB design for connecting your Arduino to the servos and bluetooth module. From their website, you can connect pins 0-7 as follows:
The Shark Car relies on bluetooth communication to drive. Any bluetooth compliant device will work to send the appropriate signals. I used the open source offering from Silver Coder, who has kindly provided a free Android bluetooth application for driving robotic vehicles (Thanks!). You can find the code for it here:
Now, we need to implement the code to receive signals from this software. The DF Robot bluetooth module receives a single character for each of the directions, and we need to implement listening code to control the motors in a reproducible fashion based on each signal. Additionally, we need to develop a solution to simultaneously oscillate the relays to control the lights. The arduino does not do multithreaded software, so this is a bit of a hack, but it proved functional. Source code was modified from github user srebroa and found here:
For the body, we chose 1/8″ Acrylic sheet from Tap Plastics in SF. Their staff was really helpful and knowledgeable. If cost is a consideration, you could use alternative materials for this part.
To cut the design, we used a Trotec Speedy 400 at Techshop. For acrylic, you want to start at lower power/speed and figure out what settings provide a nice clean cut without melting or burning. For this we used the ‘holestest’ file included with the thingverse package. This also let us test the diameter of the holes which needed screws, to ensure a snug fit.
Once your settings are correct, you should keep the protective paper on the acrylic while you cut to prevent any smoke/burn marks. Always cut interior holes/features before the main body, as parts can shift once they are freed from the bulk piece of material. A video of the cutting process can be found below:
After you cut the raw pieces, it is time to assembly the shark body. For this task, we used acrylic cement and a needle applicator. If you put the acrylic pieces orthogonal to each other, then apply a small amount of the cement, the surface tension will pull it into the joint to form a tight bond. Note that this is a solvent, so it is essentially taking two pieces of material, and fusing them into one, as opposed to putting a third party substance between them to join them (like glue). After you have applied the cement to each piece, it will fuse with a weak bond within ~30 seconds. Let it sit overnight, preferably clamped down if possible, for it to fully cure and form a solid bond.
Once the acrylic body is properly fused, you can attach it to the chassis using m2.5 screws. Note that there are room for improvements with the design (described below). Note that you should plug in the three el-wire leads and thread them through the port on the chassis and body prior to screwing it down.
Once the body is attached to the chassis, you can start to affix the el wire to the holes using the steel wire. For each hole (or every other), set the el-wire on the surface of the acrylic, loop the steel wire around and through the hole, then twist it off to tighten it. After you have affixed all the el-wire, you can use pliers to cut off the excess steel wire to make things look neat.
Once you finish, your body should be looking good with the el-wire affixed!
As with every project, if I could do it all over again, I would do it better. My wife did an incredible job on the shark design, but the hole pattern I added isn’t the easiest to attach to the chassis. The slotted design was there to add flexibility, but the vertical shark body occludes some of the best places for screws, so you have to have nimble fingers to slot them inside. Additionally, the ideal location for the back slots are blocked by the piece containing the relays. Feel free to improve upon the design should you cut your own!