Page 1 of 2

DRAWING ROBOT NXT-G (need some help)

Posted: 09 Dec 2011, 16:08
by nxtdor04
Hi everyone!
Sup?

I'm Dor, 16.5 years old.
I would like if you would help me but first of all – I'm sorry if I have some writing or grammar mistakes (English is not my first language). :oops:
~NO SPAM~

Well:
We are talking about NXT Lego.
Basically, it's a robot that draws. Something likes that: http://us.mindstorms.lego.com/en-us/Com ... 40b7ba65cc
Without getting into the details of construction – Do you think that it possible to built something like that?
I know a little C (the programming language). I have some friends who know much better programming and they can help me but I want to program this robot by its program, the NXT program (NXT-G).
Let's say that there is a picture (like square or something) on the NXT controller screen and I want that this robot will draw or will plot this picture. What do I have to do for this? What should I do?
Is it possible to do it on the NXT program or it is too difficult and I need to give up 'cause I need to know very good C and Java?


Thanks anyway!
:?:

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 09 Dec 2011, 20:44
by spillerrec
If you can figure out how to build it, I would say go for it. The nice property of those drawing robots are that you doesn't need to do advanced programming. You can start with something simple and then gradually start doing more advanced stuff. You could do it in this order:
  • Draw horizontal and vertical lines
  • Draw lines in specific angles
  • Draw curved lines
  • Read the pixels in an image and use that to draw dots on the paper
  • Draw filled shapes, like an triangle or circle
  • Use a simple vector image to draw from
  • Take a bitmap image and convert it to a vector image, and draw that
Don't aim to be able to do everything, just take a step at a time and see how far you can get.

I'm actually planning to do the very same project once I'm done with my current project and there are many other similar projects out there, here are some examples:
I once did a very simple one myself with the RCX 4 years ago (Instructions can be found here):


Laurens Valk made one using the NXT 2.0 recently, instructions can be found in his book:


A random dot printer:


An advanced vector plotter:


Re: DRAWING ROBOT NXT-G (need some help)

Posted: 10 Dec 2011, 07:40
by nxtdor04
Hi and thanks for the response!

