Вы находитесь на странице: 1из 10

instructables

Snake Robot

by joesinstructables

Introducing The Lake Erie Mamba: a actuated by servo motors and joined with metal
Reconfigurable Robot Snake brackets. The servos are controlled by an Arduino
Mega and powered by a 7.4 volt battery pack. A four
This versatile reptile is made with off-the-shelf parts button keyfob transmitter provides remote control for
and is capable of several different modes of the snake. The snake is also capable of autonomous
locomotion, including slithering, inch worm, movement. Such a robot can be constructed with
sidewinding and rolling. (The rolling configuration many different types of servos and brackets. If you
involves the snake curling itself into a vertical loop decide to give one a try, I hope you find the code
and rolling like a wheel. See the last section in the given below to be useful.
video above.) The snake contains 12 segments

https://www.youtube.com/watch?v=3YH25vspiJo

Snake Robot: Page 1


Step 1: List of Materials

1 Arduino Mega (with optional sensor shield)


1 Four Button Remote Control Keyfob and corresponding Momentary M4 Receiver
12 servos
12 servo C-brackets
12 servo side brackets
4 long servo C-brackets
1 Lithium Ion Battery
12 Lego wheels
1 continuous rotation servo
1 IR distance sensor and mount
1 micro servo and mount
Several sensor cables and connectors
1 large wheel
1 5AA battery holder with barrel plug
Various nuts, bolts, wire clips, and velcro straps

Snake Robot: Page 2


Step 2: Construction

The Lake Erie Mamba is capable of several I put the Arduino and the 5AA battery holder that
configurations depending on the type of movement powers it into the tail section of the snake. The servos
desired. This step will detail construction of the form are powered by a separate supply, the 7.4 volt battery
capable of serpentine motion (slithering). The other pack, which went into the head of the snake. All the
configurations will be described in separate steps servo wires need to run back to the Arduino. I tried to
below. keep things neat by controlling the wires with the wire
clips. Just make sure there is enough slack along
Each of the 12 segments consists of a servo motor, a each run. The servos from head to tail are connected
C-bracket, a side bracket, a wire clip and a set of to Arduino pins 2 through 13. The 5AA battery pack is
Lego wheels. Two screw holes need to be drilled into connected directly to the Arduino and the 7.4 volt
the Lego wheel axle to allow it to be connected to the battery pack is connected to the input supply on the
C-bracket. I also had to drill two screw holes into the Arduino sensor shield. I held the batteries and
wire clip to attach it to the C-bracket. See the photos Arduino in place with Velcro strips.
above. After all 12 segments are connected, head
and tail sections need to be added in order to Remote control is handled by the keyfob transmitter
accommodate the Arduino and batteries. To make and receiver I got from Adafruit. I can’t tell you how
them I used a side bracket and two long C-brackets useful I find these things. They're a quick and easy
connected as in the photo above. way to add remote control to any Arduino project. On

the receiver, the ground pin is connected to the remote control of the snake will be explained in the
Arduino ground. The voltage pin is connected to a 5 sections below.
volt pin from the Arduino (not the separate 7.4 volt
supply) and pins D0 through D3 on the receiver are
connected to pins 14 through 17 on the Arduino,
respectively. (See the figure above.) The keyfob

Snake Robot: Page 3


1 1
4 2
6
3
2
5

1. Wire clip with two screw holed drilled into it. 1. Servo connections to the Arduino
2. Lego wheel set. 2. Receiver connections to the Arduino
3. Arduino 5 volt supply for receiver
4. 7.4 volt power supply for servos
5. Remote control transmitter
6. Remote control receiver

1. Head and tail section parts

Snake Robot: Page 4


Step 3: Serpentine Motion

