Slashdot Mirror


Core Lego Mindstorms Programming

dr_skipper writes: "In the preface of Core Lego Mindstorms Programming, the author compares the Robotics Invention System to the first mass production automobile, the Ford Model-T. This put millions of cars into the hands of ordinary people, and kick-started an industry. Whether this kit will turn out to be the equivalent of the model-T of robots remains to be seen. We already know millions of these kits have already been sold, so at least it has the potential to capture a huge number of people into robotics that never would have ventured into it in the first place. Maybe someday we'll hear stories from robot engineers telling how they got their start with the Lego Mindstorms kit. Before Mindstorms there were lots of do-it-yourself robot kits that were usually a little sketchy. The promises often outweighed what was delivered, and it was never guaranteed that once all the transistors and capacitors were assembled that it would even work. Mindstorms has overcome this and caught on in a big way, as evidenced by the staggering robotics creations that are popping up on websites all over the Internet." The rest of John's review is below. Core Lego author Brian Bagnall pages 560 publisher Prentice Hall PTR rating 10/10 reviewer John Delisle ISBN 0130093645 summary Fantastic book - Covers robot construction, programming and much more!

The Mindstorms kit is for those people who have always wanted to play with robots, but couldn't find any time between work and home. In short, its a kit tailor made for programmers, not for those people with Mensa level IQs who know how to build an H-bridge circuit or a voltage regulator from scratch. Probably the easiest and most understood programming language right now is Java, and that is the language this book focuses on. The book introduces leJOS, which is a Java Virtual Machine (JVM) and operating system rolled into one. It's the first JVM I've seen to run in the tiny space of only 32kb. As lore has it, back when Java was known as "Oak," it was meant as a language to program small appliances such as remote controls, microwaves, televisions, VCRs and other household electronics. In all that time I've never seen Java actually used in such small devices until now.

This book starts out slowly, for people who are just cracking open the box. It gives a complete, in-depth overview of the hardware, as well as the included software -- which the author basically advises you toss away if you have any interest in serious robot programming. Surprisingly (or perhaps not surprisingly) the tiny RCX brick contains as much horsepower as the on-board computers for the Apollo moon missions. The brick contains 32kB of RAM, which seems small at first but when you realize the memory older computers like the Apple II and TRS-80 had, this is an ample amount. Some of those older games had a lot going on in terms of AI and graphics, so for robot applications without graphics it's a lot of memory. In the spirit of Bill Gates, 32kB should be enough for anybody. There are also some good (though prohibitively costly) third-party sensors that, if you owned them all, would give you most of the sensing abilities that old Spock had with his tricorder.

leJOS is a product of Sourceforge, and quite popular. The leJOS language, which is essentially Java with some cut-backs, is covered in depth. It has most of the features of the real Java language, barring object reflection and garbage collection. I haven't heard of any official "smallest JVM" contest but if there was one I'm sure leJOS would be one of the contenders. It definitely surpasses Sun Microsystems J2ME in the micro category. Setup is fairly straight forward and the author even includes a free IDE that works great with the leJOS.

Once past the introductory material, the book contains some truly interesting projects. In a way, the book is similar to the general robotics book Mobile Robots: Inspiration to Implementation (Jones, Seiger, Flynn), except it's for the Mindstorms crowd. There are many robots to build, including a wall-following robot, a robot that navigates with a real compass, a robot you can control from a web page, and some surprisingly in-depth hacking tricks. Unlike books which only give suggestions on how to build robots, this book includes complete building instructions and code listings for every project. The fact that Lego parts and RCX bricks (the processing center of a Lego Mindstorms robot) are identical to each other allows this to be possible. It contains not just 'how to' information, but expands into robot theory as well. Books such as Mobile Robots have to be general and ambiguous at times because the authors don't know what kind of parts a reader will be able to obtain. In a way, this is the genius of Lego Mindstorms - the ability for people to pass robot recipes to one another.

The final two chapters really kick the leJOS language into overdrive. These sections are where geeks thrive. Chapter 11 deals with connecting the RCX brick to the Internet. Apparently the leJOS language has built in classes for sending data, and even a handy Java bean that's useful for embedding JSP web pages. These projects are described down to the last detail, including showing how to set up a free Resin server to serve the web pages. Unfortunately the author does not take the time to explain much of anything with JSP, so beyond his JSP examples you may not get very far. Readers will be forced to look elsewhere if they want to learn more about JSP.

