1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

LEGO MINDSTORMS - Building Robots Part 13 ppsx

40 168 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Drawing and Writing
Chuyên ngành Robotics
Thể loại Chương học
Năm xuất bản 2001
Định dạng
Số trang 40
Dung lượng 1,15 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The most known characteristic creation of Logo is the Turtle, a symbolic turtle that moves across the computer screen according to the instruction itreceives.With simple instructions lik

Trang 2

Drawing and Writing

Solutions in this chapter:

Creating a Logo Turtle

Creating a Tape Writer

Further Suggestions

Chapter 23

441

Trang 3

Can a MINDSTORMS robot be made to draw or write? Sure Believe it or not,that’s not even a very difficult thing to implement In the following pages, wewill show you two projects, the first mainly meant for drawing and the secondfor writing Both of them require some additional parts, but both have wide mar-gins for modifications and allow for less demanding variants

Creating a Logo Turtle

Many of you may already know that Logo is a programming language specificallytargeted to education Born in the late 60s at the Massachusetts Institute ofTechnology (MIT), Logo is derived from Lisp (with a lot fewer parentheses!) andfeatures interactivity, modularity, and extensibility More than a programming lan-guage, Logo is a learning tool which has gone through a number of changes andimprovements over the years

The most known characteristic creation of Logo is the Turtle, a symbolic

turtle that moves across the computer screen according to the instruction itreceives.With simple instructions like forward 10 the turtle moves straight tenunits, and with right 90 it turns clockwise 90 degrees.The statements penup andpendown specify whether the turtle leaves a track behind it, thus producingdrawings or rather just moving to a different location Obviously the languageincludes many other commands, but these are enough to understand the princi-

ples of the Turtle Graphics that made Logo so famous.

What many people don’t know is that in its first version, the Logo programcontrolled a small robot that actually drew lines on the floor In subsequentreleases, the turtle became just a virtual animal on the screen Our interest here,however, is in replicating its first robotic version

NOTE

Dr Seymour Papert was one of the early promoters of Logo, and designed the original Turtle Under his guidance, the Epistemology and

Learning Group at MIT devised the first programmable brick, whose

con-cepts led to the development of the LEGO MINDSTORMS line

Trang 4

Building the Turtle

The idea is quite simple: Build a small robotic platform that’s able to go forwardand backward, turn in place, and lower and raise a pen Despite this apparent sim-plicity, if you want a turtle that works as expected, the task has many stringentrequirements that must be adhered to For instance:

1 The robot must go absolutely straight

2 The pen must be exactly in the pivoting point of the robot, because itmust stay in the same place on the floor while the robot turns (other-wise it would trace a curve)

3 You need a tracking system to measure both traveled distances andangles

If you remember the driving architectures described in Chapter 8, youalready know the solution to the first point: Use a dual differential drive.Thesimple differential drive is suitable for this project only if you apply an activecontrol to the wheels to be sure they travel exactly the same distance, while thesynchro drive would work as well but at the price of greater complexity and not

so evident change in orientation during action Another advantage of the dualdifferential drive is that it requires a single encoder to comply with point 3: whenthe robot goes straight it measures the covered distance, when turning it measuresthe angle

OK, so we have requirements 1 and 3 covered, but there’s still the matter ofthe pen being the center of rotation, which is at the midpoint of the imaginaryline that connects the wheels Conceptually it sounds easy, but you have to buildyour robot with this point in mind

The original turtle—a differential drive—featured a transparent plastic dome

to cover the gears.We provided our turtle with a triangular shape (Figure 23.1),because we wanted to mimic the screen turtle of some widespread Logo systems

Anyway, those V-shaped beams are definitely not necessary and you can shapeyour own turtle according to your wishes

Our differential drive does not use a caster wheel, because they tend to affectthe direction of the robot slightly when resuming straight motion after a turn

With casters, the straight lines would have a short wiggly segment, so we ferred to use a simple tile as the third supporting point.To keep the friction onthe floor to a minimum, we placed the RCX suspended behind the drive wheels,like a sort of counterweight, bringing the COG of the robot very close to thedrive axles and thus most of the weight upon the drive wheels

Trang 5

pre-There’s another advantage to having the RCX pointing upwards:This mizes the possibilities of communications between the tower and the robot, usingthe ceiling of the room as a mirror for the infrared (IR) rays (see the sidebar,

maxi-“What’s Infrared Communication?”)