On a real snake, the scales on the snake’s skin are segment and takes values from 1 to 12, amplitude
configured so that there is less friction in the direction determines how wide the wave is (i.e. how much the
parallel to the snake’s body than there is in the "S" shape is curved), frequency (along the variable
direction perpendicular to the snake’s body. This is delayTime) determine the speed of the snake,
achieved on the robot snake by attaching passive counter is the loop variable that takes the snake
wheels to each segment that roll in the direction along through its undulation and lag is the constant angular
the length of the snake. The result is that the snake difference between segments. The term 3.14159/180
can be propelled forward just by sending a sine or is just the degrees to radians conversion.
cosine wave down its body.
Each of the servo motors is controlled by a command
The Arduino code for control of this motion is given in of this form and all twelve of these commands are put
the link below. The servo motors take commands that into a for loop where the variable counter runs from
set their angle. If all servos are set to 90 degrees, 0 to 360 degrees. This commands the snake to
then the snake's position is a straight line. An angle perform one forward undulation and ends with the
less than or greater than 90 will then tell the servo to snake back in its original position. In the loop there is
bend left or right. The basic command to control each also a command delay(delayTime);. Since servos do
servo for forward motion is given by a command of not respond instantaneously, the code has to pause
the form: to give the servos time to move. For the servos I am
using, a value of 7 microseconds seems to work well
sn.write(90+amplitude*cos(frequency*counter*3.14 and gives a nice smooth movement. To make the
159/180 - n*lag); snake move in reverse, it is the exact same loop, only
with the counter running from 360 down to zero.
In the command above, n is the number of the current

If the wave responsible for the motion of the snake is Each of four motion commands will complete one
centered at 90 degrees, the snake's center of mass undulation of the desired movement and return the
will move in a straight line. If the wave is centered at snake to the exact same position at the end of the
an angle less than 90 degrees, the snake will turn left, loop. To add remote control to the robot I use the
and for more than 90 degrees, the snake will turn keyfob transmitter/receiver pair listed in step 1. The
right. This is controlled in the code by the variables four buttons on the keyfob transmitter correspond to
leftOffset and rightOffset. Thus, to turn the snake it a) forward, b) reverse, c) left turn, d) right turn. The
is a simple matter of adding one of these offsets to receiver is connected to the Arduino with forward to
the write commands in the forward motion loop. pin 14, reverse to pin 15, left turn to pin 16 and right
However, since this will result in a somewhat jerky turn to pin 17. These pins are declared as input and
motion as the snake moves suddenly to the turn set to LOW. Now I just put the section of code for
starting position, what I do in the turn loops is slowly each movement into an if loop that runs when the
ramp up the offset at the beginning of the turn loop, appropriate pin goes HIGH (i.e. when the appropriate
and slowly ramp down the offset at the end of the turn button is pushed).
loop. This results in a smoother motion.

Snake Robot: Page 5


Download (https://cdn.instructables.com/ORIG/FAQ/UZ9D/J16Y9UIU/FAQUZ9DJ16Y9UIU.txt)

http://www.instructables.com/ORIG/FAQ/UZ9D/J16Y9UIU/FAQUZ9DJ16Y9UIU.txt

(https://cdn.instructables.com/ORIG/FAQ/UZ9D/J16Y9UIU/FAQUZ9DJ16Y9UIU.txt)

Step 4: Rectilinear Motion

Inch worm movement (also known as rectilinear its horizontal position off the ground and the snake
motion) is achieved by removing the wheels and can continue forward.
setting the snake on its side. (See the photos above.)
A vertical hump sent from the tail of the snake toward Remote control is again achieved using the keyfob
the head moves the snake forward. Unfortunately, remote. The four buttons correspond to a) forward, b)
there is no way to turn the snake in this configuration. toggle wheel up/wheel down, c) left turn, d) right turn.
That’s where the continuous rotation servo and large The code contains a variable wheelState that takes
wheel come in. The first segment of the snake is the values 0 or 1. The variable is initialized to 0. If
turned up 90 degrees and two long C-brackets and a button b) is pressed and wheelState = 0, then the
side bracket are used to secure the continuous wheel will come down and the variable wheelState
rotation servo with the large wheel attached to it. The will be set to 1. Buttons c) and d) can now be pressed
wheel is oriented so that it is parallel to the ground. to turn the robot. When the turn is completed, button
When the snake wants to turn, the servos along the b) is pressed again. When button b) is pressed and
snake are positioned so that the wheel comes down wheelState = 1, the wheel will be lifted and the robot
perpendicular to the ground with the front servos off can continue forward. The variable wheelState will
the ground so that the wheel bears weight. The wheel also then be reset to 0.
can then be rotated left or right to turn the snake.
When the turn is completed, the wheel is returned to

