Adam Snaider | c4b3c19 | 2015-02-01 01:30:39 +0000 | [diff] [blame^] | 1 | #ifndef FRC971_ZEROING_ZEROING_H_ |
| 2 | #define FRC971_ZEROING_ZEROING_H_ |
| 3 | |
| 4 | #include <vector> |
| 5 | #include "frc971/zeroing/zeroing_queue.q.h" |
| 6 | |
| 7 | namespace frc971 { |
| 8 | namespace zeroing { |
| 9 | |
| 10 | // Estimates the position with encoder, |
| 11 | // the pot and the indices. |
| 12 | class ZeroingEstimator { |
| 13 | public: |
| 14 | ZeroingEstimator(double index_difference, size_t max_sample_count); |
| 15 | void UpdateEstimate(const ZeroingInfo& info); |
| 16 | double getPosition(); |
| 17 | private: |
| 18 | // The estimated position. |
| 19 | double pos_; |
| 20 | // The distance between two consecutive index positions. |
| 21 | double index_diff_; |
| 22 | // The next position in 'start_pos_samples_' to be used to store the |
| 23 | // next sample. |
| 24 | int samples_idx_; |
| 25 | // Last 'max_sample_count_' samples for start positions. |
| 26 | std::vector<double> start_pos_samples_; |
| 27 | // The number of the last samples of start position to consider |
| 28 | // in the estimation. |
| 29 | size_t max_sample_count_; |
| 30 | }; |
| 31 | |
| 32 | } // namespace zeroing |
| 33 | } // namespace frc971 |
| 34 | |
| 35 | #endif // FRC971_ZEROING_ZEROING_H_ |