lego theory and practice mark green school of creative media

62
LEGO Theory and LEGO Theory and Practice Practice Mark Green Mark Green School of Creative Media School of Creative Media

Post on 21-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

LEGO Theory and LEGO Theory and PracticePractice

Mark GreenMark Green

School of Creative MediaSchool of Creative Media

IntroductionIntroduction

Can do a wide range of things with LEGOCan do a wide range of things with LEGO adding motors, sensors and computers adding motors, sensors and computers

gives us even more possibilitiesgives us even more possibilities the question is what do we do with this?the question is what do we do with this? Its fun to play with LEGO, but where do we Its fun to play with LEGO, but where do we

want to take it?want to take it? In addition, how do we build fun things?In addition, how do we build fun things?

Expressive RobotsExpressive Robots

One thing is building robots that can One thing is building robots that can express themselvesexpress themselves

not just a mechanical thing, but something not just a mechanical thing, but something we can relate to, something with emotionswe can relate to, something with emotions

a good example of this is Feelix, a LEGO a good example of this is Feelix, a LEGO robot the expresses feelings:robot the expresses feelings:http://www.daimi.au.dk/~chili/feelix/feelix_home.http://www.daimi.au.dk/~chili/feelix/feelix_home.htmhtm

FeelixFeelix

FeelixFeelix

FeelixFeelix

Feelix has been used to study how people Feelix has been used to study how people recognize emotionsrecognize emotions

could not recognize as easily as with real could not recognize as easily as with real humans, but fairly close most of the timehumans, but fairly close most of the time

Feelix could react to people through its Feelix could react to people through its touch sensors (on feet)touch sensors (on feet)

emotion based on frequency and strength emotion based on frequency and strength of touchof touch

PETSPETS

Personal Electronic Teller of StoriesPersonal Electronic Teller of Stories Robots built from LEGO, designed by a Robots built from LEGO, designed by a

team of adults and childrenteam of adults and children Develop a robot that shows emotions and Develop a robot that shows emotions and

feelings, can be used to assist with telling feelings, can be used to assist with telling storiesstories

Robot acts out part of the story, controlled Robot acts out part of the story, controlled by computer to give expressions at by computer to give expressions at appropriate timesappropriate times

PETSPETS

LEGO used as the robot skeleton and to LEGO used as the robot skeleton and to provide the motionprovide the motion

Skeleton is covered with cloth and other Skeleton is covered with cloth and other soft things to make a huggable toysoft things to make a huggable toy

Velcro and glue used to attach “skin” to Velcro and glue used to attach “skin” to the robotthe robot

Quick way to produce responsive toy Quick way to produce responsive toy without getting into a lot of engineeringwithout getting into a lot of engineering

PETSPETS

PETSPETS

PETSPETS

Shows how LEGO can be used to Shows how LEGO can be used to prototype intelligent toysprototype intelligent toys

Building out of raw components, plastic Building out of raw components, plastic and metal, can be difficult and requires and metal, can be difficult and requires special tools and skillsspecial tools and skills

LEGO can be used by most people, LEGO can be used by most people, doesn’t require anything specialdoesn’t require anything special

Won’t be the best looking, but quick and Won’t be the best looking, but quick and easyeasy

Building with LEGOBuilding with LEGO

Two general approaches:Two general approaches: Start by deciding what you are going to build, Start by deciding what you are going to build,

figure out how to build itfigure out how to build it Start by putting things together and see what Start by putting things together and see what

you end up withyou end up with Most LEGO projects are a combination of Most LEGO projects are a combination of

these approachesthese approaches Rarely know exactly how to build Rarely know exactly how to build

something before you startsomething before you start

Building with LEGOBuilding with LEGO

Good LEGO builders claim that you need Good LEGO builders claim that you need three skills:three skills: MechanicsMechanics ElectronicsElectronics SoftwareSoftware

Also need some patience and willingness Also need some patience and willingness to try different thingsto try different things

It won’t work right the first few (many) It won’t work right the first few (many) times you try to build ittimes you try to build it

MechanicsMechanics

Need to know how to put the blocks Need to know how to put the blocks together to get the structure you needtogether to get the structure you need

Needs to be strong, so it doesn’t fall apart Needs to be strong, so it doesn’t fall apart when it moveswhen it moves