Snake Robot: Page 6


1

1. Components for turning mechanism for the rectilinear configuration

https://www.youtube.com/watch?v=wilygCTrdoo

Snake Robot: Page 7


Download (https://cdn.instructables.com/ORIG/FQO/YZW7/J140EBJH/FQOYZW7J140EBJH.txt)
http://www.instructables.com/ORIG/FQO/YZW7/J140EBJH/FQOYZW7J140EBJH.txt

(https://cdn.instructables.com/ORIG/FQO/YZW7/J140EBJH/FQOYZW7J140EBJH.txt)

Step 5: Sidewinding Motion

Sidewinding is a motion used by snakes when they serpentine motion and servos 2, 4, 6, 8, 10, and 12
are on shifting terrain such as sand. This motion is will positioned as for rectilinear motion. Sidewinding
actually a combination of the serpentine and motion is achieved by sending a horizontal cosine
rectilinear motions described above. To achieve this wave down the odd numbered servos and a vertical
motion the robot must be reconfigured. A side bracket cosine wave (offset from the horizontal wave by 90
connecting one segment to the C-bracket of the next degrees) down the even numbered servos. The result
segment is unscrewed and rotated 90 degrees. This is a sideways motion.
is done along the entire length of the snake. Thus
servos 1, 3, 5, 7, 9, and 11 will be positioned as for

2 1

1. Vertical segment
2. Horizontal segment

Snake Robot: Page 8


Download (https://cdn.instructables.com/ORIG/FNG/QX1K/J140EBJU/FNGQX1KJ140EBJU.txt)
http://www.instructables.com/ORIG/FNG/QX1K/J140EBJU/FNGQX1KJ140EBJU.txt

(https://cdn.instructables.com/ORIG/FNG/QX1K/J140EBJU/FNGQX1KJ140EBJU.txt)

Step 6: Rolling Motion

Another type of motion possible for this robot (but not necessary for this motion requires that the head and
for real snakes) is rolling. In the rectilinear tail sections be removed, so that the Arduino and
configuration, the head and tail can be connected to batteries cannot be carried by the robot. Thus this
form a loop, and the servos can be commanded so motion is only possible in tethered mode.
that the robot rolls like a wheel. The symmetry

Download (https://cdn.instructables.com/ORIG/FIW/KDC2/J140EBJS/FIWKDC2J140EBJS.txt)

http://www.instructables.com/ORIG/FIW/KDC2/J140EBJS/FIWKDC2J140EBJS.txt

(https://cdn.instructables.com/ORIG/FIW/KDC2/J140EBJS/FIWKDC2J140EBJS.txt)

Step 7: Autonomous Motion

Finally, an IR distance sensor attached to a micro object, the robot will stop and the micro servo will turn
servo can be connected to the robot’s head to allow the distance sensor to the left and right to take two
for autonomous movement. This is best done in the more distance measurements. The snake will then
serpentine configuration. The snake will move reverse one undulation, turn in the direction of the
forward one complete undulation, stop, and take a clearer path, and continue forward.
distance measurement. If the path is clear the snake
will continue forward. When it gets too close to an

Snake Robot: Page 9


https://www.youtube.com/watch?v=HbdGHT-hGxQ

Download (https://cdn.instructables.com/ORIG/F11/2SVL/J140EBJB/F112SVLJ140EBJB.txt)

http://www.instructables.com/ORIG/F11/2SVL/J140EBJB/F112SVLJ140EBJB.txt

(https://cdn.instructables.com/ORIG/F11/2SVL/J140EBJB/F112SVLJ140EBJB.txt)

Snake Robot: Page 10

Вам также может понравиться