The final chapter really goes hard core. It contains some so-so information about how to hack leJOS, changing classes or removing methods to save memory. The real kicker is a feature of the leJOS JVM I was not aware of: leJOS is capable of running almost ANY language. Apparently even the official JVM is capable of running a multitude of third-party developed languages, including Fortran, C, and weird custom languages such as IBM's NetRexx. All that's required are the development tools to compile the source code into Java bytecode, and these compilers exist in abundance. There are no fewer than 100 such available languages, all free for the downloading.

Illustrations in the book are frequent and helpful, but somewhat plain. Usually they consist of line drawings without much artistic merit. The 3-D renders of the robots are exceptional, however. Each step in building the robots has been rendered, making the Lego parts very easy to see. The steps are well laid out, and the new parts for each step are suspended in the corner and labelled. Thankfully, all models in the book can be built with any version of the Robotics Invention System kit.

If you are a programmer who has an impulse to experiment with robots, but don't want to get solder on your fingers building from scratch, this book will get you to where you want to go. And if you do want to get some solder burns, there's even a few projects in here just for you. Overall the book is a joy to read. The author obviously loves robotics and his enthusiasm shows on every page. The tone is loose but contains a lot of detail presented in an easy-to-digest manner. If you want to dabble in robotics then Lego Mindstorms is the easiest way to do it and having this book is a good way to get started.

You can purchase Core Lego Mindstorms at bn.com. You can read your own book reviews in this space by submitting your reviews after reading the book review guidelines.

