Homologation Cachan
Fork of TPixy-Interface by
Pixy.h@4:ee635fc62b6e, 2018-06-09 (annotated)
- Committer:
- lenriquez389
- Date:
- Sat Jun 09 03:56:25 2018 +0000
- Revision:
- 4:ee635fc62b6e
- Parent:
- 3:66df7d295245
PIXY
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
swilkins8 | 0:ef0e3c67dc5b | 1 | #ifndef _PIXY_H |
swilkins8 | 0:ef0e3c67dc5b | 2 | #define _PIXY_H |
swilkins8 | 0:ef0e3c67dc5b | 3 | |
swilkins8 | 0:ef0e3c67dc5b | 4 | #include "TPixy.h" |
swilkins8 | 0:ef0e3c67dc5b | 5 | #include "TPixyInterface.h" |
swilkins8 | 0:ef0e3c67dc5b | 6 | |
swilkins8 | 0:ef0e3c67dc5b | 7 | #define X_CENTER ((PIXY_MAX_X-PIXY_MIN_X)/2) |
swilkins8 | 0:ef0e3c67dc5b | 8 | #define Y_CENTER ((PIXY_MAX_Y-PIXY_MIN_Y)/2) |
swilkins8 | 0:ef0e3c67dc5b | 9 | |
swilkins8 | 0:ef0e3c67dc5b | 10 | class PixySPI : public TPixy<PixyInterfaceSPI> |
swilkins8 | 0:ef0e3c67dc5b | 11 | { |
swilkins8 | 0:ef0e3c67dc5b | 12 | public: |
swilkins8 | 3:66df7d295245 | 13 | /** Constructor for the PixySPI class |
swilkins8 | 3:66df7d295245 | 14 | * Instantiates a Pixy object that communicates via an SPI connection |
swilkins8 | 3:66df7d295245 | 15 | * @param SPI* spi the pointer to the SPI connection |
swilkins8 | 3:66df7d295245 | 16 | * @param Serial* serialOut the optional serial output pointer to print out Pixy camera data |
swilkins8 | 3:66df7d295245 | 17 | * @param int arg an optional integer argument used for custom implementations of the Pixy library |
swilkins8 | 3:66df7d295245 | 18 | */ |
swilkins8 | 0:ef0e3c67dc5b | 19 | PixySPI(SPI* spi, Serial* serialOut = NULL, uint16_t arg = PIXY_DEFAULT_ARGVAL) : |
swilkins8 | 0:ef0e3c67dc5b | 20 | TPixy<PixyInterfaceSPI>((new PixyInterfaceSPI(spi)), serialOut, arg) {} |
swilkins8 | 0:ef0e3c67dc5b | 21 | }; |
swilkins8 | 0:ef0e3c67dc5b | 22 | |
swilkins8 | 0:ef0e3c67dc5b | 23 | class ServoLoop |
swilkins8 | 0:ef0e3c67dc5b | 24 | { |
swilkins8 | 0:ef0e3c67dc5b | 25 | public: |
swilkins8 | 1:6587541f3aa8 | 26 | /** Constructor for a ServoLoop object |
swilkins8 | 1:6587541f3aa8 | 27 | * Creates a ServoLoop object for easy control of the Pixy servos |
swilkins8 | 1:6587541f3aa8 | 28 | * @param pgain the proportional gain for the control |
swilkins8 | 1:6587541f3aa8 | 29 | * @param dgain the derivative gain for the control |
swilkins8 | 1:6587541f3aa8 | 30 | */ |
swilkins8 | 0:ef0e3c67dc5b | 31 | ServoLoop(int32_t pgain, int32_t dgain); |
swilkins8 | 1:6587541f3aa8 | 32 | /** Update method for a ServoLoop object |
swilkins8 | 1:6587541f3aa8 | 33 | * Updates the m_pos variable for setting a Pixy servo |
swilkins8 | 1:6587541f3aa8 | 34 | * @param error the error between the center of the camera and the position of the tracking color |
swilkins8 | 1:6587541f3aa8 | 35 | */ |
swilkins8 | 0:ef0e3c67dc5b | 36 | void update(int32_t error); |
swilkins8 | 0:ef0e3c67dc5b | 37 | |
swilkins8 | 0:ef0e3c67dc5b | 38 | int32_t m_pos; |
swilkins8 | 0:ef0e3c67dc5b | 39 | int32_t m_prevError; |
swilkins8 | 0:ef0e3c67dc5b | 40 | int32_t m_pgain; |
swilkins8 | 0:ef0e3c67dc5b | 41 | int32_t m_dgain; |
swilkins8 | 0:ef0e3c67dc5b | 42 | }; |
swilkins8 | 0:ef0e3c67dc5b | 43 | #endif |