Need to understand how to make LEGO Need to understand how to make LEGO move, how to use wheels, gears and axlesmove, how to use wheels, gears and axles

Most of this is gained through experience Most of this is gained through experience with making thingswith making things

ElectronicsElectronics

Understand how sensors work, how they Understand how sensors work, how they can be used to control the robotcan be used to control the robot

Understand how motors can be used to Understand how motors can be used to move the robotmove the robot

How to connect the motors and sensors to How to connect the motors and sensors to the LEGO blocks, make the best of the the LEGO blocks, make the best of the limited resourceslimited resources

Use one motor to produce several motionsUse one motor to produce several motions

SoftwareSoftware

Write the programs that make the robot Write the programs that make the robot workwork

Read the sensor values, produce the Read the sensor values, produce the signals required for the motorssignals required for the motors

Plan how long each motor should run, how Plan how long each motor should run, how it should respond to sensorsit should respond to sensors

Produce the robots behavior, how it will Produce the robots behavior, how it will respond to its environmentrespond to its environment

ExampleExample

Look at a very simple robot, example of Look at a very simple robot, example of how we build and program themhow we build and program them

Based on Tippy from Brian Bagnall’s book Based on Tippy from Brian Bagnall’s book “Core LEGO Mindstorms Programming”“Core LEGO Mindstorms Programming”

Like all good robot projects, this one didn’t Like all good robot projects, this one didn’t go as planned!go as planned!

Tried to follow instructions from book, but Tried to follow instructions from book, but the robot wouldn’t fit togetherthe robot wouldn’t fit together

TippyTippy

TippyTippy

TippyTippy

Tippy is about as simple as it getsTippy is about as simple as it gets Two wheeled direct drive robot, there are Two wheeled direct drive robot, there are

skid plates at the front and back to keep skid plates at the front and back to keep the robot from tipping overthe robot from tipping over

There is a touch sensor at the front to There is a touch sensor at the front to detect collisionsdetect collisions

It can only detect collisions at the front, but It can only detect collisions at the front, but the robot does go backwards!the robot does go backwards!

TippyTippy

TippyTippy

The touch sensor is quite small, need The touch sensor is quite small, need something bigger to detect collisionsomething bigger to detect collision

The bumper mechanism at the front does The bumper mechanism at the front does this, based on a hinged lift armthis, based on a hinged lift arm

A wide axle is attached to the lift arm, to A wide axle is attached to the lift arm, to increase the range of the sensorincrease the range of the sensor

When something hits the axle the lift arm When something hits the axle the lift arm hits the touch sensor, signaling the hits the touch sensor, signaling the collisioncollision

TippyTippy

Two motors are attached to the plate at Two motors are attached to the plate at the bottom, this is not a good design!the bottom, this is not a good design!

Weight of the robot is on the wheels, Weight of the robot is on the wheels, wheels connected to motors, motors wheels connected to motors, motors connected to top of plateconnected to top of plate

Too easy for motors to come off of the Too easy for motors to come off of the plateplate

Would be better to attach the motors to the Would be better to attach the motors to the bottom of the platebottom of the plate

TippyTippy

Problem: when I tried to attach the Problem: when I tried to attach the understructure of the robot to the RCX I understructure of the robot to the RCX I found it was too wide!found it was too wide!

Our RCX is narrower, by one row then the Our RCX is narrower, by one row then the one used in the bookone used in the book

Had to design a platform on the bottom of Had to design a platform on the bottom of the RCX to mount the structure onthe RCX to mount the structure on

Result: robot is lopsided Result: robot is lopsided

LessonLesson

LEGO rarely goes together the way you LEGO rarely goes together the way you want it to, must be prepared to improvisewant it to, must be prepared to improvise

This is the creative part of the project, This is the creative part of the project, figuring out how to make the whole thing fit figuring out how to make the whole thing fit togethertogether

Be prepared to rethink your design and Be prepared to rethink your design and build interfaces between the different build interfaces between the different components of the designcomponents of the design

SoftwareSoftware

We need to make the robot do somethingWe need to make the robot do something It needs some software for thisIt needs some software for this What will we make the robot do??What will we make the robot do??

Its default action is to move forward, both of Its default action is to move forward, both of its motors should spin in the forward directionits motors should spin in the forward direction