Let’s start exploring the dual differential drive chassis that drives the robot(Figure 23.2).The gearing is more compact than those shown in Chapter 8, but itworks exactly the same way: One motor makes the differential gears and thewheels rotate in sync, while the other rotates them in the opposite direction.Youcan notice the rotation sensor coupled to the right wheel.The dark gray 16t gearright in the middle of the photo is an idler gear which connects the other two16t gears; its center hole is not cross-shaped and thus it doesn’t couple with thelong joined axle that crosses the base of the robot

Figure 23.1The Logo Turtle

Trang 6

What’s Infrared Communication?

Infrared (IR) light is of the same nature as visible light, but its frequency

is below that perceivable by the human eye Provided the intensity is high enough, we usually feel IR radiation as heat.

For most properties, IR light is really identical to visible light: It gets reflected, refracted, diffused, or shielded by different kinds of bodies.

When you want your robot to stay in communication with the tower, they must “see” each other all the time This is not always easy when the robot moves and changes orientation, but for indoor situations, you can take advantage of the ceiling, as described, to reflect the IR beams downward In most cases, placing the RCX with the tower facing upwards works very well and solves the problem.

Bricks & Chips…

Figure 23.2The Turtle Dual Differential Drive Platform (Top View)

Trang 7

Looking at the bottom, you can see the front skid plate (Figure 23.3).

Using a technique described in Chapter 11, we placed a rubber band to makethe mechanism bi-stable, so that when the pen is down it tends to stay down, andvice versa (Figure 23.4)

The pen is a non-LEGO part, a common marker with its body wrapped inadhesive tape so as to make it fit tightly into the 2 x 2 studs squared hole

reserved for the purpose It stays there with nothing but friction

The pen control mechanism is a swinging assembly operated by a third motor(Figure 23.5)

Now the turtle is ready Place a large piece of paper on the floor, uncap thepen and adjust its height so it touches the paper gently when in it is in the down

position (Figure 23.6).We strongly discourage you from writing directly on the floor.We’re sure somebody won’t like it!

Figure 23.3The Turtle Dual Differential Drive Platform (Bottom View)

Trang 8

Figure 23.4Side View of the Turtle Pen Mechanism

Figure 23.5Turtle Top View

Trang 9

Programming the Turtle

The first task in programming the Turtle is to create the primitives that control

the basic actions Let’s start with the easiest ones: the penup and pendown

com-mands A short impulse to the pen motor does the trick—nothing more is

required If you want to avoid lowering the pen again when it’s already down, in

case of repeated pendown commands, you can monitor the status with a

vari-able In the NQC example that follows, we defined two constants UP and

DOWN to make the code clearer; in fact, the instruction pen=DOWN is muchmore self-explanatory than its equivalent pen=0

Trang 10

{ OnFwd(OUT_B);

Wait(PEN_TIME);

Off(OUT_B);

pen=DOWN;

} }

The constant PEN_TIME will be typically something like 15 or 20 dredths of a second.The penup routine is obviously identical except for thedirection of the motor and the values the pen variable is tested and assigned

hun-The forward and back commands, meanwhile, are not very difficult to

implement, but require that you dig into the physical properties of your robot

You must discover what distance it covers for any increment of the rotationsensor.The model is the same as that explained in Chapter 13 when we discusseddead reckoning, but here it is simplified by the fact that the wheels always travel

at the same speed.The equation was:

F = (D x π ) / (G x R)

where D is the diameter of the wheel, R the resolution of the rotation sensor,and G the gear ratio between the sensor and the wheel.We used a wheel with anominal diameter of 5 cm.The resolution of the rotation sensor is 16 counts perturn, and is geared 1:3 with the wheel—thus our formula becomes:

Trang 11

slippage, too.We suggest you proceed by experimentation, making your turtledraw a line, measuring it and then correcting the factor until you’re happy withthe result All this process is meaningful only if you care about having your turtleuse units that correspond to some common length unit If you don’t care, simplyuse the rotation sensor counts as units.

With the required count determined, your subroutine will simply reset therotation sensor and start the motion motor until that count is reached.The NQCexample that follows assumes that the rotation sensor is attached to input port 3,and that the motor that drives the turtle straight and forward is powered byoutput port C:

