How To: Display Images on Your NXT using RobotC (JPEG, PNG, etc.)

18 02 2012

First of all, let me say that people have found various ways to do this, and that this might not be the easiest way. A big benefit, though, is that the image data you end up getting is very easily accessible and manipulable. Also, this works with *a lot* of image formats, including JPEG, JPG, PNG, BMP, and others. Anyhow, let’s get started, shall we?

What you need

  • A MindStorms NXT intelligent brick
  • RobotC
  • Paint.NET, a free image creation/ editing software which you’re going to use to create your image, with this plugin [LINK] installed. Don’t know how to install Paint.NET plugins? Refer to this page here [LINK].

Step 1: Creating or Importing your image

For creating your own image: open Paint.NET, click the “Image” menu, and then open the “Canvas size…” option. In the wizard, specify any image size, up to 100 pixels wide and 64 pixels high. Then use the pencil or any of the other tools to create your image.

For importing an image: open Paint.NET, click “open,” navigate to the desired image, and double click it. Then, go to the “Image” menu, open the “Image size…” option, and, in the wizard, specify any image size, up to 100 pixels wide and 65 pixels high.

Step 2: Making your image black and white

First, open the “Adjustments” menu and click “Black and White.” Then, again in the “Adjustments” menu, open “Brightness/ Contrast,” and, in the wizard that pops up, set the contrast to 100.

You can play around with the brightness to change how dark a color needs to be to become black, and how light a color needs to be to end up white. Once you’re satisfied with your results, hit the “OK” button and your image is ready for the next step.

Step 3: Saving your image

Open the “File” menu and click “Save as…”. You can save your image under any name, anywhere, as long as you make sure you select “Portable Bit Map Files (*.pbm)” from the “Save as Type” drop down menu. If this option is not available, you didn’t install the plugin right, so re-install it and try again. Click image to enlarge.

Step 4: Reformatting your image’s code

Next up, you need to turn the image you just created into something the NXT can actually use. Go to the folder you saved your image in, right click the picture, and hit “Edit with Notepad++”. In the code you end up with, remove everything before the 1′s and 0′s (usually the top two lines).

Then, hit ctrl and f on your keyboard to open the “Find” wizard. The next steps are very important, so pay close attention:

  1. In the wizard, go to the second tab, which should say “Replace”
  2. In the “find what” box, type ” ” [hit the space bar once], and in the “Replace with” box, type nothing. Hit “Replace all.”
  3. In the “find what” box, type “1″, and in the “Replace with” box, type “1,”. Hit “Replace all.”
  4. In the “find what” box, type “0″, and in the “Replace with” box, type “0,”. Hit “Replace all.”
  5. Finally, turn the code into a single line by going to the end of every line of code and hitting delete

Step 5: Displaying the image on your NXT

First of all, copy this code into your program somewhere:

int i, j;
int image[HEIGHT][WIDTH] = {PUT 1'S AND 0'S HERE};
for(i=0; i<HEIGHT; i++){
  for(j=0; j<WIDTH; j++){
    if(image[i][j] == 0){
      nxtSetPixel(j,-i+HEIGHT-1);
    }
  }
}

Replace “WIDTH” with the width of your image, “HEIGHT” with the height of your image, and “PUT 1′S AND 0′S HERE” with your image code (copy and paste it between the curly brackets).

And there you have it: you can now display any image you want on your NXT screen using RobotC and some freeware :)





The Fin Ray Effect® – for LEGO?

21 06 2011

Like my last  Festo-based project Bionic NXTPod 3.0, my next project will use the Fin Ray Effect® (see bottom of page). Since it’s kind of difficult to find out what exactly the Fin Ray Effect® is online, I’ve tried to scramble together as much information as possible online to get a good understanding of it, and how it might work with LEGO MindStorms, Technic and pneumatic pieces (quite a mouthful:)). In the end, I hope to use this information to create a fast color sorter for LEGO balls or small bricks.

The Basics

The Fin Ray Effect® is based on the basic principle of how fish’s, especially rays’, fins work. In other words, “the Fin Ray Effect® is a design based on the functional anatomy of a fish’s fin”. A part using the Fin Ray Effect® is made up of two struts or rods, which are joined at their tips forming an acute triangle. It can also be done using three, four or six rods, to add the third dimension, like in the Bionic Tripod (the same goes for versions 3.0 and 2.0). Oftentimes, there are also supports in between the rods to keep them apart and make the structure steadier and more flexible.

The following image cannot be displayed: Fin Ray Effect StructureBasic structure of the Fin Ray effect®. Image source

To move the structure, you simply move the ends of the rods up or down, and the movement gets translated into a smooth circular sideways motion.

The following image cannot be displayed: Fin Ray Effect MovementTwo lineal forces applied to the rods make the end curve sideways. Image source

Applications of the Fin Ray Effect®

