Monday, September 11, 2006

Norea Verhaeghe

On September 8, my beautiful daughter Norea was born. My duties as a first time father are taking up all of my time right now. Sorry to everyone whose mail I haven't answered (in fact, haven't received) yet. I'll be back in the not too distant future.

Filip.

Wednesday, September 06, 2006

My Number 1 Feature Request for NXT-G

After playing around with NXT-G for some time now, I have grown to like it. It is very powerful, but sometimes you need to be able to go just a little bit deeper. Those are the times when development languages like NXT Byte Code (NBC) is really useful. Unfortunately, you cannot use NBC code from within NXT-G.

So my #1 feature request for NXT-G would be:
  • a NXT-G block that allows you to embed NBC code (best way because it brings the code right into the NXT-G environment), OR
  • a NXT-G block that allows you to issue so-called "direct commands" to the firmware (as specified by the NXT SDK), OR
  • a NXT-G block that allows you to run an external program.
In all cases, there should be some way to pass parameters to the block or to the external program.

With that feature, one can build almost any other brick without using LabVIEW. For instance, building custom blocks that support custom sensors would be extremely easy. So my requested block is a block with which I can build any other block.

But perhaps you'd like something else. What is your most wanted NXT-G update?

Wait For Ultrasonic And Touch Sensor

Everyone in my family just loves to play with LEGO MINDSTORMS NXT (yep, I have taken it to family meetings). But I noticed that my nephew Mathijs, who is 14 years old, struggles with using two sensors at the same time.

In particular, using both the ultrasonic sensor to detect obstacles, and the touch sensor to act like a bumper, proves to be pretty challenging. Frankly, this is a piece of code I have debugged for myself also multiple times, so I decided to create a My Brick that captures this functionality, and make it available as a download.

BRICK DESCRIPTION

(download link near bottom)

What the “Wait For Ultrasonic And Touch Sensor” brick does

 The sensor will wait until either the Ultrasonic sensor has detected the selected range, or until the touch sensor is pushed. It will return the value 1 if the Ultrasonic sensor has detected the selected range, it will return the value 2 if the touch sensor was pushed, and it will return 3 if both events happened together.

Configuring the brick

  • You need to provide the ports to which the touch sensor and the ultrasonic sensor are connected.
  • For the ultrasonic connector, you must also specify the trigger point. This is the distance that the ultrasonic sensor is responding to.
  • If you want the ultrasonic to trigger when it comes too close to an obstacle, check the "Trigger If Closer Than Trigger Point" box. When this box is unchecked, the ultrasonic sensor will fire when there is no obstacle between the robot and the trigger point distance.

Sample Application

In this sample application, the robot has an ultrasonic sensor at the front, and a bumper at the back.



This application will drive forward until the ultrasonic sensor detects an obstacle closer than 30 cm. When that happens, it will drive backward and turn until the obstacle is further than 50 cm, or until it bumps into something with the rear bumper. Then it will start to drive forward again.

With this simple program, the robot can navigate the room and avoid obstacles and walls.

Sample Application 2

In this second sample application, we'll make things a little bit more complicated. This time, the bumper and the ultrasonic sensor are both at the front of the robot. When the bumper is pushed, then some obstacle did not get properly detected by the ultrasonic sensor.

We want the robot to drive forward. When the ultrasonic sensor sees an object, then it should simply turn a number of degrees to avoid the obstacle. But if something hits the bumper, it may be blocking the robot. The robot may not be able to turn. Therefore, the robot should first drive backward, and then turn. Here's the program that does this:

sample program 2


Here's the setting of the switch (if-then) statement:

switch settings


Notice that I have set the second option as the default option. That means that if both the ultrasonic and touch sensor fire at the same time, then we will respond to the bumper and ignore the ultrasonic sensor.

Download

There are two versions for download: one expresses the trigger point in centimeters, and the other in inches.
  • Download the "Wait For Ultrasonic and Touch Sensor" brick where the trigger point is expressed in centimeters;
  • Download the version where the trigger point is expressed in inches.

Installation Instructions

  • Download the brick using the link above.
  • From within NXT-G, go to the Edit menu, and select the Manage Custom Palette submenu. A directory opens.
  • In this directory, create a directory bNXT if it does not already exist.
  • Next, copy the downloaded brick from the downloaded zip file to the bNXT directory you have just created.
  • Now close NXT-G completely.
  • When you restart NXT-G, the brick will be available in the custom bricks menu (third palette down).

