On 29 Aug 2009, at 17:48, Sam wrote:

> Hi I am new to FLTK and to programming in general.

How new to programming? If *very* new, then the ideas I'm about to  
pitch might be too abstract to make sense to you - in which case, sorry!


> I am working on a robot that is using two Laser range finders.

Sounds cool...

> I have constructed it in a way that they give me a 2 dimensional  
> array filled with distance values.  I want to have this  
> continuously upgrading 2-d array made into a color image.  The  
> cells of the matrix are distance values from the scanners, in a  
> Cartesian plane.  The pixel colors would be a threshold value of  
> the distance values.  So for example distances from 0 to 100cm  
> would show up as an increasing intensity of the color blue,  
> distances from 50 to 150cm would show up as an increasing intensity  
> of the color green, and distances from 100 to 200cm would show up  
> as increasing intensity of the color red.  So it is basically like  
> a video feed from the two laser scanners.

OK, first I'd decide how many distinct ranges I thought I could  
resolve, and then generate an array that would be a lookup table that  
would be indexed by range.

So, if we thought we could resolve to 1cm accuracy over the 0 - 200cm  
range, the table would have 200 entries. Each entry would be filled  
in with the appropriate colour value as RGB (say, or possible  
indexed...)

I'd then derive the display from something simple, like a box, and  
attach an Fl_RGB_Image or similar to that, and create another array  
to use for the 2-D image.
How big would this be? I guess not very, as the azimuth resolution of  
your sensor maybe isn't hat great? Lets guess it's 512x512.
This array becomes the image data for the Image widget, and each time  
you scan your sensor you update that array (mapping ranges to colours  
then placing the colours in the image array) and call redraw on the  
image widget.

Bingo, job done.

Well, OK, might be a little harder than that in practice... This  
HowTo might give you some ideas to get started with though:

http://www.fltk.org/articles.php?L468

-- 
Ian



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to