Festo has already used the Fin Ray Effect for several robots in their Bionic Learning Network. They include:

The Bionic Tripod series

Underwater robots

Airborne robots

Miscellaneous

The last one I found out about is Festo’s bionic material sorting gate, a colored ball sorter using the Fin Ray Effect®, which is going to be the inspiration for my next project. The goal is to go for at least 50 successful sorts per minute (the Festo one does 3 per second). The above websites were also the sources I used for writing up most of the rest of this article.

Connecting with LEGO

To recreate the Fin Ray Effect® in LEGO, you would need to find LEGO pieces to replace all of the following:

  • Two actuators
  • The support beams
  • The struts/ rods

For the actuators, there are a few possibilities. The “best” option would be to use Firgelli linear actuators (L12NXT), to control how far the actuators move. The problem is the price tag: they’re currently sold for 55 USD each. The next option would be the LEGO ones, but since those are mostly controlled with power functions, they wouldn’t be too precise. They’d be very big and clumpy with a NXT servo attached.

The following image cannot be displayed: Firgelli's Mindstorms Linear Actuator (L12NXT)Firgelli’s Mindstorms based linear actuator. Image source

Stepping away from motorized/ electric actuators, next would be pneumatics. They’ve got quite some advantages: speed (if they’re modified), as much strength as you pump into it, and they’re relatively cheap. The only problem is that they’re not directly controllable from the NXT, and virtually impossible to keep or even get to a specific place using LEGO alone. The only options would be open or closed.

The following image cannot be displayed: Bionic NXTPod 3.0's actuators initial designSimple NXT servo motor based linear actuator; better version here

As a last resort, you could build your own linear actuators, like I did. It isn’t going to be very compact and probably not as strong as a “real” one, but it’s the cheapest option by far (given that you have a NXT :))

The connection beams aren’t much of a problem either. You could just use regular rounded technic beams. They’d have to become smaller towards the end, though. It’d also be best if they went down in size gradually, so don’t use something like 11, 11, 9, 9, 7, 7, etc. because that’d compromise the flexibility. Something like 11, 9, 7, 5, etc. would work much better.

It’s also important to make the supports slightly turnable, so the beams don’t always have to be at a 90° angle from the struts. Remember the support beams are only there to keep the rods apart, not make them immovable.

Most difficult to figure out are the struts; there are pretty much only two options available. The first are the hollow hoses found in some Technic sets, usually in silver or black. These are very hard to get, so aren’t really usable for bigger constructions.

A yellow soft axle hose; usually seen in black. image source

The other ones are very good though. They’re thin, you can connect them using a simple pin in between, and they’re flexible but try to get back to their original position as much as they can. And you can get them for less than half a dollar each, over here! The problem is that these soft axle hoses aren’t very strong by themselves, so it’s a good idea to use two of them in parallel.

So there you have it: using the Fin Ray Effect® in LEGO is possible, and, with the right materials, can provide an interesting new way of building robotic arms and such.

Fin Ray Effect® is a trademark/brand of EvoLogics Gmb





HiTechnic Experimenter’s kit I2C output addresses

2 05 2011

I couldn’t find all of these addresses anywhere, so I tested them to see what pins (B0 – B5) they’d turn on. A white box means that that address is turned on, and a black box means it’s off. Thanks to Xander and bullestock for helping me complete this list:

The following image cannot be displayed: I2C output addresses on HiTechnic Experimenters Kit





NXTstep Bluetooth Dongle Resource

23 01 2011

The NXT STEP has published a resource to find good, NXT-compatible Bluetooth dongles. Everyone can add to this list by leaving a comment at the post including the following (copied from original post):

  1. Brand/Name of Dongle
  2. Price
  3. Where to get (web link, or store name etc)
  4. Confirmed compatible operating systems
  5. Notes (if applicable)

Don’t wait; click here to go to the official post (and comment), or click here to visit the NXT STEP blog.





Advanced Mindstorms Sensors and Add-ons

15 10 2010

Ever wondered where to get extra Mindstorms sensors and add-ons? This is my top three:

  1. Mindsensors provides multiplexers, actuators. Furthermore, Mindsensors created a lot of advanced sensors, including the NXTCam-v3, psp controller connections, high precision infrared distance sensors, pneumatic pressure sensors, acceleration sensors, etc.
  2. HiTechnic provides some multiplexers, special accessories, and experimenter’s kits. They have angle sensors, acceleration/ tilt sensors, IRLinks and receivers, and magnetic sensors. Furthermore, HiTechnic provides building and programming instructions to help you get started with their products.
  3. Dexter Industries is a bit smaller than the above, but provides thermometers, (light) switches, and the dFlex, a sensor that measures how much it’s bent.
  4. Firgelli sells NXT-compatible linear actuators







Follow

Get every new post delivered to your Inbox.

Join 34 other followers