When it hits something it should back up and When it hits something it should back up and turn so it no longer hits somethingturn so it no longer hits something

Going forward is easy, but how do we Going forward is easy, but how do we turn?turn?

SoftwareSoftware

Neither wheel turns, there doesn’t appear Neither wheel turns, there doesn’t appear to be a way to turn the robotto be a way to turn the robot

But the two wheels are independent, each But the two wheels are independent, each have a separate motorhave a separate motor

We can make the robot turn by spinning We can make the robot turn by spinning one wheel forward and the other wheel one wheel forward and the other wheel backwardsbackwards

Only do this for a short period of timeOnly do this for a short period of time

SoftwareSoftware

Software consists of two partsSoftware consists of two parts First part just drives the robot forwardFirst part just drives the robot forward Turns on the two motors and sets both of Turns on the two motors and sets both of

them to forwardthem to forward Second part only runs when there is a Second part only runs when there is a

collisioncollision It backs up the robot and turns it, then It backs up the robot and turns it, then

starts it moving forward againstarts it moving forward again

Tippy ProgramTippy Program

SoftwareSoftware

The left side turns on the two motors and The left side turns on the two motors and sets their direction to forwardsets their direction to forward

The right side is connected to the touch The right side is connected to the touch sensorsensor

It changes the motor direction and waits It changes the motor direction and waits for 0.5 secondfor 0.5 second

Set direction so one motor is forward and Set direction so one motor is forward and the other reversethe other reverse

SoftwareSoftware

Again wait for 0.5 secondAgain wait for 0.5 second Then set both motors to forwardThen set both motors to forward We don’t measure how far the robot We don’t measure how far the robot

moves or turns, we just wait for 0.5 moves or turns, we just wait for 0.5 secondsseconds

Good enough most of the time, but could Good enough most of the time, but could still get in troublestill get in trouble

SummarySummary

We have a robot that basically worksWe have a robot that basically works Can be put together in about 20 minutes, Can be put together in about 20 minutes,

most of the effort is finding the right partsmost of the effort is finding the right parts But, neither the software or structure is But, neither the software or structure is

very robustvery robust It can easily fall apart and it can easily get It can easily fall apart and it can easily get

stuck trying to recover from collisionsstuck trying to recover from collisions

SummarySummary

Due to the modification I made I didn’t Due to the modification I made I didn’t have enough parts to finish the robothave enough parts to finish the robot

Original design had a plate above the lift Original design had a plate above the lift arm, but I ran out of platesarm, but I ran out of plates

Without the plate the arm bounces and Without the plate the arm bounces and causes the robot to turn too muchcauses the robot to turn too much

I later made a plate out of two smaller I later made a plate out of two smaller plates, and it now works betterplates, and it now works better

LEGO TheoryLEGO Theory

If we are going to build things with LEGO If we are going to build things with LEGO we need to understand how it workswe need to understand how it works

Start by looking at the various LEGO parts Start by looking at the various LEGO parts and then move on to some of the standard and then move on to some of the standard structuresstructures

Look at some of the standard design and Look at some of the standard design and solutionssolutions

Get you started on your own designsGet you started on your own designs

LEGO TheoryLEGO Theory

The main structural units are bricks, plates The main structural units are bricks, plates and beamsand beams

The size of a LEGO piece is measured in The size of a LEGO piece is measured in studs, the little round things on the topstuds, the little round things on the top

Bricks are usually one or two studs wide Bricks are usually one or two studs wide and from one to eight studs longand from one to eight studs long

Bricks are used to build up structure, they Bricks are used to build up structure, they have no other purposehave no other purpose

LEGO TheoryLEGO Theory

Plates are thin bricks, 1/3 the thickness of Plates are thin bricks, 1/3 the thickness of a bricka brick

Plates can be used to build structure, but Plates can be used to build structure, but they are usually used to connect other they are usually used to connect other units or add strength to a structureunits or add strength to a structure

Beams are one stud wide, even number of Beams are one stud wide, even number of studs long, with holes running through studs long, with holes running through themthem

LEGO TheoryLEGO Theory

If a beam is ‘n’ studs long, it has ‘n-1’ If a beam is ‘n’ studs long, it has ‘n-1’ holesholes

Axles and pins can be placed in the holes, Axles and pins can be placed in the holes, so beams are often an important part of a so beams are often an important part of a robot’s chassisrobot’s chassis