How it works

The program of this brick can be seen by double clicking the brick after installation. I encourage you to do so, and perhaps make your own variations.

Tuesday, September 05, 2006

My Block Bug in NXT-G Editor

I discovered the following bug in the NXT-G editor. If I create the following program:

Buggy program


With this prorgam, I take the screen block (right block) and I turn it into a My Block. The next time I want to use this My Block from the custom palette, the NXT-G editor will crash:

Buggy program


The bug is not in the execution of the program, but in NXT-G editor itself. I (unfortunately) discovered this bug as part of a larger My Block. I was able to confirm the bug on several computers. I have not been able to find a workaround yet, suggestions are very welcome.

bNXT in Chinese

bNXT has started a blog in Chinese. I believe it is the first blog in Chinese dedicated to LEGO MINDSTORMS NXT. Jason Yu will be responsible bringing posts to that blog. You can also reach the blog via the menu above.

I can read English, Dutch and French, but I do not speak or read Chinese myself, so please don't send me emails in Chinese. You can contact Jason at jason@bnxt.com.

NXT Course Curriculum

Today, I receive this question, and I hope you can help out:

Hello, I teach Industrial Electronics. I'm not new to electronics but I am new to teaching robotics, we are starting a intro to robotics course and lab this spring, I'm super excited about that. The original equipment was going to be one industrial robotic arm and 15 lab seats of simulation software, but after searching the web it seems that alot of schools and universities are using the lego mindstorm kits. I did some research and found that it would be cheaper to have 15 of this kits than one arm and sim software. I believe the students would learn more with these hands on kits. So my question is: "Is there a Curriculum built around the NXT? (Books, Lab Manual, Software Training, Videos, etc...)"

So that you know I'm not lazy, just really busy, I teach days and nights, and I'm dedicated to my work, I even when down to Toy's R Us and bought a set of commercial NXT for myself out of my own pocket, so that maybe I could create a course, I'm sure I can get the basics, but I really want my students to have the best.

Also if there is no such course curriculum, I'll be glad to help anyway that I can with an existing group, or start a group to create one.


Please leave comments to this blog if you can help out in any way, or would like to help with a group on building an NXT curriculum.

Monday, September 04, 2006

Custom Icons for Custom NXT-G Bricks

Using the NXT-G My Block feature, you can make your own bricks (equivalent to “functions” or “procedures” in traditional programming languages). You can learn how to do that here.

Part of the process is to select an icon for your My Block. To do this, you can select from a set of predefined icons, and you can combine those icons. But if you are like me, you’ll want to create your own icons for your blocks. And although not documented or supported, LEGO has put everything in place to do just that.

Suppose you want to create a My Block like this one:

Sample brick


The first thing you will need is to create an icon. The icon must be a transparent PNG file of dimensions 32x32 pixels. Amongst others, you can use the free software Paint.NET to create this kind of images. Make sure to use a transparent background, so that you can combine the icons with other icons you create.

For this particular sensor, I made two icons: one that just reads bNXT, and another with a compass rose. Then, I placed the two icons in the directory “C:\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Icons\MyBlock”, as seen in the next image:

My Block Directory contents


The next step is rather traditional. When I now start the NXT-G software, and I create a My Block, I see my two icons in the list of icons to be used:

My Block Builder


I simply superimposed the bNXT icon over the compass rose icon, and that was it. As you might have noticed, the My Block Builder shows the content of the “C:\Program Files\LEGO Software\LEGO MINDSTORMS NXT\engine\Icons\MyBlock” directory in alphabetical order, but it only shows the first 72 icons in the directory. That’s why LEGO uses their own naming/numbering system for the icon filenames that allows them to alphabetically sort the blocks. My blocks just sort of fell in between those, bumping out the last two blocks. So make sure that when you add your own blocks, your filename is within the first 72 files, alphabetically speaking.

Lucky for us, LEGO has decided to store the icon inside the .rbt file that stores your My Block. The icon travels with the My Block, and you can freely pass along your .rbt file. While the .rbt file is on your own computer, you can still edit the icon at any time. After copying the My Block to another machine, the original PNG files are no longer available on this new machine, and the icon can no longer be edited (but the program inside the Block can be opened and changed).

