LegoAgent-Eve
Scanner Class Reference

Klasse feur die Scan-Funktion des Roboters Alle Interaktion mit der Hardware (außer Display) findet in dieser Klasse statt Motoren werden angesprochen und Sensoren ausgelesen Von Außen wird die Methode scanNewDataPoint angesprochen, welche einen Datenpunkt mit den benoetigten Merkmalen, aber unbestimmten Figur-Typ zurueckliefert. More...

Inheritance diagram for Scanner:
Collaboration diagram for Scanner:

Public Member Functions

 Scanner ()
 
IDataPoint scanNewDataPoint ()
 scan whole image and calculate the characteristics of the objects More...
 

Static Public Attributes

static final int resolution = 4
 
static final int yMax = 900
 
static final int xSpeed = 200
 
static final int xAcceleration = 200
 
static final int ySpeed = 500
 
static final int yAcceleration = 500
 
static final int minYAngle = 18
 
static final int minXAngle = 3
 
static final int startYDir = -1
 
static final int startXDir = -1
 
static final int sensorSamples = 5
 
static final double rgbThreshold = 0.08
 

Private Member Functions

int[][] readImage ()
 scan the whole picture. More...
 
int getPixelColor ()
 read in sensor value and filter it More...
 
int getYIndex (int i)
 calculates the y Index for the image buffer Depending on the direction the index must be calculated different because of the meander shape of scanning More...
 
void turnXMotor (int xAnglePerPixel)
 turn the XMotor about given angle More...
 
void turnYMotor (int yAnglePerPixel)
 turn the YMotor about given angle More...
 
void returnToHome (int xAnglePerPixel, int yAnglePerPixel)
 return to the origin position after scanning image More...
 
void invertDirection ()
 invert the direction flag 1 means rotate clockwise -1 means rotate counter-clockwise More...
 
String debugImage (int[][] Image)
 print Image as String as Debug String More...
 
void printImageOnLCD (int[][] image)
 prints Image on LCD display scale image to fit to the screen More...
 
IDataPoint calculateCharacteristics (int[][] image)
 calculate the characteristics perimeter (sqared) and area of a given image More...
 

Private Attributes

int pixel
 
int dir
 
RegulatedMotor XMotor
 
RegulatedMotor YMotor
 
EV3ColorSensor Sensor
 
SampleProvider RgbSample
 
SampleProvider RgbFilter
 

Detailed Description

Klasse feur die Scan-Funktion des Roboters Alle Interaktion mit der Hardware (außer Display) findet in dieser Klasse statt Motoren werden angesprochen und Sensoren ausgelesen Von Außen wird die Methode scanNewDataPoint angesprochen, welche einen Datenpunkt mit den benoetigten Merkmalen, aber unbestimmten Figur-Typ zurueckliefert.

Constructor & Destructor Documentation

Scanner ( )

References Scanner.startYDir.

Member Function Documentation

IDataPoint calculateCharacteristics ( int  image[][])
private

calculate the characteristics perimeter (sqared) and area of a given image

Parameters
imageint buffer of the image
Returns
DataPoint with the characteristics perimeter and area

References Logger.log(), and Scanner.pixel.

Referenced by Scanner.scanNewDataPoint().

Here is the call graph for this function:

Here is the caller graph for this function:

String debugImage ( int  Image[][])
private

print Image as String as Debug String

References Scanner.pixel.

Referenced by Scanner.readImage().

Here is the caller graph for this function:

int getPixelColor ( )
private

read in sensor value and filter it

Returns
0 for white 1 for black

References Logger.log(), and Scanner.sensorSamples.

Referenced by Scanner.readImage().

Here is the call graph for this function:

Here is the caller graph for this function:

int getYIndex ( int  i)
private

calculates the y Index for the image buffer Depending on the direction the index must be calculated different because of the meander shape of scanning

Parameters
icurrent position y Motor
Returns
index for the image buffer

Referenced by Scanner.readImage().

Here is the caller graph for this function:

void invertDirection ( )
private

invert the direction flag 1 means rotate clockwise -1 means rotate counter-clockwise

Referenced by Scanner.readImage().

Here is the caller graph for this function:

void printImageOnLCD ( int  image[][])
private

prints Image on LCD display scale image to fit to the screen

References Scanner.pixel.

Referenced by Scanner.readImage().

Here is the caller graph for this function:

int [][] readImage ( )
private

scan the whole picture.

This is done in a meander shape. See the following illustration (s is a scan, -> symbolize movement): s->s->s->s \/ s<-s<-s<-s \/ s->s->s->s \/ s<-s<-s<-s

This shows that for the reading of a line are one scan more is necessary than movements.

References Scanner.debugImage(), Scanner.getPixelColor(), Scanner.getYIndex(), Scanner.invertDirection(), Logger.log(), Scanner.pixel, Scanner.printImageOnLCD(), Scanner.resolution, Scanner.returnToHome(), Scanner.turnXMotor(), and Scanner.turnYMotor().

Referenced by Scanner.scanNewDataPoint().

Here is the call graph for this function:

Here is the caller graph for this function:

void returnToHome ( int  xAnglePerPixel,
int  yAnglePerPixel 
)
private

return to the origin position after scanning image

References Scanner.startYDir.

Referenced by Scanner.readImage().

Here is the caller graph for this function:

IDataPoint scanNewDataPoint ( )

scan whole image and calculate the characteristics of the objects

Implements IScanner.

References Scanner.calculateCharacteristics(), and Scanner.readImage().

Here is the call graph for this function:

void turnXMotor ( int  xAnglePerPixel)
private

turn the XMotor about given angle

Parameters
xAnglePerPixelangle to rotate

References Logger.log().

Referenced by Scanner.readImage().

Here is the call graph for this function:

Here is the caller graph for this function:

void turnYMotor ( int  yAnglePerPixel)
private

turn the YMotor about given angle

Parameters
yAnglePerPixelangle to rotate

References Logger.log().

Referenced by Scanner.readImage().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

int dir
private
final int minXAngle = 3
static
final int minYAngle = 18
static
final int resolution = 4
static

Referenced by Scanner.readImage().

SampleProvider RgbFilter
private
SampleProvider RgbSample
private
final double rgbThreshold = 0.08
static
EV3ColorSensor Sensor
private
final int sensorSamples = 5
static

Referenced by Scanner.getPixelColor().

final int startXDir = -1
static
final int startYDir = -1
static
final int xAcceleration = 200
static
RegulatedMotor XMotor
private
final int xSpeed = 200
static
final int yAcceleration = 500
static
final int yMax = 900
static
RegulatedMotor YMotor
private
final int ySpeed = 500
static

The documentation for this class was generated from the following file: