Majordhome/pixy
Diff: Servoloop.h
- Revision:
- 0:b12a5af91608
diff -r 000000000000 -r b12a5af91608 Servoloop.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servoloop.h Mon Apr 13 12:16:51 2015 +0000 @@ -0,0 +1,56 @@ +//========================================================================== +// +// Pixy Pet Robot +// +// Adafruit invests time and resources providing this open source code, +// please support Adafruit and open-source hardware by purchasing +// products from Adafruit! +// +// Written by: Bill Earl for Adafruit Industries +// +//========================================================================== +// begin license header +// +// All Pixy Pet source code is provided under the terms of the +// GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). +// +// end license header +// +//========================================================================== +// +// Portions of this code are derived from the Pixy CMUcam5 pantilt example code. +// +//========================================================================== +#ifndef SERVOLOOP_H +#define SERVOLOOP_H +#include <SPI.h> +#include <Pixy.h> +#include <MD25.h> + + +#define X_CENTER 160L +#define Y_CENTER 100L +#define RCS_MIN_POS 0L +#define RCS_MAX_POS 1000L +#define RCS_CENTER_POS ((RCS_MAX_POS-RCS_MIN_POS)/2) +//--------------------------------------- +// Servo Loop Class +// A Proportional/Derivative feedback +// loop for pan/tilt servo tracking of +// blocks. +// (Based on Pixy CMUcam5 example code) +//--------------------------------------- +class Servoloop +{ +public: +Servoloop(int32_t proportionalGain, int32_t derivativeGain); +void update(int32_t error); +int32_t m_pos; +int32_t m_prevError; +int32_t m_proportionalGain; +int32_t m_derivativeGain; + +}; +#endif +// End Servo Loop Class +//--------------------------------------- \ No newline at end of file