LEGO Theory and Practice - City University of Hong Kong

Download Report

Transcript LEGO Theory and Practice - City University of Hong Kong

LEGO Theory and
Practice
Mark Green
School of Creative Media
Introduction
 Can
do a wide range of things with LEGO
 adding motors, sensors and computers
gives us even more possibilities
 the question is what do we do with this?
 Its fun to play with LEGO, but where do we
want to take it?
 In addition, how do we build fun things?
Expressive Robots
 One
thing is building robots that can
express themselves
 not just a mechanical thing, but something
we can relate to, something with emotions
 a good example of this is Feelix, a LEGO
robot the expresses feelings:
http://www.daimi.au.dk/~chili/feelix/feelix_home.
htm
Feelix
Feelix
Feelix
 Feelix
has been used to study how people
recognize emotions
 could not recognize as easily as with real
humans, but fairly close most of the time
 Feelix could react to people through its
touch sensors (on feet)
 emotion based on frequency and strength
of touch
PETS
 Personal
Electronic Teller of Stories
 Robots built from LEGO, designed by a
team of adults and children
 Develop a robot that shows emotions and
feelings, can be used to assist with telling
stories
 Robot acts out part of the story, controlled
by computer to give expressions at
appropriate times
PETS
 LEGO
used as the robot skeleton and to
provide the motion
 Skeleton is covered with cloth and other
soft things to make a huggable toy
 Velcro and glue used to attach “skin” to the
robot
 Quick way to produce responsive toy
without getting into a lot of engineering
PETS
PETS
PETS
 Shows
how LEGO can be used to
prototype intelligent toys
 Building out of raw components, plastic
and metal, can be difficult and requires
special tools and skills
 LEGO can be used by most people,
doesn’t require anything special
 Won’t be the best looking, but quick and
easy
Building with LEGO
 Two


general approaches:
Start by deciding what you are going to build,
figure out how to build it
Start by putting things together and see what
you end up with
 Most
LEGO projects are a combination of
these approaches
 Rarely know exactly how to build
something before you start
Building with LEGO
 Good
LEGO builders claim that you need
three skills:



Mechanics
Electronics
Software
 Also
need some patience and willingness
to try different things
 It won’t work right the first few (many)
times you try to build it
Mechanics
 Need
to know how to put the blocks
together to get the structure you need
 Needs to be strong, so it doesn’t fall apart
when it moves
 Need to understand how to make LEGO
move, how to use wheels, gears and axles
 Most of this is gained through experience
with making things
Electronics
 Understand
how sensors work, how they
can be used to control the robot
 Understand how motors can be used to
move the robot
 How to connect the motors and sensors to
the LEGO blocks, make the best of the
limited resources
 Use one motor to produce several motions
Software
 Write
the programs that make the robot
work
 Read the sensor values, produce the
signals required for the motors
 Plan how long each motor should run, how
it should respond to sensors
 Produce the robots behavior, how it will
respond to its environment
Example
 Look
at a very simple robot, example of
how we build and program them
 Based on Tippy from Brian Bagnall’s book
“Core LEGO Mindstorms Programming”
 Like all good robot projects, this one didn’t
go as planned!
 Tried to follow instructions from book, but
the robot wouldn’t fit together
Tippy
Tippy
Tippy
 Tippy
is about as simple as it gets
 Two wheeled direct drive robot, there are
skid plates at the front and back to keep
the robot from tipping over
 There is a touch sensor at the front to
detect collisions
 It can only detect collisions at the front, but
the robot does go backwards!
Tippy
Tippy
 The
touch sensor is quite small, need
something bigger to detect collision
 The bumper mechanism at the front does
this, based on a hinged lift arm
 A wide axle is attached to the lift arm, to
increase the range of the sensor
 When something hits the axle the lift arm
hits the touch sensor, signaling the
collision
Tippy
 Two
motors are attached to the plate at
the bottom, this is not a good design!
 Weight of the robot is on the wheels,