Since beams are thin they often need to Since beams are thin they often need to be reinforced or the structure becomes too be reinforced or the structure becomes too weakweak

LEGO TheoryLEGO Theory

Pins are short and round and fit into the Pins are short and round and fit into the holes in beamsholes in beams

Two types of pinsTwo types of pins Free turning pins, can rotate inside the holeFree turning pins, can rotate inside the hole Friction pins, don’t rotateFriction pins, don’t rotate

Pins can be used to attach parts, or to Pins can be used to attach parts, or to attach wheels and gears to the robot’s attach wheels and gears to the robot’s chassischassis

LEGO TheoryLEGO Theory

Wheels, axles and gears are used for Wheels, axles and gears are used for movementmovement

A wide range of wheels, the larger the A wide range of wheels, the larger the wheel the faster the robot will movewheel the faster the robot will move

Axles are measured in studs, even though Axles are measured in studs, even though they have no studsthey have no studs

Gear are used to change the speed of Gear are used to change the speed of motion, or change its directionmotion, or change its direction

LEGO TheoryLEGO Theory

There are a number of other parts used for There are a number of other parts used for special purposes and decorationsspecial purposes and decorations

Lift arms are beams that don’t have studsLift arms are beams that don’t have studs They can be connected to other parts They can be connected to other parts

using pins and axlesusing pins and axles Pulleys can be used to transmit force, but Pulleys can be used to transmit force, but

are not as reliable as axles and gearsare not as reliable as axles and gears

StructuresStructures

Mindstorms comes with two motors, and Mindstorms comes with two motors, and the RCX can only handle threethe RCX can only handle three

We can only have a limited number of We can only have a limited number of independent motions, one per motorindependent motions, one per motor

In addition, motors rotate, what if we want In addition, motors rotate, what if we want a linear motion, or one with a limited a linear motion, or one with a limited rotation angle?rotation angle?

Also we cannot control the speed of the Also we cannot control the speed of the motormotor

StructuresStructures

The LEGO motor consists of a motor, plus The LEGO motor consists of a motor, plus a gear chaina gear chain

There is no way to control the speed of There is no way to control the speed of this motor, we can only control the this motor, we can only control the strengthstrength

That is, we can increase the amount of That is, we can increase the amount of force the motor produces, carry heavier force the motor produces, carry heavier loads, but cannot change speedloads, but cannot change speed

StructuresStructures

This introduces the need for a number of This introduces the need for a number of structures to produce different types of structures to produce different types of motion:motion: Straight linear motionStraight linear motion Repeated linear motionRepeated linear motion Restricted rotationsRestricted rotations Faster or slower speedFaster or slower speed Axis or rotationAxis or rotation

StructuresStructures

The structures that produce these motions The structures that produce these motions contain combinations of gears and axlescontain combinations of gears and axles

Gears can be used to change speed and Gears can be used to change speed and axis of rotationaxis of rotation

The size of a gear is measure by the The size of a gear is measure by the number of teeth it hasnumber of teeth it has

The standard gear sizes are 8, 12, 16, 24 The standard gear sizes are 8, 12, 16, 24 and 40 teethand 40 teeth

StructuresStructures

The standard gears mesh together, tooth The standard gears mesh together, tooth for toothfor tooth

This can be used to control speed of This can be used to control speed of rotation using different gear sizesrotation using different gear sizes

Consider a 8 tooth and 24 tooth gear Consider a 8 tooth and 24 tooth gear connected together, both with their own connected together, both with their own axlesaxles

Start by turning the axle on the 8 tooth Start by turning the axle on the 8 tooth geargear

StructuresStructures

StructuresStructures

Every complete rotation of the axle will Every complete rotation of the axle will move 8 teeth on the larger gearmove 8 teeth on the larger gear

This gear has 24 teeth, so we need 3 This gear has 24 teeth, so we need 3 rotations of the smaller gear for one rotations of the smaller gear for one rotation of the larger gearrotation of the larger gear

Similarly, one rotation of the larger gear Similarly, one rotation of the larger gear will produce 3 rotations of the smaller onewill produce 3 rotations of the smaller one

Thus we can go faster or slowerThus we can go faster or slower

StructuresStructures

