Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
SimpleFilter/SimpleFilter.h@0:a6a169de725f, 2013-05-27 (annotated)
- Committer:
- shimniok
- Date:
- Mon May 27 13:26:03 2013 +0000
- Revision:
- 0:a6a169de725f
Working version with priorities set and update time display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | /** SimpleFilter implements a simple low pass integer "leaky integrator" described here: |
shimniok | 0:a6a169de725f | 2 | * |
shimniok | 0:a6a169de725f | 3 | * http://ece124web.groups.et.byu.net/references/readings/Simple%20Software%20Lowpass%20Filter.pdf |
shimniok | 0:a6a169de725f | 4 | * |
shimniok | 0:a6a169de725f | 5 | * Well suited for filtering ADC integer values very quickly |
shimniok | 0:a6a169de725f | 6 | * |
shimniok | 0:a6a169de725f | 7 | * Michael Shimniok http://bot-thoughts.com/ |
shimniok | 0:a6a169de725f | 8 | */ |
shimniok | 0:a6a169de725f | 9 | class SimpleFilter { |
shimniok | 0:a6a169de725f | 10 | public: |
shimniok | 0:a6a169de725f | 11 | /** Creates a new filter object |
shimniok | 0:a6a169de725f | 12 | * |
shimniok | 0:a6a169de725f | 13 | * @param shift: the number of shifts to perform at each filtering input step; lower means higher bandwidth |
shimniok | 0:a6a169de725f | 14 | */ |
shimniok | 0:a6a169de725f | 15 | SimpleFilter(short shift); |
shimniok | 0:a6a169de725f | 16 | |
shimniok | 0:a6a169de725f | 17 | /** Supplies input to the filter and returns filtered output value |
shimniok | 0:a6a169de725f | 18 | * |
shimniok | 0:a6a169de725f | 19 | * @param value is the input value to the filter, e.g., some measurement |
shimniok | 0:a6a169de725f | 20 | * @returns the filtered output value |
shimniok | 0:a6a169de725f | 21 | */ |
shimniok | 0:a6a169de725f | 22 | short filter(short value); |
shimniok | 0:a6a169de725f | 23 | |
shimniok | 0:a6a169de725f | 24 | /** Read the current value in the filter |
shimniok | 0:a6a169de725f | 25 | * |
shimniok | 0:a6a169de725f | 26 | * @returns the current value in the filter |
shimniok | 0:a6a169de725f | 27 | */ |
shimniok | 0:a6a169de725f | 28 | short value(void); |
shimniok | 0:a6a169de725f | 29 | |
shimniok | 0:a6a169de725f | 30 | /** Shorthand operator for value() |
shimniok | 0:a6a169de725f | 31 | * |
shimniok | 0:a6a169de725f | 32 | * @returns the current value in the filter |
shimniok | 0:a6a169de725f | 33 | */ |
shimniok | 0:a6a169de725f | 34 | operator short() { return value(); } |
shimniok | 0:a6a169de725f | 35 | |
shimniok | 0:a6a169de725f | 36 | private: |
shimniok | 0:a6a169de725f | 37 | long _filter_value; |
shimniok | 0:a6a169de725f | 38 | short _shift; |
shimniok | 0:a6a169de725f | 39 | }; |