Saturday, September 6, 2014

Make a swimming Robo-Snake using Arduino [Full Tutorial]


Sneel is the name of my snake / eel swimming robot. This is documentation of hardware, software and mechanical design of  Sneel_003.

urethane flex tubing, microcontrollers, Zigbee wireless radio, hose clamps, wires, servo motors, titanium servo brackets, silicon, marine grease, epoxy, pond pump

Sneel is a swimming robotic water-snake, constructed to explore lifelike, sinuous motion in an aquatic robot. It is designed to navigate unknown territory and extreme terrain.

Sneel is inspired by Protei, (protei.org), an international project for the design of a fleet of open source, robotic, unmanned sailboats. Sneel is a development of Protei_007.

Sneel_003 swimming in San Francisco, California, Spreckles Lake, Golden Gate Park:



Sneel is an open-source, biomimetic, locomotive, aquatic robot. The electromechanical design of Sneel mimics the structure and motion of a real water snake, as a test to explore swimming behavior in an undulating linear robot. The inspiration for Sneel originates from a fascination with reptilian forms of motility and the implications of modelling hardware from biological structures and functions. Sneel uses a custom-written software library to propagate an oscillating wave down a line of servo motors that comprise the robot’s body. The current model is a platform for the development of other low-cost snake drones, with semi-autonomous navigational control for waypoint following, and sensing capabilities for obstacle avoidance. Worldwide applications for Sneel include remote marine data collection of salinity / toxicity levels, nuclear level monitoring, pipeline or underwater exploration, fishery monitoring, and oil-collection.

Sneel version 2 swimming like a real snake:


Sneel version 2, first swim in central park:




Step 1: Bill of Materials

