Code for the car to drive in a figure eight motion
Dependencies: mbed-rtos mbed MODSERIAL mbed-dsp telemetry
encoder.h
- Committer:
- ericoneill
- Date:
- 2015-03-20
- Revision:
- 11:f8aa39c19477
- Parent:
- 9:d3909d9325e4
- Child:
- 13:97708869a4ba
File content as of revision 11:f8aa39c19477:
#ifndef ENCODER_H #define ENCODER_H class Encoder{ //Intervals used during encoder data collection to measure velocity int interval1; int interval2; int interval3; int avg_interval; int lastchange1; int lastchange2; int lastchange3; int lastchange4; //Variables used to for velocity control float avg_speed; float stall_check; float tuning_val; // Servo parameters float lastTurnTime; bool servoLeft; //Parameters specifying sample sizes and delays for small and large average speed samples float num_samples_small; float delay_small; float num_samples_large; float delay_large; // Large and small arrays used to get average velocity values float large_avg_speed_list [100]; float small_avg_speed_list [10]; public: Encoder(); void velocity_control(float duty_cyc, float tuning_const); void fallInterrupt(); void riseInterrupt(); private: // Internal functions float get_speed(); float get_avg_speed(float num_samples, float delay); }; #endif