wheels connected to motors, motors
connected to top of plate
 Too easy for motors to come off of the
plate
 Would be better to attach the motors to the
bottom of the plate
Tippy
 Problem:
when I tried to attach the
understructure of the robot to the RCX I
found it was too wide!
 Our RCX is narrower, by one row then the
one used in the book
 Had to design a platform on the bottom of
the RCX to mount the structure on
 Result: robot is lopsided
Lesson
 LEGO
rarely goes together the way you
want it to, must be prepared to improvise
 This is the creative part of the project,
figuring out how to make the whole thing fit
together
 Be prepared to rethink your design and
build interfaces between the different
components of the design
Software
 We
need to make the robot do something
 It needs some software for this
 What will we make the robot do??


Its default action is to move forward, both of
its motors should spin in the forward direction
When it hits something it should back up and
turn so it no longer hits something
 Going
turn?
forward is easy, but how do we
Software
 Neither
wheel turns, there doesn’t appear
to be a way to turn the robot
 But the two wheels are independent, each
have a separate motor
 We can make the robot turn by spinning
one wheel forward and the other wheel
backwards
 Only do this for a short period of time
Software
 Software
consists of two parts
 First part just drives the robot forward
 Turns on the two motors and sets both of
them to forward
 Second part only runs when there is a
collision
 It backs up the robot and turns it, then
starts it moving forward again
Tippy Program
Software
 The
left side turns on the two motors and
sets their direction to forward
 The right side is connected to the touch
sensor
 It changes the motor direction and waits
for 0.5 second
 Set direction so one motor is forward and
the other reverse
Software
 Again
wait for 0.5 second
 Then set both motors to forward
 We don’t measure how far the robot
moves or turns, we just wait for 0.5
seconds
 Good enough most of the time, but could
still get in trouble
Summary
 We
have a robot that basically works
 Can be put together in about 20 minutes,
most of the effort is finding the right parts
 But, neither the software or structure is
very robust
 It can easily fall apart and it can easily get
stuck trying to recover from collisions
Summary
 Due
to the modification I made I didn’t
have enough parts to finish the robot
 Original design had a plate above the lift
arm, but I ran out of plates
 Without the plate the arm bounces and
causes the robot to turn too much
 I later made a plate out of two smaller
plates, and it now works better
LEGO Theory
 If
we are going to build things with LEGO
we need to understand how it works
 Start by looking at the various LEGO parts
and then move on to some of the standard
structures
 Look at some of the standard design and
solutions
 Get you started on your own designs
LEGO Theory
 The
main structural units are bricks, plates
and beams
 The size of a LEGO piece is measured in
studs, the little round things on the top
 Bricks are usually one or two studs wide
and from one to eight studs long
 Bricks are used to build up structure, they
have no other purpose
LEGO Theory
 Plates
are thin bricks, 1/3 the thickness of
a brick
 Plates can be used to build structure, but
they are usually used to connect other
units or add strength to a structure
 Beams are one stud wide, even number of
studs long, with holes running through
them
LEGO Theory
 If
a beam is ‘n’ studs long, it has ‘n-1’
holes
 Axles and pins can be placed in the holes,
so beams are often an important part of a
robot’s chassis
 Since beams are thin they often need to
be reinforced or the structure becomes too
weak
LEGO Theory
 Pins
are short and round and fit into the
holes in beams
 Two types of pins


Free turning pins, can rotate inside the hole
Friction pins, don’t rotate
 Pins
can be used to attach parts, or to
attach wheels and gears to the robot’s
chassis
LEGO Theory
 Wheels,
axles and gears are used for
movement
 A wide range of wheels, the larger the
wheel the faster the robot will move
 Axles are measured in studs, even though
they have no studs
 Gear are used to change the speed of
motion, or change its direction
LEGO Theory
 There
are a number of other parts used for
special purposes and decorations
 Lift arms are beams that don’t have studs
 They can be connected to other parts
