Slashdot Mirror


Fun with LEGO Mindstorms Programming

rhempel wrote to us about an interesting LEGO Mindstorms programming tool he's created called pbForth. Click below to learn more about it - but let's talk about Mindstorms programming in general. What else is everyone using? What's the coolest thing you've done with them?

I've developed pbForth, a port of a rather archaic programming language, for the LEGO Mindstorms brick. The cool thing about it is that with a dumb terminal emulator that does ASCII uploads and can handle XMODEM (checksum) transfers, you can compile applications right on the brick! Yes, on the brick! When you are done, you blast S records back to your PC using XMODEM and then you can reload the app anytime using one of the standard firmware uploaders.

Check out pbForth for LEGO Mindstorms

pbForth got a whole chapter in the O'Reilly book, and it is getting more and more momentum as replacement firmware that busts the 32 variable barrier, and allows total cross-platform development without screwing around with building ecgs.

OK, I'm biased - I wrote it - but I think it's cool. Maybe some of you LEGO gearheads out there would like to try programming in something other than the native tongue. Learning Forth can make you a better C programmer. No, I'm not a Forth evangelist - I write embedded systems in C all day long.

7 of 183 comments (clear)

  1. No perl by morven2 · · Score: 4

    Perl is NOT suited to embedded programming. Perl is huge. A Forth interpreter is tiny, and Forth bytecode is tiny. Forth was written for embedded systems.

    Perl is best suited to larger systems, as a good method of tying together the extensive resources available on such a machine. It's just not suited to a tiny system.

  2. WebCam mount, NQC, legOS by Fastolfe · · Score: 5

    Firstly, legOS is a really cool project. They've totally re-written the firmware for the RCX and built a fully pre-emptive multitasking environment running programs you can write in C or C++ and compile with a gcc cross-compiler. Very cool stuff, though the networking support (IR) doesn't seem very usable just yet.

    NQC uses the standard firmware I believe, and is a bit more solidified. You write programs in a pseudo-C language and compile/upload it using the NQC utility. It also has some good IR message passing abilities.

    Information about both of these can be found at LUGNET in the robotics section.

    I experimented with LegOS a while back but ended up using NQC and a bunch of server-side Perl to build myself a telerobotic camera mount for my webcam.

    There are definitely tools available out there for some extremely flexible Mindstorms programming.

    1. Re:WebCam mount, NQC, legOS by Hrunting · · Score: 4

      I live in the same apartment as this webcam and actually built the camera-holding assembly. Being the humble dood that Fastolfe is, he fails to go on about some of the actual features in this webcam.

      The assembly is built solely from the parts that I received in my Mindstorms kit a year ago (no add-ons, no extra sets). One motor runs the manages the rotation in the horizontal direction (spin) and the other manages rotation in the vertical direction (tilt). The whole thing sits about 8 inches high and the RCX unit does not form part of the base (we have it slightly separated since the IR signal comes from another computer across the room).

      The program keeps track of spin and tilt so that users can't spin it all the way around (tangling up the cord in the process) nor can they tilt more than 90 degrees in any one direction. The program also allows a certain point to 'marked' as the initial starting point for the tracking, and there's a handy reset feature (not available outside the internal network). He also wrote the telecam daemon that resides on my Linux box that handles the actual control of the webcam (the web stuff is on a different server).

      Streaming is handled by (*gasp*) a Windows program, Webcam32, that actually came with the Java code necessary to the streaming. It was a nice little package. Fastolfe is currently in the process of writing his own program for Linux that will use bttv or something similar to do the same thing, but for right now, it's working pretty dandy.

      Setting this thing up isn't very difficult. Of course, with the post to Slashdot, it's getting hit pretty hard, but the great thing is, that we've gotten more feedback about potential problems (as Fastolfe said, "Finally, someone who knows how to open their Java console") in the past five minutes than we've received since we put the thing up.

  3. Re:Give your old bricks new life by giberti · · Score: 4

    As with any great toy, there are limitations, but here is the low down for thoes who dont know about this little toy yet...

    Out of the box its a PLC type system with three in's and three out's... It comes with two motors, two on/off "touch" sensors and one ir sensor... It also has (but not talked about) its own built in IR sensor which it can use but requires using some slightly more advanced programming languages than the one included.

    There are all types of Visual Basic programs available, but thats all I have seen so far. The lego site talks briefly about it I belive.

    There are also add ons available for it... a heat sensor, a rotational sensor and of course more motors.

    The toy is pretty nice, but really requires some patience engineering the remaining bricks to do what you want, and as always, if you dont have some legos already, you will want to go and get a few kits, because you will be limited despite the large quantity of bricks included.

    Hope this helps clear some stuff up.

    --

    AF-Design, web development.
  4. PRC by miahrogers · · Score: 5

    I was in the Penninsula Robotics Competition here in south eastern Virginia. We(my school's team) had to build a robot that would drive around a rectangular course and collect small white wiffle balls.

    Programming for the Mindstorms robots isn't very hard. However there are many other problems with them.

    For one you are only allowed to have three engines on a given mindstorms robot. I guess i should more accuratly say that you are only given 3 power terminals to plug your engines into, you may plug in more than three engines, but then two of them must go in the same direction.

    Another problem with the mindstorms robots is that they don't allow much room for a "smart" robot, as you are only given 3 sensors (like the engines above you can plug in more than three sensors but then two of them must respond to the same stimulus).

    Also the strength of legos in general is much worse when you try to put legos and a moving vehicle into one. Your building style will have to be entirely reformed if you plan on keeping your mindstorm alive for more than 10 minutes. The technic legos help with this a little, because they are longer and contain those neat axle shafts which we used liberally. But overall if you decide to change anything on the robot it will have to be entirely rebuilt for strengh/durability reasons.

    The last major problem with mindstorms robots is that they cost way too much. For a kit including three engines, a bunch of legos, and one cpu unit(basically the bare minimum you can get by on if you want a robot that moves), it was > 500$.

  5. Mindstorms™ is sort of limiting by Ptolemy+Too · · Score: 4
    I have a bit of a bias, here: as a programmer and a homeschooling dad, I've long wanted to write a good Intro To Programming book. I thought Mindstorms(TM) might be a good medium for that. But it's not: Doing anything with Mindstorms(TM) is as much (or more!) mechanical engineering as programming.

    At first I thought, oh, that's OK. That still involves problem solving and working with constraints, yes?

    But what constraints! Forget any notion of building Rodney Brooks-like robots: You get three sensor inputs. Even if you were willing to spring for lots of extra-cost sensors, and used some clever multiplexing schemes, you'd be hard pressed to build an insect that could even know whether its legs were up or down, forward or back.

    And seemingly simple robots have a way of using up the parts that come in the standard set. Once you've built a track following robot, what do you do with it? You've used up both motors. Similarly, once you've built an arm that can raise/lower open/close its claw, you've used both motors, both touch sensors, and most of the gears and structural pieces.

    I'm afraid that I lost interest pretty quickly.

  6. I really hope someone will moderate this up. by GoRK · · Score: 4

    Here's a related topic to this whole Mindstorm business. I have a system that LEGO designed way way before the Mindstorms and even MIT's LEGO brick (which became the basis of the Mindstorms) called LEGO Technic TC. It consisted of a very simple 8-bit ISA card that connected to a black box with a ribbon cable. Basically it was a relay control card. The thing had 6 "output ports" that could either drive a motor forward and backward or operate a light. It also had two input ports for 1-bit touch sensors or optical sensors (or any other 1-bit sensor you could build for that matter).

    The whole system was programmed in a LOGO (Remember that one, geeks?) environment called LEGO TC LOGO. It ran under DOS. I have been unable to find any control programs for this thing except for the stupid worthless DOS based LOGO.

    Is anyone else still using this system? Is there anything for it under Linux?

    ~GoRK