Mechanical hardware:
5x Lynxmotion servo brackets
5x Lynxmotion C-brackets
5x injection molded servo hinge
urethane dust collection tube, 5' x 2.5"
convoluted hose clamp
5/16" tubing
5/16" hose clamp
2x shop vac 2.5 to 1.25" vacuum reducer
5x servo bracketshttp://www.seeedstudio.com/depot/bracket-for-rb421-servo-p-939.html?cPath=0
urethane sealant
marine grease
marine epoxy sealant
o rings
carbon fiber 3x (1/32", 1"x12" strips)
rubber about 1/8" thick, 2"x10" at least, like this neoprene works well
loctite (green)
nylon string as a tether
optional: 
inner tube or valve for positive pressurizing with a bike pump
silica gel packs


electronics:
10 Servo motors (I recommend these Hitec ones with Karbonite gears but these are a bit pricy. Whatever you get, the nylon gears will ear out quickly so I warn against them)
3 6V NiMh battery packs
Arduino UNO
1 seeeduino mega
Xbee explorer
2x xbee series 1
xbee wireless shield
servo motor shield

servo extension wire
xbee breakout + 2 rows of 10 male header pins + 2 rows of xbee 2mm female headers


supplies:
wires
needlenose pliers
angle snips
wire strippers
small screwdriver
4-40 screws, lock or toothed nuts, and bolts
2-56 screws, lock or toothed nuts, and bolts
solder iron + solder
hack saw
drill or drill press
3 mm drill bit
optional: 
dremel

Step 2: Waterproof the servo motors

See this instructables I made about waterproofing servo motors.

But briefly:
-apply silicon marine sealant around the two seams in the plasitc of the servos, around the spot where the wires are inserted, and  where the screws are mounted on the bottom.
-Let the motors dry for 24 hours...

-Unscrew the servo horn (the round plastic top of the servo motor).
-Apply petroleum or marine grease around the toothed shaft, and slip an o-ring around the shaft.
-Put back on the round servo horn. Make sure it is centered (turn it one direction and make sure that it rotates about 90 degrees from center one direction and 90 degrees the other direction).
-Screw back on the circular plastic servo horn.

Step 3: Prepare the frame: cut the carbon fiber

-With a hacksaw, cut the carbon fiber into 4 inch pieces (each 12" x1" strip should be cut in 3 parts). I used a dremel to round the jaggedy corners.

-Lay out one of each servo bracket 3 inches apart. Mark on the carbon fiber where the two large holes in the brackets line up, so you can drill here to screw them into the carbon fiber.

-Drill the 4 holes in each piece of the carbon fiber using a 3 mm drill bit, or around that size.

-Do this with 7x 4" pieces.

Step 4: Prepare the frame: attach the brackets to the carbon fiber

-Using the fat screws that came with both brackets, line up the holes you cut with the holes in the brackets.

-Screw in the screws to attach the carbon to the brackets. Make sure you screw with the bolt on the backside of the brackets as shown in the photo.  

Step 5: Prepare the frame: attach the c-brackets

-Line up the rubber with the c-bracket middle section (see image) and cut 5 pieces. They will be about 1" x 2"

-Line up the cut piece of rubber with one of the c-brackets, and draw a dot on the rubber where two of the holes line up.

-Use a pin to poke a hole in the rubber at the two hole-marks.

-Insert the 2-56 screws from the black clamp, through the rubber (pop it or screw it through), then through the red bracket.

-Do this for every black/red bracket pair.

NOTE: from the image, I did things in a slightly different order than described above - you can see my servo is already attached to the servo bracket. This made it significantly more difficult to screw in the two screws here. Also, I ended up getting 1/2 inch screws but at first I was using 1 inch screws and had to grind or cut off the excess.


Step 6: Prepare the frame: Mount the servos on the brackets

-In the package with the servos, there are a few parts. Grab the small rectangle cube.

-Insert this into all four of the holes on the servo motor. Note that the rubber has a flat side. This side should be facing outwards.

-on 5 of the servos, adhere the injection molded joint (unless you have c-brackets with bearings in the bottom)

-Place the servo in the bracket as shown - the servos with the injected molded joint go on the black servo bracket.

-Screw in the 4x40 screws. Place a lock nut on the bottom and screw in the bolt. 

Step 7: Prepare the frame: Mount the c-bracket pairs to the servo brackets

-Mount the red servo-brackets to the red c-brackets, and the black to the black:
RED:
Slip the c bracket over the servo horn and under the servo bracket, as shown in the photo. Use the screw and bearing to secure it in place.
BLACK:
Slip the c bracket over the servo covering most of its body. Slip it over the servo horn and under the servo bracket. Make sure that the top side on the servo horn is the side with one large hole and four small holes. The injected molded segment on the bottom should pop into place in the small hole.

Now you should have a full length snake like structure.




Step 8: Screw in the servo horn to the bracket

-line the holes up with the brackets and the servo horn.

-Make sure that your horn is centered (you can spin it in one direction and the other direction, then bring it about halfway back turned, to the center position, so if you put your bracket on aligned straight with the servo it will be calibrated to center position.

-use a small screwdriver to screw the bracket and the round plastic servo horn together. I like to pinch them together with pliers to make sure holes line up.

The brackets and servos should rotate freely. You should apply some grease between the two metal brackets if there is friction.
You can also apply loctite to some of the screws so that they dont come out. Make sure not to do this before you are certain you are finished, because it is very hard to undo the screw once you've applied loctite. Also, the green loctite is a little less permanent.

At this point, your snake body is ready!

Step 9: Make the circuit

-Prepare the xbee breakout board (solder on the 2 rows of male headers and 2 rows of 2mm xbee female headers)

-Insert the xbee onto it.

-I'm using a servo motor shield from seeed studios, but I am sort of just using it as a perf board, but a convenient one because all the ground and power pins to my servo motor are already jumped together, with a screw terminal for the battery input. And ignore those wires hanging off the board - I had prefiously soldered on female header pins for another use of the board, so I removed them so I could use this here. I eventually clipped them off but you can see them in the pics.

-So if you have the servo shield, solder on the screw terminal; two rows of headers  where the 6V and GND from the battery are connected. Solder on male headers so it will mount in your seeeduino (or arduino) mega. I'm using the seeeduino again because i had it around, and because it is smaller so it fits better into the skin tube  (the protective outer layer).
Note: an arduino mega is necessary not because of the numbers of outputs but because the flash memory space in the arduino UNO is not large enough.

-jump xbee pin 1 (3.3Vin) to Arduino 3.3V pin (see red wire)
-jump xbee tx (pin 2) to Arduino RX (pin1) (see yellow wire)
-jump xbee ground (pin 10) to arduino gnd (see black wire)
-jump power from the 6V battery input to the Arduino VIN pin (green wire)

-Solder on wires from all the digital output pins (as many servos as you are using).
-place on the servo connectors (Red, black, white here) and insert the dOUT wires from arduino into the servo cables (white signal wire).
NOTE: if Arduino is to be housed in the frotnt of the snake, connect the pins low to high from arduino to the servos that are most close to the head to far away) . in other words: the first servo (as in when the snake is moving ahead, the servo at the HEAD) should be digital pin 2, and the tail end servo shoudl be digital pin 11.

-Screw in wires to the screw terminals to attach to 6V and GROUND from your batteries.

-I clipped the extra metal off (you shouldn't have to do this if you are starting from a clean board, not one with female header pins soldered in)


Step 10: Upload the firmware

I wrote a software library to easily generate wave locomotion based on oscillation. It calls on the Servo Arduino library to generate a sine wave propagating down the line of servos. It allows for modularity to change the sensory input, wave parameters, and number of servos.

Download the code here. Upload it to Arduino, without the xbee plugged in (when the xbee is plugged in, the tx and rx pins (pins 1 and 0) on arduino mega are usedreferences a class that propagates a sine wave down a line of motors.

During each loop cycle:
-The main program, references a class that propagates a sine wave down a line of motors.
-listens to a wireless RC protocol communicating to the snake via the joystick



Step 11: Make a remote control transmitter, or just use xbee & computer

For this version of the snake, various character inputs (numbers 1-6) affect the wave behavior.

OPTION 1: xbee+computer (see this instructable for more info)
-Plug in xbee to the xbee explorer.
-Plug xbee explorer into your computer via the USB cable.
-Download and open CoolTerm.
-Click "OPTIONS".
-Make sure the BAUD RATE is set to 57600.
-Make sure that after "PORT:" it says something like "usbserial-A700xxx". If not, select "RESCAN SERIAL PORTS".
-Click OK.
-Click "CONNECT"
-Make sure your xbee is set to 57600 baud rate:
   Type "+++" (you might not see anything written in the serial port unless you have checked "LOCAL ECHO" in the TERMINAL tab of the OPTIONS.)
   You should get "OK" returned in the serial monitor of CoolTerm. If you are not, perhaps xbee is not set to that baud rate. to debug, go back to OPTIONS and select "baud rate 9600" and try again.
   Now you have entered xbee's "command mode".
   Type "ATBD" then ENTER.(and don't wait too long or you will exit command mode).
   You should get an integer returned, corresponding to the baud rate xbee is set at. To make sure it is set to 57600, type "ATBD 6" then ENTER.
   You should get "OK" returned.
   Now type "ATWR".

Now, when you type the characters 1-6 in the serial monitor, when the snake is turned on, the characters should affect the motion.

5&6: affect the speed of the rotation of the servos.
3&4: affect the period of the wave (speed of propagation down the line of servos).
1&2: affect the amplitude of the wave.

Visualize in software how the wave behavior is affected by the various parameters, or typing in integers 1-6..


The attached graphs show the output angle values of each servo mapped over time, slightly out of phase from each other. The difference is when there is a different offset (delay in the time it takes one servo to get to the angle of the previous one in the line of waves).

If you don't want to use your computer, and want to have a free standing remote control, feel free to make an arduino based r/c. To do this, plug in the xbee to an xbee shield mounted on Arduino (see image). Make a 6 button inputs. I hacked into a joystick that had 2 extra buttons. Connect the 6 buttons to Arduino digital pins 2-7.

Upload the following code to arduino.
And now affect the snake behavior the same way as through coolTerm.



Step 12: Wire it up

So far: Arduino is soldered, wired and programmed; and the snake body built.

Now it's time to wire it all up:
Using your servo motor wire extenders, elongate all the servo wires so that they extend down the length of the body, up until a few inches past the last servo bracket.

It was helpful for me to keep track of which wire was from which servo, so that when I plugged them into the perf board it was easy to plug them in in order consecutively.

I string the wire down around the back of the carbon fiber, and tape them to the carbon fiber so that when I eventually put the vacuum skin on, it doesn't pull the wires too much. I also put tape on the junction at each wire connection just for safety.



Step 13: Attach the batteries

At each carbon fiber segment, attach the batteries with the 6V/GND wires pointing towards upwards (towards the top of the servos) and towards the front of the snake.

Use two zipties to secure on the batteries to the carbon fiber.

I used a dremmel to sand the corners of the zipties after cutting them, if they feel sharp.

I attached four battery packs in total. I also used the servo wire extensions to extend the battery power and ground to the front of the snake, at the head, where Arduino is housed. I also made a y-link from each battery junction so they all come together at the Arduino screw terminal power and ground servo motor input.

Before finishing the battery connections, make sure to add an on/off button: see the next step.

Step 14: Add the on / off buttons, and prepare the head and tail caps

I'm using one button for the water pump (12V battery) and one for the arduino / servos (6V battery). The water pump cannot be turned on unless the snake is in the water or the pump will dry up. So I turn on the snake first then turn on the pump. See the next step for attaching the water pump.

Cut two a piece of rubber about 1.75" diameter, so that it fits inside of the vacuum reducers. Cut two pieces of cord about 2 feet long, to act as tethers and to help position the body inside of the skin.

FOR THE HEAD (near the Arduino):
Place the rubber into the vacuum reducer, and cut a small slit, large enough to pass the wires. Run the string through the vacuum reducer so that there is about 8 inches of string on the inside. There doesn't need to be too much on the outside because the tether will be located at the tail.
Run both buttons up through the vacuum reducer. Run the wire (containing power and ground) from the waterpump down through the hole in the vacuum reducer. So in total, the following wires should run through the vacuum reducer and the rubber pad : power and ground from both switches; one string; power and ground from pump.

FOR THE TAIL :
Just string the other piece of string through. Leave about 10 inches of string on the inside, and a little more on the outside. This string acts solely as a tether. You can eventually lengthen it by attaching another string to it so that you can have a longer tether.

Now, solder the on / off button to the red 6V wire that attaches to the screw terminal, so that when you power this on, the arduino turns on and the servos get power. This button is the master on/off button.




Step 15: Prepare the pump battery and elongate the body

-Add two 4" pieces of carbon fiber to either end of the snake, so that the head and tail extend outward a few inches.

-Solder together a battery junction for the battery to connect directly to the pond pump, but solder the other on/off switch to the red wire between the battery and the pump. The battery sits right next to the Arduino.

-Attach the battery to the carbon fiber with zipties.

Now you should have something that moves like this when the batteries are plugged in:






Step 16: Caulk the caps

Apply a lot of caulk to both the inside of the vacuum reducer, in the seam where the rubber is, and on the opposite side, deep in the hole. Make sure to cover all of the wires.

Let it dry about 24 hours.



Step 17: Put on the skin

-I added some silica gel packets just to make sure that moisture was absorbed.

-I hot glued the Arduino just to make sure that no wires pull out.

-If any of the servo joints are stiff or the metal is rubbing, I add some grease between the rubbing sections.

-Then slip on the skin, going from the side of Arduino down to the other side of the tail.

-Cut the tube to length, if it is too long.

-Once it is all the way on, I use the string on both sides to hoist the carbon fiber all the way into to the end of the vacuum tube. I tie a knot here to prevent slipping.

-Put the caps on the head and tail end. Applying some marine grease can help seal it. 

Step 18: Put on the water pump

-cut length of plastic 5/16" tube to the length of the snake. Slip it over the OUTPUT nozzle on the pump (the more narrow nozzle is the output). I like to briefly blast the junction with a heatgun once I slip on the tube to make the connection nice and snug. Secure a hose-clamp around the tube at the joint.

optional: attach another hose of 7/16" to the input valve

-Mount the pump somewhere near the front of the snake, on the bottom side (the opposite side of the servo horns). The plastic plate that comes with the pump mounts on the pump, and has a spot with two ridges on either side. I used a ziptie to wrap in a cross around the snake body to secure it.

-I also mounted the goPro but this is optional too.





Step 19: Take it outside!

Take him outside.

-Apply grease to the outside of the plastic buttons so no water gets in.

-I screwed on the hose clamps onto the head and tail ends, but I am not sure this is necessary, it was just to be extra safe.

Turn it on.
Put it in the water. Perhaps you have to adjust the wave motion with your remote control.
Once in the water, you can turn the pump on with the other switch.
Watch him swim and use the r/c to control his motion.

0 comments:

Post a Comment