using pins and axles
 Pulleys can be used to transmit force, but
are not as reliable as axles and gears
Structures
 Mindstorms
comes with two motors, and
the RCX can only handle three
 We can only have a limited number of
independent motions, one per motor
 In addition, motors rotate, what if we want
a linear motion, or one with a limited
rotation angle?
 Also we cannot control the speed of the
motor
Structures
 The
LEGO motor consists of a motor, plus
a gear chain
 There is no way to control the speed of
this motor, we can only control the
strength
 That is, we can increase the amount of
force the motor produces, carry heavier
loads, but cannot change speed
Structures
 This
introduces the need for a number of
structures to produce different types of
motion:





Straight linear motion
Repeated linear motion
Restricted rotations
Faster or slower speed
Axis or rotation
Structures
 The
structures that produce these motions
contain combinations of gears and axles
 Gears can be used to change speed and
axis of rotation
 The size of a gear is measure by the
number of teeth it has
 The standard gear sizes are 8, 12, 16, 24
and 40 teeth
Structures
 The
standard gears mesh together, tooth
for tooth
 This can be used to control speed of
rotation using different gear sizes
 Consider a 8 tooth and 24 tooth gear
connected together, both with their own
axles
 Start by turning the axle on the 8 tooth
gear
Structures
Structures
 Every
complete rotation of the axle will
move 8 teeth on the larger gear
 This gear has 24 teeth, so we need 3
rotations of the smaller gear for one
rotation of the larger gear
 Similarly, one rotation of the larger gear
will produce 3 rotations of the smaller one
 Thus we can go faster or slower
Structures
 Note:
if we speed up there is less force, if
we slow down there is more force
 Need to consider what you are trying to
move
 What happens if we want to change the
axis of rotation? The motor is facing one
way, but we want the rotation in a different
direction
 Two ways of doing this
Structures
 One
way is to use a worm gear and the
other is to use a crown gear
 A crown gear meshes with a regular gear
at a 90 degree angle
 When the crown gear is turned the regular
gear with turn, but the axis of rotation has
been shifted by 90 degrees
Structures – Worm Gear
Structures – Crown Gear
Structures
 There
are several ways of doing linear or
straight line motion
 One is to use a crankshaft mechanism
 There are only enough parts to make one
crankshaft
 It converts a rotational motion into a linear
one by pushing and pulling an axle as it
rotates
Structures - Crankshaft
Structures
 The
other way of doing this is to use a
gear rack, a plate with gear teeth on the
top
 Gear racks are attached to plates or
beams and then meshed with a gear
 When the gear rotates the gear rack with
move forwards or backwards
 Maximum distance depends upon length
of gear rack
Structures – Gear Plate
Structures
 Our
Tippy robot used two motors so it
could both move and turn
 To turn the robot we turned the wheels in
opposite directions
 We only have 2 motors, so using both for
moving the robot means we can have no
other motion
 We need to be able to turn and move
using only one motor
Structures
 Moving
with one motor isn’t hard, connect
both wheels to the same axle
 Turning is the hard part, how can we make
the two wheels move differently with just
one motor?
 The solution is to use something called a
differential
 Allows the two wheels to operate
independently
Differential
Structures
 The
differential itself rotates, a gear
meshing with one of its outside gears
provides the motion
 The gear structure inside the differential
provides the interesting part
 The differential will normally turn both
axles, and the wheels attach to it
 This provides the forward motion for the
robot
Structures
 But
the two axles are independent, if one
axle stops rotating the other will keep
going
 This can provide our turning mechanism
 If when we reverse direction only one
wheel keeps turning the robot will turn
 The differential can handle this, but how
do we stop one of the wheels from
turning?
Structures
 The
solution is to use a ratchet
 A ratchet is based on a gear and a block
that lets the wheel turn in one direction but
not in the other
 We can add a ratchet to one side of our
differential
 When moving forward both wheels will
turn, with moving backwards the ratchet
will stop one of the wheels
Structures - Ratchet