Note: if we speed up there is less force, if Note: if we speed up there is less force, if we slow down there is more forcewe slow down there is more force

Need to consider what you are trying to Need to consider what you are trying to movemove

What happens if we want to change the What happens if we want to change the axis of rotation? The motor is facing one axis of rotation? The motor is facing one way, but we want the rotation in a different way, but we want the rotation in a different directiondirection

Two ways of doing thisTwo ways of doing this

StructuresStructures

One way is to use a worm gear and the One way is to use a worm gear and the other is to use a crown gearother is to use a crown gear

A crown gear meshes with a regular gear A crown gear meshes with a regular gear at a 90 degree angleat a 90 degree angle

When the crown gear is turned the regular When the crown gear is turned the regular gear with turn, but the axis of rotation has gear with turn, but the axis of rotation has been shifted by 90 degreesbeen shifted by 90 degrees

Structures – Worm GearStructures – Worm Gear

Structures – Crown GearStructures – Crown Gear

StructuresStructures

There are several ways of doing linear or There are several ways of doing linear or straight line motionstraight line motion

One is to use a crankshaft mechanismOne is to use a crankshaft mechanism There are only enough parts to make one There are only enough parts to make one

crankshaftcrankshaft It converts a rotational motion into a linear It converts a rotational motion into a linear

one by pushing and pulling an axle as it one by pushing and pulling an axle as it rotatesrotates

Structures - CrankshaftStructures - Crankshaft

StructuresStructures

The other way of doing this is to use a The other way of doing this is to use a gear rack, a plate with gear teeth on the gear rack, a plate with gear teeth on the toptop

Gear racks are attached to plates or Gear racks are attached to plates or beams and then meshed with a gearbeams and then meshed with a gear

When the gear rotates the gear rack with When the gear rotates the gear rack with move forwards or backwardsmove forwards or backwards

Maximum distance depends upon length Maximum distance depends upon length of gear rackof gear rack

Structures – Gear PlateStructures – Gear Plate

StructuresStructures

Our Tippy robot used two motors so it Our Tippy robot used two motors so it could both move and turncould both move and turn

To turn the robot we turned the wheels in To turn the robot we turned the wheels in opposite directionsopposite directions

We only have 2 motors, so using both for We only have 2 motors, so using both for moving the robot means we can have no moving the robot means we can have no other motionother motion

We need to be able to turn and move We need to be able to turn and move using only one motorusing only one motor

StructuresStructures

Moving with one motor isn’t hard, connect Moving with one motor isn’t hard, connect both wheels to the same axleboth wheels to the same axle

Turning is the hard part, how can we make Turning is the hard part, how can we make the two wheels move differently with just the two wheels move differently with just one motor?one motor?

The solution is to use something called a The solution is to use something called a differentialdifferential

Allows the two wheels to operate Allows the two wheels to operate independentlyindependently

DifferentialDifferential

StructuresStructures

The differential itself rotates, a gear The differential itself rotates, a gear meshing with one of its outside gears meshing with one of its outside gears provides the motionprovides the motion

The gear structure inside the differential The gear structure inside the differential provides the interesting partprovides the interesting part

The differential will normally turn both The differential will normally turn both axles, and the wheels attach to itaxles, and the wheels attach to it

This provides the forward motion for the This provides the forward motion for the robotrobot

StructuresStructures

But the two axles are independent, if one But the two axles are independent, if one axle stops rotating the other will keep axle stops rotating the other will keep goinggoing

This can provide our turning mechanismThis can provide our turning mechanism If when we reverse direction only one If when we reverse direction only one

wheel keeps turning the robot will turnwheel keeps turning the robot will turn The differential can handle this, but how The differential can handle this, but how

do we stop one of the wheels from do we stop one of the wheels from turning?turning?

StructuresStructures

The solution is to use a ratchetThe solution is to use a ratchet A ratchet is based on a gear and a block A ratchet is based on a gear and a block

that lets the wheel turn in one direction but that lets the wheel turn in one direction but not in the othernot in the other

We can add a ratchet to one side of our We can add a ratchet to one side of our differentialdifferential

When moving forward both wheels will When moving forward both wheels will turn, with moving backwards the ratchet turn, with moving backwards the ratchet will stop one of the wheelswill stop one of the wheels

Structures - RatchetStructures - Ratchet