void forward(int dist)

The back subroutine will be symmetrical to this one, with the motor

reversed and the sensor counting negative numbers until a negative limit isreached

Now the last part: the turning primitives right and left If you glance again atChapter 13, you find that the change in orientation ∆OR(in radians) depends onthe distance covered by the wheels (TR – TL) and the distance between thewheels (B).When the dual differential drive turns in place, both the wheels travelthe same distance (T) in opposed directions, so we can express the equation insimplified terms:

∆ OR= 2 x T / B

This relationship is shown in graphical form in Figure 23.7 Don’t worry ifyou are not familiar with measuring angles in radians.We are going to convertradians into degrees in a few steps

Trang 12

Actually you know the ∆OR you want to get, it corresponds to the desiredturning angle of the turtle, and it’s the input to your subroutine.What you’relooking for is the Count of the rotation sensor that produces that ∆OR.The firststep is to obtain T from the previous equation:

count = angle/2.6;

Where angle is the desired turning angle, and count the number of ticks ofthe rotation sensor that correspond to that angle But there is no floating pointmath on the RCX, so you cannot divide by 2.6 and you need to scale yournumbers up to express this ratio using integers (see Chapter 12) Here is the

Figure 23.7Computing Changes in Orientation

Trang 13

complete NQC implementation of the right routine (the turning motor

con-nected to output port A):

void right(int angle)

decrease the divider (Figure 23.8)

Instead of working on the software, you can often change the geometry ofthe robot Altering the distance between the wheels by moving them in or outalong the axles is a very effective way to tune the robot Make small adjustmentsuntil your square comes out perfect

Figure 23.8Tune Calculations by Testing Your Turtle in Drawing a Square

Trang 14

Looking at the problem another way, you can force a specific result from theexpression πx B / (360 x F), for example 1/3:

π x B / (360 x F) = 1/3

B = (360 x F) / (3 π ) = 12.49 cm

We suggested 1/3 because this would lead to the code count=angle/3.That’svery simple, but more importantly, it doesn’t suffer from rounding errors on manycommon multiple of 3 angles like 30°, 60°, 90°, 120°, 180°, etc

Work patiently on your turtle and its code.The result will astound you!

Figure 23.9 shows our turtle drawing an almost perfect five-pointed star and asquare

Choosing the Proper Language

As a general principle, in this book we don’t suggest any specific language foryou to program your RCX.We provided examples in NQC just to find acommon background with the readers to discuss programming issues; however,most of the projects in this book can be translated into any language of yourchoice In this chapter, we make an exception—we are going to recommend a

Figure 23.9The Logo Turtle in action

Trang 15

particular language, because we feel that the Logo Turtle project would benefitfrom a lot of interactivity.

A product specifically designed to marry LEGO to Logo does exist, it’s theDACTA Control Lab Learning Environment But it’s been designed to interfacewith the Control Lab, not the RCX, and is a very expensive product Staying inthe range of free software, in our opinion the best choice for this project ispbForth, whose interactivity corresponds to the original Logo philosophy

PbForth uses the Reverse Polish Notation, so your statements will becomereversed in respect to the Logo ones: FORWARD 10 will become 10 FOR-WARD, but is this a serious problem? With pbForth you can sit at your PC, typesome commands on the console and watch the turtle execute them Like inLogo, you can easily define new words to draw complex shapes, all this withoutbeing subjected to a compile-upload cycle

If you don’t want to approach pbForth, but still would like to make yourturtle interactive, you have other options One is sending commands through IRmessages.You have 8 bits for each message, and can use three of them to code the

main commands (forward, back, right, left, penup, pendown) and the

remaining five for the command parameter Five bits correspond to 32 differentvalues, enough to code the angles, for example, in increments of 15°

Alternatively, you can design a two-byte messaging system, where the first bytecorresponds to the command and the second byte to its parameter

Another option could be to write an interface for your PC that performs allthe computations and sends direct bytecodes to control the robot, while at thesame time polling its sensors

Variations

Let’s examine what you can do in case you need some of the parts we used forthis project, starting with the second differential gear Using only one differential,you can make it subtract the motion of one wheel from the other, so that thedifferential case remains stationary when the robot goes straight (see Chapter 8)

