Fluke Functions

From IPRE Wiki
Jump to: navigation, search


The dongle supports 3 different user-defined windows in addition to the raw image area (takePicture()). The windows are defined with the SET_WINDOW command code followed by which window you are defining (0-2) and then the window itself (X_LOW, Y_LOW, X_HIGH, Y_HIGH). The last two parameters are the step sizes (X_STEP, Y_STEP) which allows you to skip columns and rows respectively.

One use of windowing is to get small parts of the raw image. For example, configuring the window with (window=0, xlow=0, ylow=0, xhigh=84, yhigh=191, xstep=1, ystep=1) sets the first window to the left 1/3 of the image. You can then use GET_WINDOW 0 to retrieve this image. Since the actual data is in the form (YUYVYU ...) care must be taken when interpreting the window data since you may start with a Y, U, or V pixel. A simple rule of thumb is that the current image routines should work as long as you start on the same kind of pixel every time, so make sure your xlow is evenly divisible by 4.

Another use of windowing allows you to discard the color parts of the image (U/V) and just get the gray scale image (Y). This mode works by using the step size to skip the U/V pixels. For instance, to get a gray scale image you configure the first window with the following parameters (window=1, xlow=1, ylow=0, xhigh=255, yhigh=191, xstep=2, ystep=2)

Finally, not only can you get each pixel of a window, but you can also get the sum of the pixels. This might be useful for finding the average colors or intensities in some window of the image. By issuing the GET_WINDOW_LIGHT followed by the window you will get a two byte value that is the sum of all the pixels in the window.

You can only have 3 windows configured at one time, but the windows can be changed as often as desired. So you can setup a window for a grayscale image and use the other two to split the screen into two columns. Or you can just swap back and forth by configuring before every image grab.

Blob Image

The camera can also perform on-board color segmentation. For instance, you can use this to find an orange ball in an image. You give the camera a U/V bounding box of the colors of the ball, and it classifies pixels as either ball or not-ball. The dongle then returns a run-length encoded (RLE) image (e.g. 5 ball, 15 non-ball, 32 ball ...). The RLE data sent over bluetooth is much smaller than the raw image data.

The segmentation routine is given a smoothing threshold, which smooths out noise. For instance, if you set the threshold to 3, a one or two pixel change won't throw off the RLE.

You configure the RLE by sending the SET_RLE command followed by 8 parameters. The first should always be 90 (this is for internal development) the second is the smoothing threshold. The next two parameters will be used to bound the Y dimension (but is currently not used). The next parameters bound the U dimensions (U-low and U-high). Finally, the last two bound the V dimension (V-low and V-high).

You then send the GET_RLE command to retrieve the RLE image.

In MYRO, the configureBlob function call can be used to set the YUV histogram programtically. You can also use the mouse to select a rectangle form an image in a window and Myro will use the average values of the pixels to call the configureBlob() function. Directions: Take a picture and use the show() function to show it. Click and hold the mouse at the top left corner of the group of pixels you want to select. Then drag the mouse to the bottom right corner and release. The status bar at the bottom of the image will show the configureBlob() function call that was made.

Camera Paramters

The camera is very configurable, allowing a wide variety of modes. It can be configured over the bluetooth by reading and writing to its configuration registers. For instance, disabling automatic color balance, exposure gain, etc. There are functions in scribbler.py to enable and disable common features.

IR sensors

There are 3 IR emitters and 1 IR receiver on the dongle. The method of operation is each IR emitter is strobed when queried. The receiver counts how many times it detects the reflected light. This count is returned over the bluetooth.

The IR emitter power is configurable, and often needs to be tweaked for each device. Values of around 135 seem to work well. You use the SET_DONGLE_IR to configure this value. If the value is too low the light will not relect at all and you will get 0, but if it is too high it will reflect off of everything and always return high values. The key is to find the sweet spot in between (normally between 125 and 145).

Adjustable LED

The adjustable LED can be set with values in the range 0 - 255, but is only visible at values around 150-255. With 255 being ridiculously bright.

Dongle Name

Each dongle has a unique serial number printed on a label at the top. The name of the device with be IPRE12XXXX where 12XXXX is the serial number.

Serial Memory

There is a large serial memory that can be accessed over bluetooth. The memory is organized by pages (512 of them). Each page is 264 bytes. To read a page you issue the GET_SERIAL_MEM command followed by the page and the offset. To write to the memory you issue the SET_SERIAL_MEM command followed by the page, the offset, and then the value. You can also erase pages at a time by issueing the SET_SERIAL_ERASE command followed by the page to be erased.

Scribbler Voltage Sensing

The scribbler provides power to the dongle over pin 8. We use a analog-to-digital convert to sense the scribbler's voltage. You can use the GET_BATTERY to retrieve the voltage of the scribbler. This value will range from 0 - 255, to convert to the actual voltage divide that number by 20.9813.

Scribbler Orientation

By default the dongle swaps forward/backward on the robot so the camera is facing forward. This can be overridden by sending the SET_FORWARDNESS command, followed by 0, which returns forward/backward to the scribbler's normal configuration. SET_FORWARDNESS 1 swaps the orientation so the camera is facing forward.

Scribbler Programming

The dongle can reprogram the scribblers firmware. This is done first by transferring the basic stamp bytecodes to the dongle over bluetooth. You use the SET_SCRIB_PROGRAM followed by an offset address, and then the actual byte code. For example, (SET_SCRIB_PROGRAM 0 first-byte), (SET_SCRIB_PROGRAM 1 second-byte) ... Once you have uploaded all the bytecodes you use the SET_START_PROGRAM command code, followed by the size of the program. The dongle will then program the scribbler. If you use SET_START_PROGRAM with a size of zero, the default scribbler program on the dongle will be used. Although this program is already obsolete ;-)