#include <SIR.h>
Inheritance diagram for SIR:
Public Member Functions | |
bool | obstacleLeft () |
bool | obstacleRight () |
bool | obstacleFront () |
double | getLeftMargin () |
double | getRightMargin () |
double | getFrontMargin () |
bool | robotDetected () |
bool | cubeDetected () |
void | getRobotPosition (double &x, double &y, double &phi) |
void | getGlobalCubePosition (double &x, double &y) |
void | getDensity (double &density, double ¢erOfDensityX, double ¢erOfDensityY) |
void | setCubeSize (int size) |
void | setCubeColor (int color) |
bool | obstacle (void) |
bool | spawn () |
void | getLocalCubePosition (double &x, double &y) |
void | initialize (void) |
Static Public Member Functions | |
SIR * | getSIR () |
Protected Member Functions | |
SIR () | |
void | run (void) |
Static Protected Member Functions | |
void | staticRun (void) |
Private Member Functions | |
void | takePicture () |
void | takeColorPicture () |
bool | detectCubes () |
bool | detectRobots () |
bool | hasCubeColor (BYTE hue) |
Private Attributes | |
double | cubeDistanceX |
double | cubeDistanceY |
double | cubePositionX |
double | cubePositionY |
double | obstacleThresholdFront |
bool | robotDetectedFlag |
bool | cubeDetectedFlag |
double | minimumCubeSize |
int | cubeColor |
int | allowedCubeColorDeviation |
double | obstacleThresholdSides |
image | currentImage |
colimage | currentColorImage |
Camera * | camera |
ImageFilter | imageFilter |
PSDs * | psds |
Drive * | drive |
Static Private Attributes | |
SIR * | mes [NUMBER_OF_ROBOTS] |
SIR | sirs [NUMBER_OF_ROBOTS] |
const double | row2Meter [imagerows] |
const double | yFactor [imagerows] |
const double | yFactorMinus [imagerows] |
|
Constructor for SIR. Passes standard parameters for SIR to the Thread constructor |
|
Indicates if a cube is currently visible on the camera
|
|
Tries to detect cubes in the current color image
|
|
Tries to detect robots in the current image
|
|
Estimates the cube density in the image by counting the pixels that have the cube color
|
|
Returns the distance from the robot to the next object in the front
|
|
Passes the last known position of the last detected cube in global coordinates (i.e. with (0,0) and not the current robot position as origin). If no cube has been detected yet (0,0) is passed. SIR::cubeDetected() should be used before calling this method to check if the data is up to date (i.e. the cube whose position is passed is indeed still visible). If more than one cube was detected on the image the position of the closest cube is passed |
|
Returns the distance from the robot to the next object to the left
|
|
Passes the last known position of the last detected cube in local coordinates. If no cube has been detected yet (0,0) is passed. As the position is passed in local coordinates (that is the relative distance from cube to robot at the time when the image - on which the cube was detected - was taken) this information expires quickly. SIR::cubeDetected() should definitely be used before calling this method to check if the data is up to date (i.e. the cube whose position is passed is indeed still visible). If more than one cube was detected on the image the position of the closest cube is passed |
|
Returns the distance from the robot to the next object to the right
|
|
Passes the last known position of the last detected robot. If no robot has been detected yet (0,0,0) is passed. SIR::robotDetected() should be used before calling this method to check if the data is up to date (i.e. the robot whose position is passed is indeed still visible). If more than one robot was detected on the image the position of the closest robot is passed |
|
This method is used to get the instance of this singleton class
|
|
Checks if the passed hue is similar to the cube color
|
|
The simulator does not allow the usage of RoBIOS functions in class constructors. Therefore we use public initialize methods for classes that need RoBIOS functions for their initializations. |
|
Indicates whether an obstacle is detected by any of the infra-red sensors
|
|
Indicates whether an obstacle is detected by the front infra-red sensor
|
|
Indicates whether an obstacle is detected by the left infra-red sensor
|
|
Indicates whether an obstacle is detected by the right infra-red sensor
|
|
Indicates if a robot is currently visible on the camera
|
|
The method is overwritten by the inheritor. When the thread starts the code in this run method is executed Reimplemented from Thread. |
|
Not used yet |
|
Not used yet |
|
According to C++ convention, methods cannot be static and virtual at once. In the initial design run was declared as virtual which results in dynamic binding. That means the program determines at run-time which run method to use, the one of the Thread base class or the one of the inheritor. Because we have to use staticRun, we cannot use the virtual keyword anymore. Without the virtual keyword the compiler determines at compile-time which run method is used, always the run method of the Thread base class. To ensure that the inheritor indeed uses its own run method, it is necessary to overwrite the thread initialization method (spawn) as well.
Reimplemented from Thread. |
|
Static wrapper method for run. It does nothing but to call run. That is necessary because the RoBIOS multi-tasking functions expect a pointer to a C-function (not a pointer to a C++ method) containing the code to be executed. Fortunately, pointer-to-static-C++-methods are compatible with regular pointer-to-C-functions. But the problem is that static methods can only use other static methods and variables. The reasons is that a static method, which is shared by all instances, would not know which non-static method or variable to use if there were multiple instances of the same class. Thus, the static property would have to be applied to all used (sub-)methods and (sub-) variables, and propagate through the whole class structure. By using staticRun, we can keep using our non-static run. If static methods cannot call non-static ones, how can staticRun call run? As aforementioned the reason why static method cannot use non-static members is because it is not clear which non-static member to use if there are multiple instances of the same class. That means staticRun needs a pointer to the instance whose run method is to be called. This pointer is stored in a static member variable called me.
|
|
Gets a new color image from the camera and stores it in currentColorImage
|
|
Gets a new image from the camera and stores it in currentImage
|
|
By how much the color of a pixel may deviate and still be accepted as cube color |
|
The SIR has a Camera to get pictures |
|
Stores the color of the cubes to be pushed as hue |
|
Flag to indicate that a cube is visible on the camera. Used internally
|
|
Stores the x value of the last known position of the last detected cube in local coordinates (That is the x distance from cube to robot at the time when the image - on which the cube was detected - was taken) |
|
Stores the y value of the last known position of the last detected cube in local coordinates (That is the y distance from cube to robot at the time when the image - on which the cube was detected - was taken) |
|
Stores the x value of the last known position of the last detected cube (in global coordinates, i.e. with (0,0) and not the current robot position as origin) |
|
Stores the y value of the last known position of the last detected cube (in global coordinates, i.e. with (0,0) and not the current robot position as origin) |
|
The color image that is currently used for the detection of cubes (by SIR::detectCubes(), SIR::getDensity()) |
|
The grayscale image that is currently used for the detection of robots (SIR::detectRobots()) |
|
The SIR needs the Drive to receive position information |
|
The SIR has an ImageFilter to process the taken pictures |
|
Stores pointers to instances of SIR
|
|
Stores the minimum size that an object must have to be accepted as a cube (in meter) |
|
How far the distance to an object may drop before the object is marked as an obstacle by the front PSD sensor (in meter) |
|
How far the distance to an object may drop before the object is marked as an obstacle by the left/right PSD sensor (in meter) |
|
The SIR needs the PSDs to receive infra-red distance information |
|
Flag to indicate that a robot is visible on the camera. Used internally
|
|
Initial value: {1.000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.9000, 0.9000, 0.9000, 0.8000, 0.8000, 0.7500, 0.7000, 0.6500, 0.6000, 0.5500, 0.5250, 0.5000, 0.4830, 0.4670, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.7300, 0.6600, 0.6200, 0.5800, 0.5400, 0.5000, 0.4700, 0.4400, 0.4100, 0.3900, 0.3700, 0.3500, 0.3300, 0.3050, 0.2900, 0.2750, 0.2550, 0.2400, 0.2300, 0.2200, 0.2150, 0.2100, 0.2000, 0.1950, 0.1900, 0.1800, 0.1700, 0.1600, 0.1550, 0.1500, 0.1400, 0.1350, 0.0650, 0.065} |
|
The single instance that exists of this class
|
|
Initial value: {0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0200, 0.0180, 0.0140, 0.0105, 0.0095, 0.0090, 0.0085, 0.0080, 0.0073, 0.0069, 0.0067, 0.0095, 0.0095, 0.0095, 0.0095, 0.0095, 0.0075, 0.0075, 0.0075, 0.0075, 0.0075, 0.0055, 0.0039, 0.0039, 0.0037, 0.0036, 0.0036, 0.0035, 0.0034, 0.0034, 0.0033, 0.0033, 0.0032, 0.0030, 0.0028, 0.0026, 0.0025, 0.0026, 0.0027, 0.0028, 0.0029, 0.0030, 0.0029, 0.0028, 0.0026, 0.0023, 0.0022, 0.0020, 0.0018, 0.0016, 0.0015, 0.0100} |
|
Initial value: {0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0100, 0.0059, 0.0055, 0.0053, 0.0047, 0.0045, 0.0042, 0.0040, 0.0036, 0.0034, 0.0033, 0.0015, 0.0015, 0.0014, 0.0014, 0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0026, 0.0025, 0.0024, 0.0023, 0.0022, 0.0021, 0.0019, 0.0018, 0.0017, 0.0016, 0.0015, 0.0014, 0.0013, 0.0012, 0.0011, 0.0011, 0.0010, 0.0011, 0.0010, 0.0010, 0.0010, 0.0010, 0.0010, 0.0010, 0.0010, 0.0010, 0.0010, 0.0009, 0.0008, 0.0007, 0.0010} |