Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pixy2.h
00001 /** 00002 * @author Hugues Angelis 00003 * 00004 * @section LICENSE 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy 00007 * of this software and associated documentation files (the "Software"), to deal 00008 * in the Software without restriction, including without limitation the rights 00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00010 * copies of the Software, and to permit persons to whom the Software is 00011 * furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00022 * THE SOFTWARE. 00023 * 00024 * @section DESCRIPTION 00025 * 00026 * CMUCAM 5 - Pixy2 00027 * 00028 * Datasheet, FAQ and PC drivers : 00029 * 00030 * http://www.pixycam.com/ 00031 */ 00032 00033 #ifndef _PIXY2_ 00034 #define _PIXY2_ 00035 00036 /** 00037 * Include : Mbed Library 00038 */ 00039 #include "mbed.h" 00040 00041 /** 00042 * Defines 00043 */ 00044 #define PIXY2_NCSHEADERSIZE 4 00045 #define PIXY2_CSHEADERSIZE 4 00046 #define PIXY2_SYNC 0xC1AE 00047 #define PIXY2_CSSYNC 0xC1AF 00048 #define PIXY2_REP_ACK 1 00049 #define PIXY2_REP_ERROR 3 00050 #define PIXY2_ASK_RESOL 12 00051 #define PIXY2_REP_RESOL 13 00052 #define PIXY2_ASK_VERS 14 00053 #define PIXY2_REP_VERS 15 00054 #define PIXY2_SET_BRIGHT 16 00055 #define PIXY2_SET_SERVOS 18 00056 #define PIXY2_SET_LED 20 00057 #define PIXY2_SET_LAMP 22 00058 #define PIXY2_ASK_FPS 24 00059 #define PIXY2_REP_FPS 1 00060 #define PIXY2_ASK_BLOC 32 00061 #define PIXY2_REP_BLOC 33 00062 #define PIXY2_ASK_LINE 48 00063 #define PIXY2_REP_LINE 49 00064 #define PIXY2_SET_MODE 54 00065 #define PIXY2_SET_TURN 58 00066 #define PIXY2_SET_VECTOR 56 00067 #define PIXY2_SET_DEFTURN 60 00068 #define PIXY2_SET_REVERSE 62 00069 #define PIXY2_ASK_VIDEO 112 00070 #define PIXY2_VECTOR 1 00071 #define PIXY2_INTERSECTION 2 00072 #define PIXY2_BARCODE 4 00073 #define PIXY2_MAX_INT_LINE 6 00074 00075 /**************** ERRORS ****************/ 00076 00077 /** 00078 * \struct T_pixy2ErrorCode 00079 * \brief Explicit error code list : 00080 * \param PIXY2_OK : No error 00081 * \param PIXY2_MISC_ERROR : Generic error 00082 * \param PIXY2_BUSY : Pixy is busy (the response message is not yet fully arrived) 00083 * \param PIXY2_BAD_CHECKSUM : Checksum is wrong 00084 * \param PIXY2_TIMEOUT : Pixy2 is not talking 00085 * \param PIXY2_BUTTON_OVERRIDE : User is manualy operating the button of the Pixy2 00086 * \param PIXY2_PROG_CHANGE : Checksum is wrong 00087 * \param PIXY2_TYPE_ERROR : Unexpected message type 00088 * @note More documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api#error-codes 00089 */ 00090 typedef int T_pixy2ErrorCode; 00091 00092 #define PIXY2_OK 0 00093 #define PIXY2_MISC_ERROR -1 00094 #define PIXY2_BUSY -2 00095 #define PIXY2_BAD_CHECKSUM -3 00096 #define PIXY2_TIMEOUT -4 00097 #define PIXY2_OVERRIDE -5 00098 #define PIXY2_PROG_CHANGE -6 00099 #define PIXY2_TYPE_ERROR -7 00100 00101 /**************** STATE MACHINE ****************/ 00102 00103 typedef enum {idle, messageSent, receivingHeader, receivingData, dataReceived} T_Pixy2State; 00104 00105 /**************** UTILS ****************/ 00106 00107 00108 /** 00109 * \struct Byte -> Short hand for unsigned char 00110 * \struct sByte -> Short hand for char 00111 * \struct Word -> Short hand for unsigned short 00112 * \struct sWord -> Short hand for short 00113 * \struct lWord -> Short hand for unsigned long 00114 * \struct slWord -> Short hand for long 00115 */ 00116 typedef unsigned char Byte; 00117 typedef char sByte; 00118 typedef unsigned short Word; 00119 typedef short sWord; 00120 typedef unsigned long lWord; 00121 typedef long slWord; 00122 00123 /** 00124 * \union T_Word 00125 * \brief Structured type to switch from word to bytes 00126 * \param mot (Word) : 16 bits word 00127 * \param octet (Byte) : 2 bytes that overlap mot (byte access) 00128 */ 00129 typedef union { 00130 Word mot; 00131 Byte octet[2]; 00132 }T_Word; 00133 00134 /** 00135 * \union T_lWord 00136 * \brief Structured type to switch from lword to word or bytes 00137 * \param motLong (lWord) : 32 bits word 00138 * \param mot (Word) : 2 x 16 bits words that overlap motLong (word access) 00139 * \param octet (Byte) : 4 bytes that overlap motLong (byte access) 00140 */ 00141 typedef union { 00142 lWord motLong; 00143 Word mot[2]; 00144 Byte octet[4]; 00145 }T_lWord; 00146 00147 00148 /**************** HEADERS ****************/ 00149 00150 /** 00151 * \struct T_pixy2Header 00152 * \brief Structured type that match pixy2 header without checksum (send message) 00153 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC) 00154 * \param pixType (Byte) : 8 bits message type identifier 00155 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum) 00156 */ 00157 typedef struct { 00158 Word pixSync; 00159 Byte pixType; 00160 Byte pixLength; 00161 }T_pixy2Header; 00162 00163 /** 00164 * \struct T_pixy2SendFrame 00165 * \brief Structured type that match frame definition for all kind of message to send to a pixy2 00166 * \param header (T_pixy2Header) : 4 bytes classical header starting with PIXY2_SYNC 00167 * \param data (Byte) : 5 bytes payload (to match all usage, not all byte must be used) 00168 */ 00169 typedef struct { 00170 T_pixy2Header header; 00171 Byte data[5]; 00172 }T_pixy2SendFrame; 00173 00174 /** 00175 * \union T_pixy2SendBuffer 00176 * \brief Structured type to switch between structured type T_pixy2sendFrame and bytes 00177 * \param frame (T_pixy2SendFrame) : classical frame (header + payload) starting with PIXY2_SYNC 00178 * \param data (Byte) : 9 bytes that overlap frame (byte access) 00179 */ 00180 typedef union { 00181 T_pixy2SendFrame frame; 00182 Byte data[9]; 00183 }T_pixy2SendBuffer; 00184 00185 /** 00186 * \struct T_pixy2RcvHeader 00187 * \brief Structured type that match pixy2 header with checksum (received message) 00188 * \param pixSync (Word) : 16 bits synchro word - could be 0xc1ae (PIXY2_SYNC) or 0xc1af (PIXY2_CSSYNC) 00189 * \param pixType (Byte) : 8 bits message type identifier 00190 * \param pixLength (Byte) : 8 bits message payload length (payload doesn't include checksum) 00191 * \param pixSync (Word) : 16 bits checksum (sum of all bytes of the payload) 00192 */ 00193 typedef struct { 00194 Word pixSync; 00195 Byte pixType; 00196 Byte pixLength; 00197 Word pixChecksum; 00198 }T_pixy2RcvHeader; 00199 00200 00201 /**************** PAYLOADS ****************/ 00202 00203 /** 00204 * \struct T_pixy2ReturnCode 00205 * \brief Structured type that match pixy2 error/acknowledge/reply frame (type = 1 or 3) message payload 00206 * \param pixReturn (lWord) : 32 bits returned value 00207 */ 00208 typedef struct { 00209 lWord pixReturn; 00210 }T_pixy2ReturnCode; 00211 00212 /** 00213 * \struct T_pixy2Version 00214 * \brief Structured type that match pixy2 version frame (type = 14/15) message payload 00215 * \param pixHWVersion (Word) : 16 bits hardWare Version of pixy2 00216 * \param pixFWVersionMaj (Byte) : 8 bits upper part of firmware (before the dot) 00217 * \param pixFWVersionMin (Byte) : 8 bits lower part of firmware (after the dot) 00218 * \param pixFWBuild (Word) : 16 bits firmware build information 00219 * \param pixHFString (String) : 10 bytes user friendly pixy2 firmware type 00220 */ 00221 typedef struct { 00222 Word pixHWVersion; 00223 Byte pixFWVersionMaj; 00224 Byte pixFWVersionMin; 00225 Word pixFWBuild; 00226 char pixHFString[10]; 00227 }T_pixy2Version; 00228 00229 /** 00230 * \struct T_pixy2Resolution 00231 * \brief Structured type that match pixy2 resolution frame (type = 12/13) message payload 00232 * \param pixFrameWidth (Word) : 16 bits width (in pixel) of an image 00233 * \param pixFrameHeight (Word) : 16 bits height (in pixel) of an image 00234 */ 00235 typedef struct { 00236 Word pixFrameWidth; 00237 Word pixFrameHeight; 00238 }T_pixy2Resolution; 00239 00240 /** 00241 * \struct T_pixy2Bloc 00242 * \brief Structured type that match pixy2 blocks frame (type = 32/33) message payload 00243 * \param pixSignature (Word) : 16 bits signature or color code of the color bloc (signature are between 1 and 7, color code are composed of signature of 2, up to 5, tags so over 10) 00244 * \param pixX (Word) : 16 bits X (horizontal axis) position of color bloc center, relative to the left of the image (in pixels, between 0 and 315) 00245 * \param pixY (Word) : 16 bits Y (vertical axis) position of color bloc center, relative to the top of the image (in pixels, between 0 and 207) 00246 * \param pixWidth (Word) : 16 bits width (in pixels, between 0 and 316) of color bloc 00247 * \param pixHeight (Word) : 16 bits height (in pixels, between 0 and 208) of color bloc 00248 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of a color code bloc 00249 * \param pixIndex (Byte) : 8 bits tracking identification of the color code bloc (set by pixy2 to ease a bloc position following program) 00250 * \param pixAge (Byte) : 8 bits age (in number of frame) of a bloc (doesn't wrap around). 00251 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:ccc_api 00252 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components 00253 */ 00254 typedef struct { 00255 Word pixSignature; 00256 Word pixX; 00257 Word pixY; 00258 Word pixWidth; 00259 Word pixHeight; 00260 sWord pixAngle; 00261 Byte pixIndex; 00262 Byte pixAge; 00263 }T_pixy2Bloc; 00264 00265 /** 00266 * \struct T_pixy2Vector 00267 * \brief Structured type that match pixy2 vector definition - used in Line frame (type 48/49) - message payload 00268 * \param pixX0 (Byte) : 8 bits X (horizontal, relative to the left of image) position of the tail of the vector (number between 0 and 78) 00269 * \param pixY0 (Byte) : 8 bits Y (vertical, relative to the top of image) position of the tail of the vector (number between 0 and 51) 00270 * \param pixX1 (Byte) : 8 bits X (horizontal, relative to the left of image) position of the head of the vector (number between 0 and 78) 00271 * \param pixY1 (Byte) : 8 bits Y (vertical, relative to the top of image) position of the head of the vector (number between 0 and 51) 00272 * \param pixIndex (Byte) : 8 bits tracking identification of the vector (set by pixy2 to ease a vector identification in case of multiple vector in a line following program) 00273 * \param pixFlags (Byte) : 8 bits flag containing possible usefull informations (see notes) 00274 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference 00275 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api 00276 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00277 */ 00278 typedef struct { 00279 Byte pixX0; 00280 Byte pixY0; 00281 Byte pixX1; 00282 Byte pixY1; 00283 Byte pixIndex; 00284 Byte pixFlags; 00285 }T_pixy2Vector; 00286 00287 /** 00288 * \struct T_pixy2InterLine 00289 * \brief Structured type that match pixy2 intersection line definition - used in Line frame (type 48/49) - message payload 00290 * \param pixIndex (Byte) : 8 bits tracking identification of the intersection line (set by pixy2 to ease a line following program) 00291 * \param pixReserved (Byte) : Not documented by manufacturer 00292 * \param pixAngle (sWord) : 16 bits angle (in degree, between -180.0 and +180.0) of the intersection line 00293 * @note This structure is a sub feature of Line API, packed as a sub feature of intersection feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference 00294 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api 00295 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00296 */ 00297 typedef struct { 00298 Byte pixIndex; 00299 Byte pixReserved; 00300 sWord pixAngle; 00301 }T_pixy2InterLine; 00302 00303 /** 00304 * \struct T_pixy2Intersection 00305 * \brief Structured type that match pixy2 intersection definition - used in Line frame (type 48/49) - message payload 00306 * \param pixX (Byte) : X axis coordinate of the intersection (in pixel, between 0 and 78) 00307 * \param pixY (Byte) : Y axis coordinate of the intersection (in pixel, between 0 and 51) 00308 * \param pixN (Byte) : Number of lines connected to the intersection (between 3 and 5) 00309 * \param pixReserved (Byte) : Not documented by manufacturer 00310 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference 00311 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api 00312 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00313 */ 00314 typedef struct { 00315 Byte pixX; 00316 Byte pixY; 00317 Byte pixN; 00318 Byte pixReserved; 00319 T_pixy2InterLine PixintLines[PIXY2_MAX_INT_LINE]; 00320 }T_pixy2Intersection; 00321 00322 /** 00323 * \struct T_pixy2BarCode 00324 * \brief Structured type that match pixy2 barcode definition - used in Line frame (type 48/49) - message payload 00325 * \param pixX (Byte) : X axis coordinate of the barcode (in pixel, between 0 and 78) 00326 * \param pixY (Byte) : Y axis coordinate of the barcode (in pixel, between 0 and 51) 00327 * \param pixFlag (Byte) : Flag to indicate if barcode met filtering constraint 00328 * \param pixCode (Byte) : Indicate the numeric value associated with the barcode (between 0 and 15) 00329 * @note This structure is a feature of Line API, packed as a feature in a Line Frame, documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference 00330 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api 00331 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00332 */ 00333 typedef struct { 00334 Byte pixX; 00335 Byte pixY; 00336 Byte pixFlag; 00337 Byte pixCode; 00338 }T_pixy2BarCode; 00339 00340 /** 00341 * \struct T_pixy2LineFeature 00342 * \brief Structured type that match pixy2 feature header for Line API - used in Line frame (type 48/49) - message payload 00343 * \param pixType (Byte) : Type of the feature (can be 1 -> Vector, 2 -> Intersection or 4 -> Barcode) 00344 * \param pixLength (Byte) : Number of Bytes for this feature 00345 * @note This structure is the header of features of Line API in Line Frames. Ther can be up to 4 features in a frame. Documented here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference 00346 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api 00347 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00348 */ 00349 typedef struct { 00350 Byte fType; 00351 Byte fLength; 00352 }T_pixy2LineFeature; 00353 00354 /** 00355 * \struct T_pixy2Pixel 00356 * \brief Structured type that match pixy2 video API - used in Video frame (type 112/1) - message payload 00357 * \param pixBlue (Byte) : Blue RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255) 00358 * \param pixGreen (Byte) : Green RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255) 00359 * \param pixRed (Byte) : Red RGB value of the average blue component of the 5x5 pixels square centered on X param passes to the function (value between 0 and 255) 00360 * @note More info can be found here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api 00361 * @note or here : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video 00362 */ 00363 typedef struct { 00364 Byte pixBlue; 00365 Byte pixGreen; 00366 Byte pixRed; 00367 }T_pixy2Pixel; 00368 00369 /** 00370 * Pixy2 : CMU CAM 5 - Smart camera 00371 * More informations at http://www.pixycam.com/ 00372 */ 00373 class PIXY2 { 00374 00375 protected : 00376 00377 Serial* _Pixy2; 00378 00379 public : 00380 /** 00381 * Constructor of pixy2 UART object. 00382 * 00383 * @param tx : the Mbed pin used as TX 00384 * @param rx : the Mbed pin used as RX 00385 * @param debit : the bitrate of the serial (max value is 230400 b/s) 00386 */ 00387 PIXY2(PinName tx, PinName rx, int debit = 230400); 00388 00389 /** 00390 * Destructor of pixy2 UART object. 00391 */ 00392 ~PIXY2(); 00393 00394 // Fonctions publiques 00395 00396 /** 00397 * Queries and receives the firmware and hardware version of Pixy2, which is put in the version member variable. 00398 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00399 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00400 * @param version (T_pixy2Version - passed by reference) : pointer to the version data structure 00401 * @return T_pixy2ErrorCode : error code. 00402 */ 00403 T_pixy2ErrorCode pixy2_getVersion (T_pixy2Version *version); 00404 00405 /** 00406 * Gets the width and height of the frames used by the current program. 00407 * After calling this function, the width and height can be found in the frameWidth and frameHeight member variables. 00408 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00409 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00410 * @param resolution (T_pixy2Resolution - passed by reference) : pointer to the resolution data structure 00411 * @return T_pixy2ErrorCode : error code. 00412 */ 00413 T_pixy2ErrorCode pixy2_getResolution (T_pixy2Resolution *resolution); 00414 00415 /** 00416 * Sets the relative exposure level of Pixy2's image sensor. 00417 * Higher values result in a brighter (more exposed) image. 00418 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00419 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00420 * @param brightness (Byte - passed by value) : brightness level 00421 * @return T_pixy2ErrorCode : error code. 00422 */ 00423 T_pixy2ErrorCode pixy2_setCameraBrightness (Byte brightness); 00424 00425 /** 00426 * Sets the servo positions of servos plugged into Pixy2's two RC servo connectors. 00427 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00428 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00429 * @param s0 (Word - passed by value) : value between 0 and 511 00430 * @param s1 (Word - passed by value) : value between 0 and 511 00431 * @return T_pixy2ErrorCode : error code. 00432 */ 00433 T_pixy2ErrorCode pixy2_setServos (Word s0, Word s1); 00434 00435 /** 00436 * Sets Pixy2's RGB LED value. The three arguments sets the brightness of the red, green and blue sections of the LED. 00437 * It will override Pixy2's own setting of the RGB LED. 00438 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00439 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00440 * @param red (Byte - passed by value) : Red component value (between 0 and 255) 00441 * @param green (Byte - passed by value) : Green component value (between 0 and 255) 00442 * @param blue (Byte - passed by value) : Blue component value (between 0 and 255) 00443 * @return T_pixy2ErrorCode : error code. 00444 */ 00445 T_pixy2ErrorCode pixy2_setLED (Byte red, Byte green, Byte blue); 00446 00447 /** 00448 * Sets on/off Pixy2's integrated light source. 00449 * The upper argument controls the two white LEDs along the top edge of Pixy2's PCB. The lower argument sets the RGB LED, causing it to turn on all three color channels at full brightness, resulting in white light. 00450 * It will override Pixy2's own setting of the RGB LED. 00451 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00452 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00453 * @param upper (Byte - passed by value) : switch on or off the upper lamps (boolean : zero or non-zero) 00454 * @param lower (Byte - passed by value) : switch on or off the lower lamp (boolean : zero or non-zero) 00455 * @return T_pixy2ErrorCode : error code. 00456 */ 00457 T_pixy2ErrorCode pixy2_setLamp (Byte upper, Byte lower); 00458 00459 /** 00460 * Gets Pixy2's framerate. 00461 * The framerate can range between 2 and 62 frames per second depending on the amount of light in the environment and the min frames per second setting in the Camera configuration tab. 00462 * This function can also serve as a simple indicator of the amount of light in the environment. That is, low framerates necessarily imply lower lighting levels 00463 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00464 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00465 * @param framerate (T_pixy2ReturnCode - passed by reference) : number of frame per second (between 2 and 62) 00466 * @return T_pixy2ErrorCode : error code. 00467 */ 00468 T_pixy2ErrorCode pixy2_getFPS (T_pixy2ReturnCode *framerate); 00469 00470 /** 00471 * Gets all detected color blocks in the most recent frame. 00472 * The new data is then available in the blocks member variable. The returned blocks are sorted by area, with the largest blocks appearing first in the blocks array. 00473 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components 00474 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00475 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__ccc_api 00476 * @param sigmap (Byte - passed by value) : signature filtering 00477 * @param maxBloc (Byte - passed by value) : maximum number of blocks to return 00478 * @return T_pixy2ErrorCode : error code. 00479 * @note There are 7 different signatures definition (sig1 to sig7). Color codes are made of a combination of signature and can be filtered as well. 00480 * @note Filtering is based on ORing codes : 1 for sig1, 2 for sig2, 4 for sig3, 8 for sig4, 16 for sig5, 32 for sig6, 64 sor sig7 and 128 for color code. 00481 * @note So sigmap = 255 means accept all and sigmap = 0 means reject all. For example filtering to get only sig1 and sig5 means using sigmap = 17 (16 + 1). 00482 */ 00483 T_pixy2ErrorCode pixy2_getBlocks (Byte sigmap, Byte maxBloc); 00484 00485 /** 00486 * Gets the latest main features of Line tracking in the most recent frame. 00487 * The results are returned in the variables vectors, intersections, and barcodes, respectively. 00488 * The main feature is the feature that is the most likely to be relevant for line traking. 00489 * In case of multiple vector (for example 2 lines unconnected), the function will return only the vector of the line you are the most likely to follow. 00490 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00491 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00492 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00493 * @param feature (Byte - passed by value) : feature filtering 00494 * @return T_pixy2ErrorCode : error code. 00495 * @note There are 3 possible features (vectors, intersections and barcodes). 00496 * @note Filtering is based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes. 00497 * @note So 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4). 00498 */ 00499 T_pixy2ErrorCode pixy2_getMainFeature (Byte features); 00500 00501 /** 00502 * Gets all the latest features of Line tracking in the most recent frame. 00503 * The results are returned in the variables vectors[], intersections[], and barcodes[], respectively. 00504 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00505 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00506 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00507 * @param feature (Byte - passed by value) : feature filtering 00508 * @return T_pixy2ErrorCode : error code (if negative) or ORing of feature detected (if positive). 00509 * @note There are 3 possible features (vectors, intersections and barcodes). 00510 * @note Filtering or detected feature are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes. 00511 * @note So for filtering : 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4). 00512 * @note So for return value : 1 means only vector(s) detected, 2 means only intersection(s) detected, 3 vector(s) and intersection(s) detected and so on. 00513 */ 00514 T_pixy2ErrorCode pixy2_getAllFeature (Byte features); 00515 00516 /** 00517 * Sets various modes in the line tracking algorithm. 00518 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00519 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00520 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00521 * @param mode (Byte - passed by value) : ORing of required feature 00522 * @return T_pixy2ErrorCode : error code. 00523 * @note There are 3 possible features : 00524 * @note * LINE_MODE_TURN_DELAYED : Normally, the line tracking algorithm will choose the straightest path (branch) when encountering an intersection. Setting LINE_MODE_TURN_DELAYED will prevent the line tracking algorithm from choosing the path automatically. This is useful if your program doesn't know beforehand which path it wants to take at the next intersection. 00525 * @note * LINE_MODE_MANUAL_SELECT_VECTOR : Normally, the line tracking algorithm will choose what it thinks is the best Vector line automatically. Setting LINE_MODE_MANUAL_SELECT_VECTOR will prevent the line tracking algorithm from choosing the Vector automatically. Instead, your program will need to set the Vector by calling setVector(). 00526 * @note * LINE_MODE_WHITE_LINE : Normally, the line tracking algorithm will try to find dark lines on a light background (black lines). Setting LINE_MODE_WHITE_LINE will instruct the line tracking algorithm to look for light lines on a dark background (white lines). 00527 */ 00528 T_pixy2ErrorCode pixy2_setMode (Byte mode); 00529 00530 /** 00531 * Tells the line tracking algorithm which path it should take at the next intersection. 00532 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00533 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00534 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00535 * @param angle (sWord - passed by value) : angle closest to the next turn (in degree, between -180 and 180) 00536 * @return T_pixy2ErrorCode : error code. 00537 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used. 00538 * @note setNextTurn() will remember the turn angle you give it, and execute it at the next intersection. The line tracking algorithm will then go back to the default turn angle for subsequent intersections. 00539 * @note Upon encountering an intersection, the line tracking algorithm will find the path in the intersection that matches the turn angle most closely. 00540 */ 00541 T_pixy2ErrorCode pixy2_setNextTurn (sWord angle); 00542 00543 /** 00544 * Tells the line tracking algorithm which path to choose by default upon encountering an intersection. 00545 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00546 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00547 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00548 * @param angle (sWord - passed by value) : angle closest to the default turn (in degree, between -180 and 180) 00549 * @return T_pixy2ErrorCode : error code. 00550 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used. 00551 * @note The line tracking algorithm will find the path in the intersection that matches the default turn angle most closely. 00552 * @note A call to setNextTurn() will supercede the default turn angle for the next intersection. 00553 */ 00554 T_pixy2ErrorCode pixy2_setDefaultTurn (sWord angle); 00555 00556 /** 00557 * Tells witch vector the tracking algorithm must choose as default route upon encountering an intersection. 00558 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00559 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00560 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00561 * @param index (Byte - passed by value) : index of the line to follow 00562 * @return T_pixy2ErrorCode : error code. 00563 * @note If the LINE_MODE_MANUAL_SELECT_VECTOR mode bit is set, the line tracking algorithm will no longer choose the Vector automatically. Instead, setVector() will set the Vector by providing the index of the line. 00564 */ 00565 T_pixy2ErrorCode pixy2_setVector (Byte vectorIndex); 00566 00567 /** 00568 * Reverse the head and the tail of vectors 00569 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00570 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00571 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00572 * @return T_pixy2ErrorCode : error code. 00573 * @note The Vector has a direction. It normally points up, from the bottom of the camera frame to the top of the camera frame for a forward-moving robot. Calling reverseVector() will invert the vector. This will typically cause your robot to back-up and change directions. 00574 */ 00575 T_pixy2ErrorCode pixy2_ReverseVector (void); 00576 00577 /** 00578 * Returns the average RGB components of a square of 5x5 pixels centered on the given pixel coordinate 00579 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video 00580 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00581 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api 00582 * @param x (Word - passed by value) : X coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 315) 00583 * @param y (Word - passed by value) : Y coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 207) 00584 * @param saturate (Byte - passed by value) : scale the 3 RGB components so that the highest one of the 3 RGB components is set to 255 (boolean : zero or non-zero) 00585 * @param pixel (T_pixy2Pixel - passed by reference) : RGB pixel. 00586 * @return T_pixy2ErrorCode : error code. 00587 */ 00588 T_pixy2ErrorCode pixy2_getRGB (Word x, Word y, Byte saturate, T_pixy2Pixel *pixel); 00589 00590 // Variables globales Publiques 00591 /** 00592 * @var Pixy2_numBlocks (Byte) number of color blocks in Pixy2_blocks 00593 * @var Pixy2_blocks[] (T_pixy2Bloc) color blocks detected in the last frame 00594 * @var Pixy2_numVectors (Byte) number of vectors in Pixy2_vectors 00595 * @var Pixy2_vectors[] (T_pixy2Vector) vectors detected in the last frame 00596 * @var Pixy2_numIntersections (Byte) number of intersections in Pixy2_intersections 00597 * @var Pixy2_intersections[] (T_pixy2Intersection) intersections detected in the last frame 00598 * @var Pixy2_intersLine[] (T_pixy2IntLines) lines detected in the last frame 00599 * @var Pixy2_numVectors (Byte) number of vectors in Pixy2_blocks 00600 * @var Pixy2_vectors[] (T_pixy2Vector) vectors detected in the last frame 00601 */ 00602 Byte Pixy2_numBlocks; 00603 T_pixy2Bloc *Pixy2_blocks; 00604 Byte Pixy2_numVectors; 00605 T_pixy2Vector *Pixy2_vectors; 00606 Byte Pixy2_numIntersections; 00607 T_pixy2Intersection *Pixy2_intersections; 00608 Byte Pixy2_numBarcodes; 00609 T_pixy2BarCode *Pixy2_barcodes; 00610 00611 private : 00612 // Variables globales Privées 00613 /** 00614 * @var etat (T_Pixy2State) state of the pixy2 cam (idle = No action, messageSent = Query or Set message sent, receivingHeader = Camera is respondig to the query/set, receivingData = Header received, dataReceived = All data has been recovered) 00615 * @var Pixy2_buffer (Array of Byte) bytes received from camera 00616 * @var wPointer (Byte) write pointer, pointing the next free cell of the array of received bytes 00617 * @var hPointer (Byte) header pointer, pointing on the begining of the header field in the array of received bytes 00618 * @var dPointer (Byte) data pointer, pointing on the begining of the data field in the array of received bytes 00619 * @var dataSize (Byte) number of bytes in the data field 00620 * @var frameContainChecksum (Byte) indicate if the received frame contains a checksum 00621 */ 00622 T_Pixy2State etat; 00623 Byte* Pixy2_buffer; 00624 Byte wPointer, hPointer, dPointer, dataSize; 00625 Byte frameContainChecksum; 00626 00627 // Fonctions privées 00628 00629 /** 00630 * Queries the firmware and hardware version of Pixy2. 00631 * This function is part of the pixy2_getVersion function who treat the reply to this query. 00632 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00633 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00634 * @return T_pixy2ErrorCode : error code. 00635 */ 00636 T_pixy2ErrorCode pixy2_sndGetVersion (void); 00637 00638 /** 00639 * Queries width and height of the frames used by the current program. 00640 * This function is part of the pixy2_getResolution function who treat the reply to this query. 00641 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00642 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00643 * @return T_pixy2ErrorCode : error code. 00644 */ 00645 T_pixy2ErrorCode pixy2_sndGetResolution (void); 00646 00647 /** 00648 * Sends the relative exposure level of Pixy2's image sensor. 00649 * Higher values result in a brighter (more exposed) image. 00650 * This function is part of the pixy2_setCameraBrightness function who treat the acknowledge of this frame. 00651 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00652 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00653 * @param brightness (Byte - passed by value) : brightness level 00654 * @return T_pixy2ErrorCode : error code. 00655 */ 00656 T_pixy2ErrorCode pixy2_sndSetCameraBrightness (Byte brightness); 00657 00658 /** 00659 * Sends the servo positions of servos plugged into Pixy2's two RC servo connectors. 00660 * This function is part of the pixy2_setServo function who treat the acknowledge of this frame. 00661 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00662 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00663 * @param s0 (Word - passed by value) : value between 0 and 511 00664 * @param s1 (Word - passed by value) : value between 0 and 511 00665 * @return T_pixy2ErrorCode : error code. 00666 */ 00667 T_pixy2ErrorCode pixy2_sndSetServo (Word s0, Word s1); 00668 00669 /** 00670 * Sends Pixy2's RGB LED value. The three arguments sets the brightness of the red, green and blue sections of the LED. 00671 * It will override Pixy2's own setting of the RGB LED. 00672 * This function is part of the pixy2_setLED function who treat the acknowledge of this frame. 00673 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00674 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00675 * @param red (Byte - passed by value) : Red component value (between 0 and 255) 00676 * @param green (Byte - passed by value) : Green component value (between 0 and 255) 00677 * @param blue (Byte - passed by value) : Blue component value (between 0 and 255) 00678 * @return T_pixy2ErrorCode : error code. 00679 */ 00680 T_pixy2ErrorCode pixy2_sndSetLED (Byte red, Byte green, Byte blue); 00681 00682 /** 00683 * Sends command that turns on/off Pixy2's integrated light source. 00684 * The upper argument controls the two white LEDs along the top edge of Pixy2's PCB. The lower argument sets the RGB LED, causing it to turn on all three color channels at full brightness, resulting in white light. 00685 * It will override Pixy2's own setting of the RGB LED. 00686 * This function is part of the pixy2_setLamp function who treat the acknowledge of this frame. 00687 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00688 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00689 * @param upper (Byte - passed by value) : switch on or off the upper lamps (boolean : zero or non-zero) 00690 * @param lower (Byte - passed by value) : switch on or off the lower lamp (boolean : zero or non-zero) 00691 * @return T_pixy2ErrorCode : error code. 00692 */ 00693 T_pixy2ErrorCode pixy2_sndSetLamp (Byte upper, Byte lower); 00694 00695 /** 00696 * Queries Pixy2's framerate. 00697 * This function is part of the pixy2_getFPS function who treat the reply to this query. 00698 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00699 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api 00700 * @return T_pixy2ErrorCode : error code. 00701 */ 00702 T_pixy2ErrorCode pixy2_sndGetFPS (void); 00703 00704 /** 00705 * Queries all detected color blocks in the most recent frame. 00706 * This function is part of the pixy2_getBlocks function who treat the reply to this query. 00707 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:color_connected_components 00708 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00709 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__ccc_api 00710 * @param sigmap (Byte - passed by value) : signature filtering 00711 * @param maxBloc (Byte - passed by value) : maximum number of blocks to return 00712 * @return T_pixy2ErrorCode : error code. 00713 * @note There are 7 different signatures definition (sig1 to sig7). Color codes are made of a combination of signature and can be filtered as well. 00714 * @note Filtering is based on ORing codes : 1 for sig1, 2 for sig2, 4 for sig3, 8 for sig4, 16 for sig5, 32 for sig6, 64 sor sig7 and 128 for color code. 00715 * @note So sigmap = 255 means accept all and sigmap = 0 means reject all. For example filtering to get only sig1 and sig5 means using sigmap = 17 (16 + 1). 00716 */ 00717 T_pixy2ErrorCode pixy2_sndGetBlocks (Byte sigmap, Byte maxBloc); 00718 00719 /** 00720 * Queries the latest features of Line tracking in the most recent frame. 00721 * The results are returned in the variables vectors, intersections, and barcodes, respectively. 00722 * This function is part of the pixy2_getMainFeature or pixy2_getAllFeature function who treat the reply to this query. 00723 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00724 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00725 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00726 * @param type (Byte - passed by value) : select between Main or All features (0 for main feature only, 1 for all features) 00727 * @param feature (Byte - passed by value) : feature filtering 00728 * @return T_pixy2ErrorCode : error code (if negative) or ORing of feature detected (if positive). 00729 * @note There are 3 possible features (vectors, intersections and barcodes). 00730 * @note Filtering or detected feature are based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes. 00731 * @note So for filtering : 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4). 00732 * @note So for return value : 1 means only vector(s) detected, 2 means only intersection(s) detected, 3 vector(s) and intersection(s) detected and so on. 00733 */ 00734 T_pixy2ErrorCode pixy2_sndGetLineFeature (Byte type, Byte feature); 00735 00736 /** 00737 * Sets various modes in the line tracking algorithm. 00738 * This function is part of the pixy2_setMode function who treat the acknowledge of this frame. 00739 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00740 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00741 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00742 * @param mode (Byte - passed by value) : ORing of required feature 00743 * @return T_pixy2ErrorCode : error code. 00744 * @note There are 3 possible features : 00745 * @note * LINE_MODE_TURN_DELAYED : Normally, the line tracking algorithm will choose the straightest path (branch) when encountering an intersection. Setting LINE_MODE_TURN_DELAYED will prevent the line tracking algorithm from choosing the path automatically. This is useful if your program doesn't know beforehand which path it wants to take at the next intersection. 00746 * @note * LINE_MODE_MANUAL_SELECT_VECTOR : Normally, the line tracking algorithm will choose what it thinks is the best Vector line automatically. Setting LINE_MODE_MANUAL_SELECT_VECTOR will prevent the line tracking algorithm from choosing the Vector automatically. Instead, your program will need to set the Vector by calling setVector(). 00747 * @note * LINE_MODE_WHITE_LINE : Normally, the line tracking algorithm will try to find dark lines on a light background (black lines). Setting LINE_MODE_WHITE_LINE will instruct the line tracking algorithm to look for light lines on a dark background (white lines). 00748 */ 00749 T_pixy2ErrorCode pixy2_sndSetMode (Byte mode); 00750 00751 /** 00752 * Tells the line tracking algorithm which path it should take at the next intersection. 00753 * This function is part of the pixy2_setNextTurn function who treat the acknowledge of this frame. 00754 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00755 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00756 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00757 * @param angle (sWord - passed by value) : angle closest to the next turn (in degree, between -180 and 180) 00758 * @return T_pixy2ErrorCode : error code. 00759 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used. 00760 * @note setNextTurn() will remember the turn angle you give it, and execute it at the next intersection. The line tracking algorithm will then go back to the default turn angle for subsequent intersections. 00761 * @note Upon encountering an intersection, the line tracking algorithm will find the path in the intersection that matches the turn angle most closely. 00762 */ 00763 T_pixy2ErrorCode pixy2_sndSetNextTurn (Word angle); 00764 00765 /** 00766 * Tells the line tracking algorithm which path to choose by default upon encountering an intersection. 00767 * This function is part of the pixy2_setDefaultTurn function who treat the acknowledge of this frame. 00768 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00769 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00770 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00771 * @param angle (sWord - passed by value) : angle closest to the default turn (in degree, between -180 and 180) 00772 * @return T_pixy2ErrorCode : error code. 00773 * @note Turn angles are specified in degrees, with 0 being straight ahead, left being 90 and right being -90, although any valid angle value can be used. 00774 * @note The line tracking algorithm will find the path in the intersection that matches the default turn angle most closely. 00775 * @note A call to setNextTurn() will supercede the default turn angle for the next intersection. 00776 */ 00777 T_pixy2ErrorCode pixy2_sndSetDefaultTurn (Word angle); 00778 00779 /** 00780 * Tells witch vector the tracking algorithm must choose as default route upon encountering an intersection. 00781 * This function is part of the pixy2_setVector function who treat the acknowledge of this frame. 00782 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00783 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00784 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00785 * @param vectorindex (Byte - passed by value) : index of the vector to follow 00786 * @return T_pixy2ErrorCode : error code. 00787 * @note If the LINE_MODE_MANUAL_SELECT_VECTOR mode bit is set, the line tracking algorithm will no longer choose the Vector automatically. Instead, setVector() will set the Vector by providing the index of the line. 00788 */ 00789 T_pixy2ErrorCode pixy2_sndSetVector (Byte vectorIndex); 00790 00791 /** 00792 * Reverse the head and the tail of vectors 00793 * This function is part of the pixy2_reverseVector function who treat the acknowledge of this frame. 00794 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00795 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00796 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00797 * @return T_pixy2ErrorCode : error code. 00798 * @note The Vector has a direction. It normally points up, from the bottom of the camera frame to the top of the camera frame for a forward-moving robot. Calling reverseVector() will invert the vector. This will typically cause your robot to back-up and change directions. 00799 */ 00800 T_pixy2ErrorCode pixy2_sndReverseVector (void); 00801 00802 /** 00803 * Queries the average RGB components of a square of 5x5 pixels centered on the given pixel coordinate 00804 * This function is part of the pixy2_getRGB function who treat the reply to this query. 00805 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video 00806 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00807 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:video_api 00808 * @param x (Word - passed by value) : X coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 315) 00809 * @param y (Word - passed by value) : Y coordinate of the center of de 5x5 pixels square (in pixel, between 0 and 207) 00810 * @param saturate (Byte - passed by value) : scale the 3 RGB components so that the highest one of the 3 RGB components is set to 255 (boolean : zero or non-zero) 00811 * @param pixel (T_pixy2Pixel - passed by reference) : RGB pixel. 00812 * @return T_pixy2ErrorCode : error code. 00813 */ 00814 T_pixy2ErrorCode pixy2_sndGetRGB (Word x, Word y, Byte saturate); 00815 00816 /** 00817 * Gets all the latest features of Line tracking in the most recent frame. 00818 * The results are returned in the variables vectors, intersections, and barcodes, respectively. 00819 * @note General description : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_tracking 00820 * @note Frame Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide 00821 * @note Function Documentation : https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy2_full_api#plugin_include__wiki__v2__line_api 00822 * @param feature (Byte - passed by value) : feature filtering 00823 * @return T_pixy2ErrorCode : error code. 00824 * @note There are 3 possible features (vectors, intersections and barcodes). 00825 * @note Filtering is based on ORing codes : 1 for vectors, 2 for intersections, 4 for barcodes. 00826 * @note So 7 = accept all, 0 = reject all. For example filtering to get only vectors and barcode means using feature = 5 (1 + 4). 00827 */ 00828 T_pixy2ErrorCode pixy2_getFeatures (void); 00829 00830 void pixy2_getByte (); 00831 T_pixy2ErrorCode pixy2_validateChecksum (Byte* tab); 00832 }; // End Class 00833 00834 #endif
Generated on Wed Jul 13 2022 11:28:36 by
1.7.2