• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

RangeFinder.h

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;  // the port to which the sensor is connected
00023         int _history_ptr;
00024         int _history[AP_RANGEFINDER_NUM_AVERAGES];
00025   public:
00026         int raw_value;  // raw value from the sensor
00027         int distance; // distance in cm
00028         int max_distance;  // maximum measurable distance (in cm)
00029         int min_distance;  // minimum measurable distance (in cm)
00030         int orientation_x, orientation_y, orientation_z;
00031 
00032         int filter(int latestValue);  // returns the average of the last AP_RANGEFINDER_NUM_AVERAGES values
00033         
00034         virtual void init(int analogPort);
00035     virtual void set_orientation(int x, int y, int z);
00036         virtual int read();   // read value from analog port and return distance in cm
00037 };
00038 #endif

Generated for ArduPilot Libraries by doxygen