32 of 108 comments (clear)

  1. imprecise hardware... by kisrael · · Score: 4, Insightful

    I only played a little bit with the first generation they released, and only using that bad visual block language it came bundled with. But one problem I see is that you couldn't specify exact degree turns or amount of motion consistently. For instance, there'd be no way to make a robot that consistently turned 90 degrees and went forward X inches; you're forced into a more biological, reactive method of programming. That's not an entirely bad thing, though it ramps up the level of difficulty, especially in that original block language, don't know about these later ones.

    --
    SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    1. Re:imprecise hardware... by sk8king · · Score: 2, Informative

      They do have rotation sensors now which are very accurate...if you need more accuracy, just change the gearing ratios.

      The sensors count 16 ticks/rotation...just change the gears to make it count 160 ticks/rotation or 1600....the accuracy is there for anything you make with lego.

    2. Re:imprecise hardware... by flipflapflopflup · · Score: 3, Informative
      From the little robotics experience/knowledge I have, I seem to remember this style is advocated, as in the *real world* it's not good to rely on your hardware being 100% accurate (it may be fair to say that in this case, a high-precision, very specific factory setting is not really the *real world*).

      This may mean, as said, the difficulty is ramped up a little - but the effect will be that the results will be a lot more robust and rewarding. Otherwise beginners in the field may spend weeks on their cd autochanger, find it becomes uncalibrated after 2 cds and give up. If robotics is going to explode into the field everyone wants it to, it's best that best practises are forced now, not later.

    3. Re:imprecise hardware... by sk8king · · Score: 2, Informative

      That is why you always reset to a known point with robotics...there will be drift in mechanical instruments and you will have to reset to a known point. I agree with good practices being forced now as well, but you can also use the parts given to you. No part will be 100% accurate but that doesn't mean you should dismiss it.

      Carpenters know that if you want to cut a 16' length of wood into 4 foot sections, you measure 4' from the end and then 8' from the end and then 12' from the end...not 4' then another 4' then another 4'. The measuring tape is extremely accurate if used correctly, just like the sensors in the robotics set.

    4. Re:imprecise hardware... by goldenfield · · Score: 5, Interesting

      This is representative of robotics in general. Robots are notoriously BAD at knowing where they are in the real world, or exactly how far they have moved. That's why NASA had a lander and a rover in the Mars Pathfinder mission. The lander had a pan and scan stereo camera that could pretty accurately measure the rover's relative position from the lander (IIRC, cameras were accurate to about 5mm at 5m, but I'd have to review my notes). Without an external view, NASA would have quickly lost the rover - in one sequence of commands, the error in where the rover ended up from where it was commanded to go was as large as the distance it was supposed to move!

      One way (I think, anyway) to get around this is to have many rovers all talking to each other and to the lander. Robots are good at sending relative positions, but bad at determining absolute position. So you get each robot to stay in constant contact w/2 other robots, and deterime their positions relative to itself. As long as one robot stays in constant contact with the lander, the lander can do some simple vector math and determine the positions of all the other robots! This would be cool because you can string out the robots in a long line, and you can safely move robots outside of the visual range of the lander. I wrote about it in my thesis.

  2. Re:Robots were HUGE in the 80's by coryboehne · · Score: 2, Insightful

    Human labor (so far as the present time) cannot be replaced in many jobs, there is simply currently no way to program a robot to respond to all of the problems that may arise in just about any given "real-world" situation. The thing we need to worry about is how to effectively manage and balance human and robotic labor.

  3. Robots and Complexity by httpamphibio.us · · Score: 2, Interesting

    A couple years back, before all the robot fighting shows started popping up, I decided that I wanted to get into robotics to enhance my art projects. I searched everywhere for books and relevant information, but all I found was extremely basic kids books that didn't really tell me anything useful or extremely complex stuff on "muscle wires" and the like. I found there wasn't much of a middle-ground and soon I was onto something else. It appears as though the scene has changed a bit, how much will Lego Mindstorms help me in learning how to create more complex interactive robots?

    --
    sig.
    1. Re:Robots and Complexity by Uberminky · · Score: 5, Insightful
      I've been interested in robotics since I was a kid (I'm 21 now). Where I grew up, I didn't have access to resources like Radio Shack, or well stocked hardware stores. (Mail was about 2 weeks each way.) I tried to do what I could, reading all the books I could find. "Robot Builder's Bonanza" was an awesome book, which gave me many ideas and helped give me a foundation. But as you say, there were no books for the middle ground. I still didn't know jack about robots, when it came down to it.

      Here is my tip for you. I know it's lame and obvious, but still: find other people that are working on this stuff. When you have a real question, no book will answer it. You can only answer it one of two ways: working your butt off for unreasonable amounts of time (what I was forced to do), or asking someone who knows. No online forums, none of that -- real live people. And then, it takes work. Lots of work. And time. (And money. Ack!)

      how much will Lego Mindstorms help me in learning how to create more complex interactive robots?

      I like MindStorms because they get kids and other people involved with robotics that otherwise wouldn't be. You can presumably learn a thing or two from them. But for people actually interested in learning real things, I'd say it doesn't take you far. You learn about gear ratios, great. But where do you buy a gear? What pitch should it be? How does the rotation sensor work? How will you learn about back-EMF and how to protect your circuits from it? Maybe I'm just biased, but I think it doesn't teach you so much, as it lets you play with hardware without investing time to do it. (I've always been convinced that the real value of MindStorms was the LEGO blocks, not the microcontroller at all.) Mindstorms are great. Get excited about robotics with them. Then get off your lazy butt and make it to the club meetings! ;)

      I've been working on some things for the new members of the Indiana University Robotics Club for next year. Kits and things that will let anyone get started building robots from scratch, for cheap. But even that will only take people so far. If you want to move past the kits, you need to learn a little about electronics. (This book is awesome: Practical Electronics for Inventors.) Find people with the same interests to work on projects with, and find people you can ask questions. Then start on a project, and learn everything you can. This WILL take time.

      Robotics is hard. There are ways to have fun without getting far into it (like MindStorms). But if you want to really learn, you need to find people to help you, and you need to invest time learning.

      <beating dead horse>

      --

      The streets shall flow with the blood of the Guberminky.

  4. Vacuum Cleaner! by coryboehne · · Score: 3, Interesting

    Remember that scene in 'The Fifth Element' where all the cute little robots come out of the wall and clean up the broken glass, well I wonder how much trouble it would be to say create a couple of specialty mindstorm bots to do this on command (obviously not environment reactive, but event driven is good enough for me) Hook up a small broom and dustpan to one, hook one up to my vacuum and `viola! I'll never do housework again :)

    1. Re:Vacuum Cleaner! by interstellar_donkey · · Score: 3, Funny

      but event driven is good enough for me

      Just remember to put your gown over the hook, place your towel over the drain, place your satchel over the panel and put your junk mail on top of the satchel...

      Otherwise, you'll never get anywhere with these bots.

      =

      --
      The Internet is generally stupid
  5. forget the Lego by insanegadgets.com · · Score: 2, Funny

    ...I want a rubbermaid...

  6. When I were a lad... by delphi125 · · Score: 3, Funny

    I combined my lego and my computer. It may not have moved, but that was the whole point. You see, I had a ZX-81 and a 16k RAM pack with a VERY wobbly connection, and lego just did the trick of keeping it in place!

  7. Sun's article by SashaM · · Score: 5, Interesting

    Here's Sun's article on this. Apparently, they managed to squeeze a JVM with multithreading (although no garbage collection) into 16K. Who said Java was big and bloated? :-)

    A funny quote:

    The robot that they built for the International Space Station, called Jitter, floats around collecting particles of debris. So even though it doesn't have a garbage collector, it is one!

  8. with all the lego book reviews by f00zbll · · Score: 2, Interesting

    maybe /. should sponsor a MindStorm-athon. A bunch of geeks in the room, 24 hours and lots of caffiene. I'm sure Lego could be convinced to donate the lego's, since they could take those robots and use them for PR and other marketing related uses.

  9. Everquest. by Gannoc · · Score: 3, Funny

    A few years ago, I made a lego mindstorms robot that would automatically fish for me in everquest. I know there were better ways of doing it, but it was pretty cool. ;)

  10. Re:Robots were HUGE in the 80's by Ted+Maul · · Score: 2, Informative

    The biggest (Fanuc) are still going strong. I suspect that a lot of their business was in the CNC controls area they had some neat stuff like moving from just G codes to the interactive/graphical FAPT programming. I've been out of the CAM business for a while now and looking at their site now, they seem to be basing their new controls on XP or CE. Could be interesting in your $10,00,000 5 axis laser cutter.

    --

    The Day Today - Game Warden to the Events Rhino
  11. Interesting Simulation/Robotics project by moooo · · Score: 4, Interesting
    A guy I know did a project in lego mindstorms and lejos as part of his final year,

    check out

    http://www-theory.dcs.st-and.ac.uk/IC_Group/resour ces/software/software.shtml
    - for the software

    and

    http://www-theory.dcs.st-and.ac.uk/IC_Group/resour ces/multimedia/multimedia.shtml
    for cool movies and videos of the lego robot.

    Various different types of learning were played around with ; neural, reinforcement learning , handcoded algorithms....

    Those pages are still to be ok'd with my local dept. though, so please email gbb@dcs.(nospam).st-and.ac.uk if you have any questions about them.

  12. Re:I buy when by slantyyz · · Score: 3, Funny

    To kill two birds with one stone, you should just integrate a Mindstorms robot with a vacuum cleaner and a Flowbee attachment. Then you could use it to cut your hair and lawn.

  13. No, don't, the outgassing will kill you by Hairy_Potter · · Score: 5, Funny

    If you haven't opened those tubs in a few years, the outgassing from the ABS will have created lethal quantities of lethal phosgene gas.

    Fortunately, I can take those off your hands, and safely dispose of them, just email me for shipping information.

  14. After you have read the book... by krswan · · Score: 3, Interesting

    Take your Mindstorms set to a local school, gather a group of geeks-in-training, and join the First Lego League. The challenges are complex and fun, and it sounds like the programming information and tips in the book would lead to some really great robots.

    Best of all, you will be helping kids see that computers can be used for more than just video games and IM.

  15. Re:this book looks amazing by NineNine · · Score: 2

    This is absolutely ridiculous. The Net is no replacement for books. The ease of publishing on the Net is reason enough *not* to rely on the Net for information... how accurate can it be if a 8 year old can slap up a web page? I'm willing to trust a book that has gone through many editors and reviews and has spent a lot of money to be published than I am some silly web page.

    The "information wants to be free" thing is just stupid.

  16. Re:Robots were HUGE in the 80's by Ooblek · · Score: 2

    The people who make robotic CD duplicating machines are apparently doing pretty well right now.....Just ask Eminem.

  17. Re:Good Old Legos by ncc74656 · · Score: 3, Informative
    Now I finally have a good reason/motivation to open up those huge rubbermaid tubs of Legos sitting my closet at home.

    ...and if you need an RCX brick to control them, it appears that Target is blowing out the Robotics Invention System 2.0 kits for $100 (their normal price was $200). I snagged one last Friday and am wondering if I should get another (they had two on the shelf).

    --
    20 January 2017: the End of an Error.
  18. Re:Robots were HUGE in the 80's by Junks+Jerzey · · Score: 2

    I remember how big robotics was supposed to become, and how they would replace all our industrial workers...

    And so they did to a great extent. Have you ever seen the assembly line at any auto manufacturerer? Just because a robot doesn't walk on two legs and push a vaccuum doesn't mean it isn't a sophisticated robot.

  19. Re:Robots were HUGE in the 80's by interstellar_donkey · · Score: 2

    seem to be basing their new controls on XP or CE

    Being as it's early and I'm quickly skimming posts, I first read that as "bashing their new controls on XP or CE" and had this image in my head or robots being so fed up with their host computers... well, you get the idea.

    -

    --
    The Internet is generally stupid
  20. Re:So how much would it cost to get into this? by sk8king · · Score: 2

    In the past year I have fallen into the LEGO trap and buy quite a bit. It seems that I've become a piece collector [most pieces are sorted to the extreme] than a set collector. The RIS is a good set but you pay for the RCX unit. A little more money could get you a killer educational resource set.

    I also find myself picking up those little sets they have now just to get a few extra gears or something.

    Basically, it costs as much as having a killer computer system...you're always upgrading.

    Click here for prices on pieces.

  21. Mindstorms Java & Linux by julianc · · Score: 4, Informative

    I recently bought a mindstorms set along with the core mindstorms book. I've found it all great, but the standard Lego software only works with Win98/ME.
    Under Linux the problem is that the Robot Invention kit 2.0 only has a USB infrared tower to download programs to your lego brick - v1.5 and 1.0 had serial towers where were easy to access from Linux.

    The setup I've got currently is Linux with VMWare 3.1 Running Win98 - that way I can get transfer programs using the USB support from the Win98 and USB support from VMware 3.1.

    Its not a great setup but it means I only have to run one program, the lejos transfer program in my Win98 sandbox. (I couldn't get the main lego program to run under VMWare/Win98 - when it attempted to access the usb I just got segmentation violations and vmware disappeared!)

    There is a project at sourceforge - legousb.sourceforge.net to add the usb support for the lego tower to linux but its not very advanced.

    Overall if you know java, then programming mindstorms using lejos is a breeze. The book for me has been an excellent guide to both java/mindstorm programming, and the types of extra equipment such as sensors that make everything more enjoyable. There are even projects in the book to build distance sensors using the Sharp GP2D12 sensor and a compass sensor.

    The book also touchs on Behavior Control Theory and Navigation theory, and shows how the lejos java API provides you with classes that implement these concepts.

    If you know java and want to use mindstorms, then this book is a must.

  22. The Java Lego MindStorm Challenge by marick · · Score: 2

    Sun didn't invent the LeJOS system, but they certainly do like it.

    Last year, a bunch of undergraduates and I
    participated in the Java Lego Mindstorm challenge, a particularly silly competition between Stanford, UC Berkeley, and UC Santa Cruz. Berkeley won with a money-sorter.

    Anyway, working with the kit was really fun and leJOS worked well. Check out the photos:

    http://www.sun.com/developers/evangcentral/chall en ge/photos.html

    Or read about the event:

    http://www.sun.com/developers/evangcentral/chall en ge/

    LeJOS really is all it's cracked up to be. It provides a very familiar (for Java junkies) interface to the sensors, motors, etc. of the lego mindstorms kit. Of course, you still need some fine muscle control in order to be able to assemble the legos. The undergrads did that part. ;-)

  23. Curious about no garbage collection by slow_flight · · Score: 2

    How does memory management work without garbage collection? Is there an explicit delete, or is it a matter of once allocated, always allocated?

    --

    Karma: Professionally Doomed (mostly affected by inability to keep opinions to self)
  24. Just showing off by brejc8 · · Score: 2

    Just wanted to show off my creations.
    My webcam
    You can see it working or play with ithere
    And my hamster powered 32bit microprocessor

    1. Re:Just showing off by brejc8 · · Score: 2

      Actualy its a IE5 fault. It cant recieve push connections. It also doesnt work with konqueror as that also lacks the feature. Im not victimising IE5.

  25. Re:I buy when by Dwonis · · Score: 2

    Here's one.