In this setup, you connect the rotation sensor to the body of the differential andensure that during straight motion it doesn’t rotate, slowing down the fastermotor of the two when necessary.You have to rely on temporization to controlthe distance to cover during straight motion, but for turns, which are more diffi-cult to control, you can still use the rotation sensor exactly as in the case wedescribed

Trang 16

If you have two rotation sensors, you can build your turtle on a simple ential drive, and concentrate your efforts on the software that would have to keepthe wheels in phase both during straight motion and turns.

differ-On the other hand, if you have no rotation sensor, you should dig back intoChapter 4 to see how you can make a fake one using other kinds of sensors

Provided that the paper sheet provides a good color contrast against the floor,you can place a downward-looking light sensor to prevent your Turtle from acci-dentally writing off the edge of the sheet

Tape Writer

The second project of this chapter uses an approach somewhat opposite to that

of the Logo Turtle: Here it’s the paper that moves, while the robot stays still.Theprinciple is similar to the one used in ink-jet printers: A mechanism feeds thepaper under a writing head, which by itself moves perpendicularly to the direc-tion in which the sheet advances From what you learned in the previous chap-ters, you can tell that such a system has two degrees of freedom, controlledrespectively by a paper feeding motor and by the writing head motor (actually,our robot implements a third DOF, needed to move the pen up or down overthe paper).This Tape Writer is also a Cartesian system, because the movements ofthe mechanisms are linear and perpendicular to one another

This robot requires some extra parts: a motor, some plates and beams, andmany tiles; however, if you don’t have the needed parts, there are many thingsyou can do to downsize the project to keep within your inventory (we’ll describesome of them)

Building the Writer

What we have in mind is a robot that writes on one of those common papertapes made for printing calculators or cash registers One motor moves the paperstrip forward and backward, while a second moves the pen in a perpendicular(side-to-side) direction.The third motor controls the up/down pen movements

Starting from the end, here’s our finished robot that writes the traditional

“Hello world!” welcome sentence (Figure 23.10)

Trang 17

Analyzing the Tape Writer in detail, you can see that it’s made of a body andthree subsystems, all of them with one degree of a freedom.

■ The body provides the main structures and hosts the paper transportsystem

■ There’s a movable carriage over the body, which transports the pen in adirection perpendicular to the tape

■ Over the carriage, the pen assembly moves up and down

■ At the bottom of the body, there’s the writing surface, a smooth surfacethat presses the paper against the wheels

Looking inside the main body, you catch a glimpse of the transport wheelsand the pen assembly (Figure 23.11)

The wheels are operated by a motor through a worm gear and three nected 24t gears (Figure 23.12).This latter geartrain is necessary to keep the twogroups of dragging wheels turning in the same direction.You need the paper to

con-go back to shape some letters, and this is the reason why there are wheels both

Figure 23.10The Writer Composes Its First Sentence

Trang 18

Figure 23.11Writer Side View

Figure 23.12Writer Rear View

Trang 19

Removing the pen carriage, you see the wheels and the paper tape downbelow (Figure 23.13).The carriage is translated using a rack and pinion assembly,powered by a second motor on the body.We used two touch sensors to detectthe carriage limits, but you could just as well employ a single sensor with twoclosing pegs, as we did for many other projects in this book.

A second rack and pinion system, operated by the third motor, controls thevertical movement of the pen (Figure 23.14)

We tried different ways to attach the pen, until we discovered that manycommon and cheap pen refills have a diameter close to that of the LEGO flextubing.This simplified our lives a lot (Figure 23.15) Make sure you don’t damagethe refill, otherwise you’ll end up washing a few LEGO parts!

The top is completely covered with tiles (Figure 23.16).The irregular surfacecovered with studs wouldn’t work In case you don’t have tiles, or not enough ofthem, cover the plates with a smooth, thin support, like a glossy cardboard, analuminum or plastic sheet or anything else similar that comes to mind.You canalso build a top out of standard LEGO bricks laid on their side, which shouldprovide an even more regular surface than tiles

The writing surface is an independent part linked to the main body throughshort rubber bands (Figure 23.17).Those bands pull the surface up against thepen and against the wheels of the feeding mechanism

Figure 23.13Writer Top View, Pen Carriage Removed

Trang 20

Figure 23.14The Writer’s Pen Assembly

Ngày đăng: 10/08/2014, 04:22

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN