Andrew Coates ::: MSFT

It's all about community!

January, 2010

  • Andrew Coates ::: MSFT

    Lego Mindstorms NXT2.0 - TrophyBot


    Lego Mindstorms NXT2.0 Box

    For some time now, I've coveted the Lego Mindstorms NXT 2.0 Robotics kit. It's a great teaching toy tool and not only can you program it with the excellent and intuitive Lego IDE (from LabView), but you can also use Microsoft Robotics Studio and .NET.

    With that justification, just before Christmas I ordered one from the local online Lego Specialist, BrickNet and immediately got an email from them saying they'd shipped it. As soon as I got back to work after New Year, it was waiting on my desk. Awesome!

    Lego Mindstorms NXT2.0 Contents

    There are over 600 pieces in the box ranging from the main brick (the NXT Controller) that's the brains of any robot you build, the motors cables and sensors that are the brawn and nervous system:

    NXT2.0 COntroller Motors, cables and sensors

    The traditional Lego Technics bits and the test pad are accompanied by a CDROM and instruction manual

    Lego Bits Test Pad 

    Of course, when they arrive, they're all packed in the box like this:

    Original packing configuration

    Having built Technics kits before, I know how important it is to be able to find that tiny piece without which the whole thing just won't work, so the first thing I did was go down to the local supermarket and buy a heap of plastic sealable containers in various sizes and spend the next 90 minutes or so sorting bits into boxes. Yes, I know there's a name for my condition and thanks, the therapy is proceeding apace. In the end, it looked like this:

    Reboxed and ready to start

    So the question was, of course, what to build first. Some of you may have caught the news that Catherine Eibner was recently awarded the Microsoft Diversity Campion Women Build Award for 2009. Of course, the trophy she got was all lego (as were the dozen or so "mini-me" lego people that went along with it.

    Mini-ceibnerMini-ceibner from behind

    Catherine's Trophy

    Sadly, not everyone in the subsidiary reads Catherine's blog, and so they might not have found out about this important award being presented to someone so close to them.

    What better way to solve that problem than to have a robot take them the news. Enter TrophyBot:

    TrophyBot front view

    TrophyBot is an extension of the first tutorial robot that ships with the Mindstorms kit. The driving base consists of 2 motors to propel the tracks and the NXT controller. A third motor is built in to the centre of the body to provide for later upgrades.

    Building the base is pretty straight forward, the detailed step-by-step instructions are available in the printed manual or as part of the NXT software that comes in the kit.

    instructions screenshot

    In addition to the driving base (shown in the top-left of the screenshot above), I added a platform for the trophy to stand on, a bump sensor to work out when the robot hits things and an ultrasonic sensor to detect things that are further away.

     TrophyBot right side TrophyBot rear view TrophyBot left side

    In a subsequent post I'll show how easy it is to program TrophyBot, to respond to events and to interact with the environment.

  • Andrew Coates ::: MSFT

    NXT2.0 Robot - The Journey Continues


    In my previous post, I talked about getting a new Lego Mindstorms NXT 2.0 robotics kit and about building TrophyBot to carry around a Lego trophy Catherine Eibner won for being an awesome evangelist. In this post, as promised, I'll talk about how I programmed the robot to move around, shouting "HORRAY!" whenever it bumped into anything.

    The Lego Mindstorms NXT software is a really nice piece of work. It's a Flash player preloaded with the always excellent step-by-step instructions for building four very cool robots, a vehicle (ShooterBot), an animal (Robogator), a machine (Color Sorter) and a humanoid (Alpha Rex). Lego instructions are exceptionally thorough, which means that even a novice can construct a working robot in fairly short order.

    Step-by-step instrcutions

    Aside: I've been thinking a bit about the corollary between these step-by-step logo instructions and how I started programming, which was copying 100 or so lines of code out of a magazine to do <insert inane or mundane thing here>. Having something to copy meant that I had a base to experiment from, to draw conclusions about and to formulate patterns around. I could generalise and improvise. This fed my curiosity far more than I see my childrens' being fed by the current "download 1000 lines and a couple of libraries from the internet". I think that actually typing in the code and fixing the inevitable typos gave me more insight. I've noticed this trait in my kids though when they build Lego. The instructions are very clear, but they have to execute every one of them to make the robot (or what ever they're building) work. They're much more familiar with it than if I'd built it for them and said "have a look at this and see how it works". My gut feel (completely devoid of any science) is that their curiosity is awakened by the feeling of ownership and achievement that comes with building it themselves.

    I used the first section of Shooterbot - the driving base - for Trophybot

    Shooterbot Driving Base

    To this I needed to add a bump sensor (so Trophybot could detect and move away from obstacles) and a platform to hold the trophy.


    Trophybot platform Trophybot bump sensor 

    Ignore the ultrasonic sensor (that looks like a pair of eyes), it's not used at this stage.

    The next step was to actually make Trophybot do something. First, I had to connect the NXT to the computer. There are a couple of ways to do this, either tether via USB or connect via Bluetooth. the instructions for both are pretty straightforward, so I did both.

    Now it was time to write the first bit of code. In fact, using the NXT software, it's actually a matter of assembling and wiring together programming blocks. Initially, I just wanted Trophybot to go forwards and I'd manually pick it up and turn it off.

    I created a new program called, originally enough, "Go Forward" and was presented with a blank canvas:

    Starting a new mindstorms program

    I grabbed the Move block from the top of the toolbar and dropped it where it says "Start". When the new block's selected, a properties pane appears at the bottom of the screen to let you set properties for that block. I set the duration property to Unlimited and hit the download button.

    Go forward - first draft

    I pressed the orange button on the NXT brick 4 times to run the program I'd just downloaded and nothing happened - hmm.

    OK - maybe the environment's smart enough not to get into an infinite loop, so I added some logic - what I thought might be a sensible way to represent an event (in this case, the sensor getting pressed). I chose the complete palette in the blocks toolbox and dropped a touch sensor on the canvas. I didn't connect it to anything because I figured this would be an event that happened and broke into whatever was going on at the time.

    Sensor event?

    The sensor block stayed greyed-out, which I guessed meant that it wouldn't be used. More work needed.

    Next I tried putting all the logic in a loop that polled the state of the sensor each iteration and then took the appropriate action.

    Move and check in a loop

    This says:

      If sensor not pressed or bumped 
        Go forward 1 second
        Go back 1 revolution
        Turn right 1 revolution
    End Loop

    Which at least made the robot move but it had two drawbacks:

    1. It moved forward in 1 second jerks followed by a small break; and
    2. It didn't react to a bump or press until the second of forward motion was done.

    Interestingly, the way to fix this is to make the motion in the top part of the loop unlimited instead of making it a specific duration. The unlimited move block is a special case that actually means keep moving until the condition at the start of the loop changes. It also doesn't work outside a loop (which is why my first, single block, program failed) because it "falls through immediately to the next step.

    Finally, I added some randomness to the program that meant that the robot turns in a random direction and a random number of degrees when it hits something. This seems to give it more of a chance to get out of corners and away from complex obstacles. I also added a play sound block to make the bot say "Horray!" whenever it bumped into something.

    The final program looks like this:

    TrophyBot final program

    All-in-all, this was a really fun start to what's going to be a much longer term project. I've managed to acquire a Lego Technics truck that is ripe for roboticising and I'm looking forward to having a play with the .NET programming environment provided by Microsoft Robotics Studio.

    I'll keep you in the (infinite) loop.


  • Andrew Coates ::: MSFT

    Windows Azure User Group Briefings


    Dave Lemphers comin' atchya

    The one and only Dave Lemphers is coming back to Australia for a week at the end of February for a whirlwind tour of the country to coincide with the launch in Australia of Windows Azure. He'll be doing public technical briefings hosted by the user groups in 5 capital cities.

    Date/Time City Details
    Mon 22 Feb 12:00-13:30 Adelaide Microsoft Innovation Centre
    Level 2, Westpac House
    91 King William Street Adelaide SA 5000
    Register Here
    Tue 23 Feb 18:00-20:30 Melbourne Microsoft Theatre
    Level 5, 4 Freshwater Place,
    Southbank, VIC
    Wed 24 Feb 12:00-13:00 Brisbane Microsoft Theatres
    Level 9, Waterfront Place
    1 Eagle Street
    Thu 25 Feb 12:00-13:00 Canberra Microsoft Theatre
    Level 2, Walter Turnbull Building,
    44 Sydney Avenue,
    Barton, ACT 2600
    Thu 25 Feb 18:30-20:30 Sydney Microsoft Theatres
    1 Epping Rd

    If/when there are registration links for the events in the other 4 cities, I'll update them here. Otherwise, just rock up at the date/time above.

    For more details about Windows Azure in Australia, see Greg Willis' post from last month.

    Windows Azure Logo

  • Andrew Coates ::: MSFT

    Test Post from Word 2010


    I've not posted from Word 2010 before (I prefer Live Writer), but I had a question from a colleague as to how to set it up. If this appears, it looks like I managed.

Page 1 of 1 (4 items)