ECRobot C++ API for LEGO MINDSTORMS NXT
1.0.10
|
Mindsensor Camera device (http://www.mindsensors.com/) class. More...
#include <Camera.h>
Classes | |
struct | Rectangle_T |
Type of rectangle for object being tracked. More... | |
Public Types | |
enum | eTrackingType { OBJECT = OBJECT_TRACKING, LINE = LINE_TRACKING } |
Tracking types. More... | |
enum | eSortType { SIZE = SORT_OBJ_BY_SIZE, COLOR = SORT_OBJ_BY_COLOR, NO_SORTING = NO_SORTING_OBJ } |
Tracked objects sorting types. More... | |
Public Member Functions | |
Camera (ePortS port) | |
Constructor (activate I2C). | |
void | enableTracking (boolean enable) |
Enable/disable tracking objects. | |
void | setTrackingType (eTrackingType mode) |
Choose either object or line tracking mode. | |
void | sortBy (eSortType sortType) |
Camera sorts objects it detects according to criteria, either color, size, or no sorting at all. | |
SINT | getNumberOfObjects (void) const |
Get the number of objects being tracked. | |
SINT | getObjectColor (SINT id) const |
Get the color number for a tracked object. | |
void | getRectangle (SINT id, Rectangle_T *rect) |
Get the rectangle containing a tracked object. | |
bool | update (void) |
Call regularly to poll the status of the camera device. | |
bool | sendCommand (U8 command) |
Send a camera command. | |
bool | receive (U32 address, U8 *data, U32 length) |
Receive raw data from the camera. | |
Static Public Attributes | |
static const U8 | SORT_OBJ_BY_SIZE = 0x41 |
Command to sort tracked objects by size. | |
static const U8 | OBJECT_TRACKING = 0x42 |
Command to select object tracing mode. | |
static const U8 | WRITE_CAM_REG = 0x43 |
Command to write to camera registers. | |
static const U8 | DISABLE_TRACKING = 0x44 |
Command to disable tracking. | |
static const U8 | ENABLE_TRACKING = 0x45 |
Command to enable tracking. | |
static const U8 | GET_COLOR_MAP = 0x47 |
Command to get the color map from camera engine. | |
static const U8 | READ_CAM_REG = 0x48 |
Command to read data from the camera engine. | |
static const U8 | ILLUMINATION_ON = 0x49 |
Command to turn illumination On (Future) | |
static const U8 | LINE_TRACKING = 0x4C |
Command to select line tracking mode. | |
static const U8 | SET_ADPA_ON = 0x4E |
Command to set ADPA mode On. | |
static const U8 | SET_ADPA_OFF = 0x4F |
Command to set ADPA mode Off (default) | |
static const U8 | PING_CAMERA_ENGINE = 0x50 |
Command to ping camera engine. | |
static const U8 | RESET_CAMERA_ENGINE = 0x52 |
Command to reset camera engine. | |
static const U8 | SET_COLOR_MAP = 0x53 |
Command to send the color map to camera engine. | |
static const U8 | ILLUMINATION_OFF = 0x54 |
Command to turn illumination Off. | |
static const U8 | SORT_OBJ_BY_COLOR = 0x55 |
Command to sort tracked objects by color. | |
static const U8 | GET_VERSION = 0x56 |
Command to get camera engine firmware version. | |
static const U8 | NO_SORTING_OBJ = 0x58 |
Command to not sort tracked objects. |
Mindsensor Camera device (http://www.mindsensors.com/) class.
[ How to use with TOPPERS/ATK1(OSEK) ]
I2C (derived/compositted) class and Clock class internally use RTOS features. Thus, user needs to implement a C function and RTOS provided events.
+ Invoke SleeperMonitor function in user_1msec_isr_type2 hook.
void user_1ms_isr_type2(void)
{
SleeperMonitor(); // needed for I2C devices and Clock class
}
+ Define EventSleepI2C and EventSleep Events in user oil file.
EVENT EventSleepI2C
{
MASK = AUTO;
};
EVENT EventSleep
{
MASK = AUTO;
};
TASK TaskMain
{
AUTOSTART = TRUE
{
APPMODE = appmode1;
};
PRIORITY = 1;
ACTIVATION = 1;
SCHEDULE = FULL;
STACKSIZE = 512;
EVENT = EventSleepI2C; <- Here it is
EVENT = EventSleep; <- Here it is
};
[ How to use with TOPPERS/JSP(ITRON) ]
In case of using this class with TOPPERS/JSP(ITRON), RTOS specific definitions for the class are not needed.
ecrobot::Camera::Camera | ( | ePortS | port | ) | [explicit] |
Constructor (activate I2C).
Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object.
When the object is destructed while the system is shut down, the device is de-activated automatically.
port | Camera device connected port |
void ecrobot::Camera::enableTracking | ( | boolean | enable | ) |
Enable/disable tracking objects.
enable,: | true(enable)/false(disable) |
SINT ecrobot::Camera::getNumberOfObjects | ( | void | ) | const [inline] |
Get the number of objects being tracked.
- |
SINT ecrobot::Camera::getObjectColor | ( | SINT | id | ) | const [inline] |
Get the color number for a tracked object.
id | The object number (starting at zero) |
void ecrobot::Camera::getRectangle | ( | SINT | id, |
Rectangle_T * | rect | ||
) |
Get the rectangle containing a tracked object.
id | The object number (staring at zero) |
rect | Rectangle data |
bool ecrobot::Camera::receive | ( | U32 | address, |
U8 * | data, | ||
U32 | length | ||
) | [inline] |
Receive raw data from the camera.
address | I2C address |
data | Data to be received |
length | Length of data to be received |
bool ecrobot::Camera::sendCommand | ( | U8 | command | ) | [inline] |
Send a camera command.
command | single byte camera command |
void ecrobot::Camera::setTrackingType | ( | eTrackingType | mode | ) | [inline] |
Choose either object or line tracking mode.
mode | OBJECT/LINE |
void ecrobot::Camera::sortBy | ( | eSortType | sortType | ) | [inline] |
Camera sorts objects it detects according to criteria, either color, size, or no sorting at all.
sortType | SIZE/COLOR/NO_SORTING |
bool ecrobot::Camera::update | ( | void | ) |
Call regularly to poll the status of the camera device.
- |
const U8 ecrobot::Camera::WRITE_CAM_REG = 0x43 [static] |
Command to write to camera registers.
According to Mindsensors:
Use extreme CAUTION when using this command since this can stop your camera working properly. In case this happens, please power off your NXTCam and power it on again.