Go to the documentation of this file.00001 #ifndef RangeFinder_h
00002 #define RangeFinder_h
00003
00004 #include <inttypes.h>
00005
00006 #define AP_RANGEFINDER_ORIENTATION_FRONT 0, 10, 0
00007 #define AP_RANGEFINDER_ORIENTATION_RIGHT -10, 0, 0
00008 #define AP_RANGEFINDER_ORIENTATION_BACK 0,-10, 0
00009 #define AP_RANGEFINDER_ORIENTATION_LEFT 10, 0, 0
00010 #define AP_RANGEFINDER_ORIENTATION_UP 0, 0,-10
00011 #define AP_RANGEFINDER_ORIENTATION_DOWN 0, 0, 10
00012 #define AP_RANGEFINDER_ORIENTATION_FRONT_RIGHT -5, -5, 0
00013 #define AP_RANGEFINDER_ORIENTATION_BACK_RIGHT -5, -5, 0
00014 #define AP_RANGEFINDER_ORIENTATION_BACK_LEFT 5, -5, 0
00015 #define AP_RANGEFINDER_ORIENTATION_FRONT_LEFT 5, 5, 0
00016
00017 #define AP_RANGEFINDER_NUM_AVERAGES 4
00018
00019 class RangeFinder
00020 {
00021 public:
00022 int _analogPort;
00023 int _history_ptr;
00024 int _history[AP_RANGEFINDER_NUM_AVERAGES];
00025 public:
00026 int raw_value;
00027 int distance;
00028 int max_distance;
00029 int min_distance;
00030 int orientation_x, orientation_y, orientation_z;
00031
00032 int filter(int latestValue);
00033
00034 virtual void init(int analogPort);
00035 virtual void set_orientation(int x, int y, int z);
00036 virtual int read();
00037 };
00038 #endif