PS. The movie on the Compass correcting slippage post has finally been published by YouTube. Click here to see it.

Sunday, September 03, 2006

New NXT-G Tutorials on bNXT

Last updated on September 4, 2006

I’d like bNXT to be a great place to find information about LEGO MINDSTORMS NXT, for teachers, researchers, other adults and kids alike. I realize that there is no way that I can build all of that information myself.

However, what I can do is to structure information. Whenever I find some really great content, I try to get permission to republish it on bNXT, and put it in a place where you can easily find it (with credits and links to the author). By bringing in the best content from around the world, I hope bNXT can help new users to learn a lot about their new robot set.

Recently, I came across NXT Tutorial was developed by Dale Yocum, Head Robotics Coach at Catlin Gabel School in Portland, Oregon (I believe I got the link from a NXTasy or TheNXTStep post). Watching the video’s teached me one or two things about NXT-G. For instance, I did not know how to make a MyBrick with parameters before I saw Yocum’s tutorial on it. I’ve been using parameterized MyBlocks intensely ever since.

So I’m really happy that Dale gave me permission to republish the tutorials on bNXT. You can find them in the menu above, under “Learn NXT”, and “Tutorials”. Or jump right in with this link.

Thanks Dale! I hope even more people find their way to the tutorials now.

PS. I will also publish translations of these videos, if someone would translate them to his/her own language.

UPDATE on Sept. 4, 2006: Dale tells me a Spanish version is being created, although there is still a lot of work to be done. Stay tuned!

Friday, September 01, 2006

A Request for National Instruments

There are really cool things that the community can do for LEGO MINDSTORMS NXT, now that LEGO has released the Mindstorms SDK.

One thing I am personally looking forward to, is making custom NXT-G bricks. There are all sorts of bricks that would make programming with NXT-G a lot simpler. But to make new bricks, I understand one needs LabVIEW from National Instruments.

LabVIEW is a really expensive piece of software, but there is a student version that is very reasonably priced. So my plea to National Instruments is this. When you release the LabVIEW Toolkit for LEGO MINDSTORMS NXT, could you please:
  1. Allow residential (non-academic, non-commercial) users to buy the Student Edition;
  2. Make sure that it is possible to create custom bricks using the Student Edition (i.e. it is not crippled on the functionality relevant to LEGO MINDSTORMS NXT).
Thanks!

Correcting Wheel Slippage Using the HiTechnic Compass

So, after having learned a few things on how to program using the HiTechnic compass sensor, I was itching to make the compass something really useful and really robotic.

One of the main challenges when driving robots, is to know where the robot is. One common approach is to count the number of times the wheels have turned. Then, to navigate back, just go back on your steps. You can make your robot navigate back taking the shortest route by using trigonometry. The principle described is generally referred to as odometry. But as you can guess, when the wheels slip, your calculated position is no longer accurate.

Usually, the robot doesn’t notice when a wheel is slipping. But if only one wheel is slipping, the robot while veer to the left or the right. And with the HiTechnic Compass, we can detect that.

So, the challenge I put to myself is this: build a robot that continuously corrects its heading such that it keeps driving straight even as its wheels slip.

To make testing a little easier, I decided to put different sized wheels on the robot. The robot will also veer off in a direction, and needs to compensate. The software is actually identical.

And here’s the result of the software. Notice the wheel size difference, and that changing the wheels halfway the movie requires the robot to adjust in a completely different direction.:



This was accomplished by this rather trivial piece of software:
Software to steer on compass


The basic working principle is that the difference between the compass heading and the start direction controls the steering. I multiply by 4 to increase the effect on the steering correction. And that’s it!

A few points to note:
  • I have not received a custom Compass sensor from HiTechnic yet, so for now I have built my own brick that returns the heading (0 – 359°) as one of its parameters. When the sensor from HiTechnic comes, I can simply replace the my brick with the official HiTechnic software brick.
  • The Debug brick simply puts a number on the screen, which is something I need all the time as well.
  • I’m starting to enjoy this My Brick feature. I’ll be exploring this feature more in the future.
So there it is, the first practical compass application. But off course, there is lots more that can be done using the compass. What would you do with a compass on your robot?