I'd like to make a robot which draws something that I programed it to draw it. I don't want that my robot will draws some lines or something random.
I mean, like that: http://us.mindstorms.lego.com/en-us/Com ... 40b7ba65cc
or something like the last video with the "Mona Lisa" (But more simply than how it done there because I know it's really complicated and I want to program it on the NXT - G).
And BTW, if we are speaking about this robot, how he sends a command to the NXT controller to draw the vector image of the "Mona Lisa"?

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 10 Dec 2011, 11:46
by spillerrec
The robot you are linking to, as far as I understood it, just draws a bunch of straight lines. It just draws so many of them that it looks like a fluid motion.
The video with Mona Lisa also just draws curved lines. And then it draws a whole lot of them to fill the shapes.
So if you can't figure out how to draw lines, you will never be able to make something like that.

However the question then becomes, how do you tell the NXT program which lines to draw? There are several options, and following is a list with those, with easiest options at the top:
  1. Manually input the actions directly into the program
  2. Create a text file which contains the actions, which the NXT program reads. Create this file manually
  3. Use a PC program to transform an image into actions to draw, convert this output to the text file by hand
  4. Make a PC program which converts that output to the text file automatically
  5. Make a PC program which combines these tasks: read an image, transform it into actions, create the text file, download it to the NXT and start the NXT program.
  6. Skip the file step and use BT to input the actions directly into the NXT program while it is running.
Notice that already at step 4 you need to make a PC program, which cannot be done in NXT-G. And step 3 requires you to find a program which can transform an image into drawing commands, which might not exist, requiring you to make it yourself!

Since I assume that you can't program in anything else than NXT-G, anything past step 3 would not be possible for you.
So I would say you should try to make a dot matrix printer. It takes a Black/White image, and if the pixel is black it draws a dot. Here is an example:

The difficult thing would be to create the file. However if you can figure out how to read a PBM formatted image file, it should be possible. You can see an example of a PBM file here: http://en.wikipedia.org/wiki/Netpbm_format#PBM_example
You should be able to use a Image editor like GIMP to convert an image into Black/White and save the image the result as a (plain, not raw) PBM file. (You could also use my RICcreator program, as it contains functions specifically made to convert images like this, if you want more control over the conversion.)

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 10 Dec 2011, 17:58
by nxtdor04
So what you are saying is, in fact, that I should do a dot matrix printer because it is easier.
OK, cool. I will go for it. The robot in the video looks great.
So… he used Labview (I'm not the best but I think I can handle with this program).
I didn't quit understand, you helped me a lot and you are very nice - I'd like if you continue to help me and explain to me more about programming a dot matrix printer:
Lets say that I have a pic in black and white.
What now? How do I send it to the controller and how I send a command to the controller to do a dot in every black pixel?

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 11 Dec 2011, 19:03
by spillerrec
I do not use NXT-G nor Labview myself so I can only tell you the general steps, you will have to figure out how to do it in NXT-G yourself.
You will have to create three signals which makes the bot do one of these actions:
  1. Draw a dot, move one position to the right.
  2. Do not draw a dot, but still move one position to the right.
  3. Move one position down and return all the way to the left.
Now lets say '1' is the signal to draw a dot, '0' is the signal to not draw a dot and a newline is the signal to go to next line. We can then draw a 'X' by sending these commands:

Code: Select all

10001
01010
00100
01010
10001
These commands could be stored in a file stored on the NXT, or sent with BT to the NXT. How you achieve this in NXT-G you will have to figure out yourself.

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 12 Dec 2011, 09:31
by nxtdor04
Well, thank you very much. you helped me a lot.
I understood and now I just need some help with programming this with the NXT-G.
I will wait untill someone here who knows NXT-G better would help me.

thanks again spillerrec!

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 13 Dec 2011, 03:06
by muntoo
NXT-G Only
What specifically do you need help with regarding NXT-G? IMHO, the program might be a bit too complicated for NXT-G. If you insist on solely using NXT-G, you will need a few blocks:
  • A 2D array block
  • Others I might have forgotten to mention :)
You can find some of the blocks in the Mindboards Repository.


NXT and Computer
However, if you want to do it the easier, and better way, you will need to implement the algorithm on the computer. Then, the computer will send only instructions to your NXT: Move motor forward, move it backwards, and stuff like that.

In order to send information back and forth, you will need to establish a Bluetooth connection between your computer (master) and NXT (slave). If your computer does not come with Bluetooth, you will either need to buy a "Bluetooth USB Stick" or use an alternate programming language, such as NXC (Not eXactly C).

What Spiller told you was language agnostic -- he was just giving you an algorithm. The algorithm should be executed on the computer.

Another advantage to using a computer is scalability -- if you later decide you want to use more complex algorithms, you can easily recode your computer program; NXT-G is bulky, and modifying it would be a huge pain. If you are lucky, you might even find an existing library on the internet that already implements such an algorithm.



If you need any more help, please state specifically what area you need help on, which method you have decided to use, and your choice programming language(s).

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 13 Dec 2011, 05:56
by nxtdor04
Hi!

I think i would do the DOT MATRIX robot. It's seems like it would be more easy so... I'll go for it.

Well:
I'm good at
1.NXT-g
2.robolab
3.labview
and a little C.
I'd rather to programming the robot with languages ​​that I know better (nxtg. robolab. labview)
I would prefer not to use C because i think it's only going to get difficult, don't you think?

I just need help in how to program the part where the robot starts to draw the pic (or in other words, the part of sending the image to the controller and start drawing) and the part when the robot stops to draw because the image is done.
I don't even know from where to start and I would really be happy if I'll get some help



EDIT:
Oh, and BTW, where is the program which was on the vid of the dot matrix robot? I saw the name - lego printer.vi (vi it's labview) but i didn't fint it.

Re: DRAWING ROBOT NXT-G (need some help)

Posted: 16 Dec 2011, 13:54
by nxtdor04
Help someone? :oops: