Mindstorms 3rd Party ROBOTC Drivers RobotC
[Home] [Download] [Submit a bug/suggestion] [ROBOTC Forums] [Blog] [Support this project]
Data Structures | Files | Defines | Typedefs | Functions | Variables

NXTCam Vision System
[Mindsensors]

Data Structures

struct  blob

Files

file  mindsensors-nxtcam.h
 

Mindsensors NXTCam driver.


Defines

#define MAX_BLOBS   8
#define NXTCAM_I2C_ADDR   0x02
#define NXTCAM_CMD_REG   0x41
#define NXTCAM_COUNT_REG   0x42
#define NXTCAM_DATA_REG   0x43
#define SIDE_CENTER(X1, X2)   ((X1 + X2) / 2)

Typedefs

typedef blob blob_array [MAX_BLOBS]

Functions

bool NXTCAMinit (tSensors link, ubyte address=NXTCAM_I2C_ADDR)
bool NXTCAMinitTL (tSensors link, ubyte address=NXTCAM_I2C_ADDR)
int NXTCAMgetBlobs (tSensors link, blob_array &blobs, bool mergeBlobs, ubyte address=NXTCAM_I2C_ADDR)
int NXTCAMgetBlobs (tSensors link, blob_array &blobs, ubyte address=NXTCAM_I2C_ADDR)
bool _camera_cmd (tSensors link, byte cmd, ubyte address)
int _mergeBlobs (int blob1, int blob2, int nblobs, blob_array &blobs)
int _merge (int nblobs, blob_array &blobs)
void _sortBlobs (int nblobs, blob_array &blobs)
void NXTCAMgetAverageCenter (blob_array &blobs, int nblobs, int colourindex, int &x, int &y)
void NXTCAMgetCenter (blob_array &blobs, int index, int &x, int &y)

Variables

tByteArray NXTCAM_I2CRequest
tByteArray NXTCAM_I2CReply
bool still_merging = false

Detailed Description

NXTCam Vision System


Define Documentation

#define MAX_BLOBS   8

Maximum number of blobs returned by the NXTCam

Definition at line 48 of file mindsensors-nxtcam.h.

#define NXTCAM_CMD_REG   0x41

Register used for issuing commands

Definition at line 50 of file mindsensors-nxtcam.h.

#define NXTCAM_COUNT_REG   0x42

Register used to hold number of blobs detected

Definition at line 51 of file mindsensors-nxtcam.h.

#define NXTCAM_DATA_REG   0x43

Register containing data pertaining to blobs

Definition at line 52 of file mindsensors-nxtcam.h.

#define NXTCAM_I2C_ADDR   0x02

I2C address used by the NXTCam

Definition at line 49 of file mindsensors-nxtcam.h.

#define SIDE_CENTER (   X1,
  X2 
)    ((X1 + X2) / 2)

Returns the center of a side

Definition at line 54 of file mindsensors-nxtcam.h.


Typedef Documentation

typedef blob blob_array[MAX_BLOBS]

Array of blob as a typedef, this is a work around for RobotC's inability to pass an array to a function

Examples:
mindsensors-nxtcam-test1.c.

Definition at line 67 of file mindsensors-nxtcam.h.


Function Documentation

bool _camera_cmd ( tSensors  link,
byte  cmd,
ubyte  address 
)

This function sends a command to the camera over I2C.

Note: this is an internal function and should not be called directly.

Parameters:
linkthe sensor port number
cmdthe command to be sent
addressthe I2C address to use, optional, defaults to 0x02
Returns:
true if no error occured, false if it did

Definition at line 98 of file mindsensors-nxtcam.h.

int _merge ( int  nblobs,
blob_array blobs 
)

Go through the blobs and calls _mergeBlobs.

Note: this is an internal function and should not be called directly.

Parameters:
nblobsthe number of blobs
blobsthe array of blobs
Returns:
the number of blobs detected

Definition at line 232 of file mindsensors-nxtcam.h.

int _mergeBlobs ( int  blob1,
int  blob2,
int  nblobs,
blob_array blobs 
)

Check if two blobs can be merged into one. blob1 will be replaced with the new merged blob and blob2 will be destroyed.

Note: this is an internal function and should not be called directly.

Parameters:
blob1the index number of the first blob
blob2the index number of the second blob
nblobsthe number of blobs
blobsthe array of blobs
Returns:
the number of blobs detected

Definition at line 256 of file mindsensors-nxtcam.h.

void _sortBlobs ( int  nblobs,
blob_array blobs 
)

This function sorts the blobs in the array using insertion sort.

Note: this is an internal function and should not be called directly.

Parameters:
nblobsthe number of blobs
blobsthe array of blobs

Definition at line 326 of file mindsensors-nxtcam.h.

void NXTCAMgetAverageCenter ( blob_array blobs,
int  nblobs,
int  colourindex,
int &  x,
int &  y 
)

Calculate the average center of all the blobs of a specific colour.

Note: this is an experimental function and may not function properly yet.

Parameters:
blobsthe array of blobs
nblobsthe number of blobs
colourindexthe colour of the blobs of which the average center is to be calculated
xx-coordinate of the center
yy-coordinate of the center

Definition at line 358 of file mindsensors-nxtcam.h.

int NXTCAMgetBlobs ( tSensors  link,
blob_array blobs,
ubyte  address 
)

This function fetches the blob data from the camera.

Parameters:
linkthe sensor port number
blobsthe array of blobs
addressthe I2C address to use, optional, defaults to 0x02
Returns:
the number of blobs detected, -1 if an error occurred

Definition at line 183 of file mindsensors-nxtcam.h.

int NXTCAMgetBlobs ( tSensors  link,
blob_array blobs,
bool  mergeBlobs,
ubyte  address 
)

This function fetches the blob data from the camera and merges the colliding ones.

Parameters:
linkthe sensor port number
blobsthe array of blobs
mergeBlobswhether or not to merge the colliding blobs
addressthe I2C address to use, optional, defaults to 0x02
Returns:
the number of blobs detected, -1 if an error occurred
Examples:
mindsensors-nxtcam-test1.c.

Definition at line 169 of file mindsensors-nxtcam.h.

void NXTCAMgetCenter ( blob_array blobs,
int  index,
int &  x,
int &  y 
)

Calculate the center of a specified blob.

Note: this is an experimental function and may not function properly yet.

Parameters:
blobsthe array of blobs
indexthe blob that you want to calculate the center of
xx-coordinate of the center
yy-coordinate of the center

Definition at line 384 of file mindsensors-nxtcam.h.

bool NXTCAMinit ( tSensors  link,
ubyte  address 
)

This function initialises camera ready to find blobs and sort them according to size.

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
true if no error occured, false if it did
Examples:
mindsensors-nxtcam-test1.c.

Definition at line 113 of file mindsensors-nxtcam.h.

bool NXTCAMinitTL ( tSensors  link,
ubyte  address 
)

This function initialises camera ready to track lines.

Parameters:
linkthe sensor port number
addressthe I2C address to use, optional, defaults to 0x02
Returns:
true if no error occured, false if it did

Definition at line 140 of file mindsensors-nxtcam.h.


Variable Documentation

Array to hold I2C reply data

Definition at line 70 of file mindsensors-nxtcam.h.

Array to hold I2C command data

Definition at line 69 of file mindsensors-nxtcam.h.

bool still_merging = false

boolean to signal if there are still blobs that might qualify for merging

Definition at line 87 of file mindsensors-nxtcam.h.