Thoughts On Lego Mindstorms Programming

I’ve had the privilege to be a First Lego League (FLL) coach for the past two years.  It’s a very rewarding experience as I am amazed at the hard work and awesome ideas that these kids put into the research and their presentations.

The FLL competition each year revolves around a main theme.  This year it was called Food Factor and was all about keeping food safe.  The competition has three areas of emphasis, the Research (identifying and providing solutions to problems), Core Values (team participation, enthusiasm, gratious professionalism), and the robot (design and programming).  This is a very brief overview but you get the point.

FLL is for kids 9 to 14 years old and this year my team consisted of 10 kids (double the team size from last year) with two sixth graders, two fifth graders, a fourth grader, and five 3rd graders with seven of the ten being brand new to the program.  The ‘hook’ for most of the kids is the Lego Mindstorms robot and at the table competition challenges are made from Lego’s.  It’s brilliant because what kid doesn’t like playing with Lego’s?

In reality, though, there’s after building the field components there’s not a lot of Lego building.  There’s *some* with the robot but once you build it you really don’t want to mess with it much.  The robot is really about learning how to program and that’s where my big beef comes in.

After having used the Lego Mindstorms graphical programming environment for a couple of years for my First Lego League team I decided that it teaches them little to nothing about programming.  The graphical programming environment seems easy but in reality the kids find it frustrating and once you get past simple programs it quickly gets confusing.  There are ways around these limitations but I feel it in no way teaches the kids about good programming principles.

The IDE uses ‘blocks’ to describe what’s going on.  But, because the display doesn’t show the properties you are constantly having to click on blocks to see what is going on with that block.  So the graphical environment is NOT self documenting.

The left to right programming environment isn’t like most other languages.  I don’t know if this is a spurious argument or not but I find the left-to-right paradigm unsettling.  I spent years doing PLC programming in my electrical engineering days and I found it easy to describe how logic ‘fell through’ to the next level.  This language was used by a lot of plant electricians and a lot were not the ‘programmer type’ if you get my meaning.  All programming languages I’ve used professionally are text based vertical (top to bottom).  I feel the kids are not learning much that’s helpful when they get to a ‘real’ language.

You can add comments to the code which is kind of nice.  But, they are location specific meaning that if I added a comment near the 3rd block from the left and then added two new blocks before the 3rd one the comment is now out of place.  What I’ve found is that the kids won’t use comments.  No one likes documenting their code but because the IDE works against them they learn not to use it.

Variables are almost an afterthought in this development environment.  They are hard enough to use that it’s considered an ‘advanced’ technique?  Really!?  What programming language doesn’t make variables easy?  Another major failing in my opinion.

Now I don’t know what, exactly, I’d do differently, but I’m looking into it.  I’m looking at creating a set of Mindstorms NXT classes using Real Studio.  This might involve creating a base set of classes to allow Real Studio developers to control the robot just like the Mindstorms software.

Besides using standard REALbasic classes (and dot notation) I’d love to create a simplified interface that would be easy for beginners to accomplish some complex things.  I’ve batted the idea around of something like Mac OS X Automator.  It’s pretty linear, self documenting and graphical.  I don’t know how I’d handle loops but it has to be better than what the Mindstorms software is doing.

So I’ve done a little research and it looks like Real Studio can at least *see* the NXT using the MonkeyBread Software USB classes. Does anyone have any experience/insight in this area? I can start from scratch but I’d love to talk to someone that’s a Subject Matter Expert (SME) if I could.

For what it’s worth, there is a very old project that connected to the older RCX but not the newer NXT. Unfortunately, it was written using encrypted modules so it’s not possible to review and update the code for the NXT.

So if you have any experience in this area, please contact me and we’ll collaborate if possible.

5 thoughts on “Thoughts On Lego Mindstorms Programming

  1. Good Idea. I was involved in FLL for a few years teaching kids also. AS a programmer by trade…my coaching responsibility centered around helping the kids program the NXT. As a programming UI it was pretty limited. I always wondered If I could more or less “manually” take over the NXT with my own code. Thought about implementing a coordinate system… of course the robot often just isn’t as precise an instrument as one would like. Similar to “Automator” I thought that the Windows automation tool Automate has a pretty friendly interface for “beginners”. The one thing that continues to be lacking are subroutines. You can code around that limitation…but it adds a good bit of kludge to any lengthy process. Still you might look to it for UI inspiration.

    • I’d like to actually get to the point of compiling an application and downloading it to the NXT just like the Mindstorms IDE does. The specification is heavily documented so it shouldn’t be too hard. Obviously a LOT of steps to get through before getting to that point.

      Subroutines would actually be one of the things I’d love to get figured out. You can use MyBlocks using the Mindstorms software but they’re pretty kludgy in my opinion. One of the teams that won the KC region used MyBlocks extensively so you *can* do it but again, I don’t think that Subroutines should be an ‘advanced’ technique any more than variables should be advanced. They should be a natural part of the language and environment.

  2. I spent a little time working on this today and I’ve given up on connecting to the brick via USB. Real Studio doesn’t recognize it as a serial device though some of the MonkeyBread Software classes recognize it’s there.

    However, in a brilliant move of desperation (!) I wondered if Bluetooth would work better. So after pairing the NXT brick to my Mac, Real Studio *DID* indeed recognize it as a serial port and I was able to connect to it via the Serial class.

    This is where I left off after some hours of frustration. I tried sending message to the brick using a variety of means and I was unable to get a response of any kind. I would have loved to have even received an error message.

    I’ve never tried to use the Serial class with Bluetooth before. I suspect I’m missing something. Oh well, that’s what research is for, right?

    • Woohoo! Much success today! I was able to successfully query the Mindstorms NXT brick for its battery level. There were a couple of things I was doing wrong: First, I had the Serial Port settings wrong and then I was using the RB MemoryBlock incorrectly. I have never figured out the MemoryBlock class so that’s been a challenging learning experience.

      I think when all is said and done this will be a good learning experience. 🙂

  3. You should also check out Sikuli.org, talk about visual -but in a different way.

Comments are closed.