5 changed files with 0 additions and 209 deletions
@ -1,80 +0,0 @@ |
|||||||
#if 0 |
|
||||||
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
||||||
/*
|
|
||||||
This program is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
|
|
||||||
/*
|
|
||||||
* AP_RangeFinder_MaxsonarXL.cpp - Arduino Library for Sharpe GP2Y0A02YK0F |
|
||||||
* infrared proximity sensor |
|
||||||
* Code by Jose Julio and Randy Mackay. DIYDrones.com |
|
||||||
* |
|
||||||
* Sparkfun URL: http://www.sparkfun.com/products/9491
|
|
||||||
* datasheet: http://www.sparkfun.com/datasheets/Sensors/Proximity/XL-EZ0-Datasheet.pdf
|
|
||||||
* |
|
||||||
* Sensor should be connected to one of the analog ports |
|
||||||
* |
|
||||||
* Variables: |
|
||||||
* int distance : distance in cm |
|
||||||
* int max_distance : maximum measurable distance (in cm) |
|
||||||
* int min_distance : minimum measurable distance (in cm) |
|
||||||
* |
|
||||||
* Methods: |
|
||||||
* read() : read value from analog port and returns the distance (in cm) |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "AP_RangeFinder_MaxsonarXL.h" |
|
||||||
|
|
||||||
// Constructor //////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
AP_RangeFinder_MaxsonarXL::AP_RangeFinder_MaxsonarXL(AP_HAL::AnalogSource *source, FilterInt16 *filter) : |
|
||||||
RangeFinder(source, filter), |
|
||||||
_scaler(AP_RANGEFINDER_MAXSONARXL_SCALER) |
|
||||||
{ |
|
||||||
max_distance = AP_RANGEFINDER_MAXSONARXL_MAX_DISTANCE; |
|
||||||
min_distance = AP_RANGEFINDER_MAXSONARXL_MIN_DISTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
// Public Methods //////////////////////////////////////////////////////////////
|
|
||||||
float AP_RangeFinder_MaxsonarXL::calculate_scaler(int16_t sonar_type, float adc_refence_voltage) |
|
||||||
{ |
|
||||||
float type_scaler = 1.0f; |
|
||||||
switch(sonar_type) { |
|
||||||
case AP_RANGEFINDER_MAXSONARXL: |
|
||||||
type_scaler = AP_RANGEFINDER_MAXSONARXL_SCALER; |
|
||||||
min_distance = AP_RANGEFINDER_MAXSONARXL_MIN_DISTANCE; |
|
||||||
max_distance = AP_RANGEFINDER_MAXSONARXL_MAX_DISTANCE; |
|
||||||
break; |
|
||||||
case AP_RANGEFINDER_MAXSONARLV: |
|
||||||
type_scaler = AP_RANGEFINDER_MAXSONARLV_SCALER; |
|
||||||
min_distance = AP_RANGEFINDER_MAXSONARLV_MIN_DISTANCE; |
|
||||||
max_distance = AP_RANGEFINDER_MAXSONARLV_MAX_DISTANCE; |
|
||||||
break; |
|
||||||
case AP_RANGEFINDER_MAXSONARXLL: |
|
||||||
type_scaler = AP_RANGEFINDER_MAXSONARXLL_SCALER; |
|
||||||
min_distance = AP_RANGEFINDER_MAXSONARXLL_MIN_DISTANCE; |
|
||||||
max_distance = AP_RANGEFINDER_MAXSONARXLL_MAX_DISTANCE; |
|
||||||
break; |
|
||||||
case AP_RANGEFINDER_MAXSONARHRLV: |
|
||||||
type_scaler = AP_RANGEFINDER_MAXSONARHRLV_SCALER; |
|
||||||
min_distance = AP_RANGEFINDER_MAXSONARHRLV_MIN_DISTANCE; |
|
||||||
max_distance = AP_RANGEFINDER_MAXSONARHRLV_MAX_DISTANCE; |
|
||||||
break; |
|
||||||
} |
|
||||||
_scaler = type_scaler * adc_refence_voltage / 5.0f; |
|
||||||
return _scaler; |
|
||||||
} |
|
||||||
|
|
||||||
#endif |
|
@ -1,42 +0,0 @@ |
|||||||
#ifndef __AP_RangeFinder_MaxsonarXL_H__ |
|
||||||
#define __AP_RangeFinder_MaxsonarXL_H__ |
|
||||||
|
|
||||||
#include "RangeFinder.h" |
|
||||||
|
|
||||||
// XL-EZ0 (aka XL)
|
|
||||||
#define AP_RANGEFINDER_MAXSONARXL 0 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXL_SCALER 1.0 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXL_MIN_DISTANCE 20 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXL_MAX_DISTANCE 765 |
|
||||||
|
|
||||||
// LV-EZ0 (aka LV)
|
|
||||||
#define AP_RANGEFINDER_MAXSONARLV 1 |
|
||||||
#define AP_RANGEFINDER_MAXSONARLV_SCALER (2.54/2.0) |
|
||||||
#define AP_RANGEFINDER_MAXSONARLV_MIN_DISTANCE 15 |
|
||||||
#define AP_RANGEFINDER_MAXSONARLV_MAX_DISTANCE 645 |
|
||||||
|
|
||||||
// XL-EZL0 (aka XLL)
|
|
||||||
#define AP_RANGEFINDER_MAXSONARXLL 2 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXLL_SCALER 2.0 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXLL_MIN_DISTANCE 20 |
|
||||||
#define AP_RANGEFINDER_MAXSONARXLL_MAX_DISTANCE 1068 |
|
||||||
|
|
||||||
// HRLV-MaxSonar-EZ0 (aka HRLV)
|
|
||||||
#define AP_RANGEFINDER_MAXSONARHRLV 3 |
|
||||||
#define AP_RANGEFINDER_MAXSONARHRLV_SCALER 0.512 |
|
||||||
#define AP_RANGEFINDER_MAXSONARHRLV_MIN_DISTANCE 30 |
|
||||||
#define AP_RANGEFINDER_MAXSONARHRLV_MAX_DISTANCE 500 |
|
||||||
|
|
||||||
class AP_RangeFinder_MaxsonarXL : public RangeFinder |
|
||||||
{ |
|
||||||
public: |
|
||||||
AP_RangeFinder_MaxsonarXL(AP_HAL::AnalogSource *source, FilterInt16 *filter); |
|
||||||
int16_t convert_raw_to_distance(int16_t raw_value) { |
|
||||||
return raw_value * _scaler; |
|
||||||
} // read value from analog port and return distance in cm
|
|
||||||
float calculate_scaler(int16_t sonar_type, float adc_refence_voltage); |
|
||||||
|
|
||||||
private: |
|
||||||
float _scaler; // used to account for different sonar types
|
|
||||||
}; |
|
||||||
#endif |
|
@ -1,51 +0,0 @@ |
|||||||
#if 0 |
|
||||||
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
||||||
/*
|
|
||||||
This program is free software: you can redistribute it and/or modify |
|
||||||
it under the terms of the GNU General Public License as published by |
|
||||||
the Free Software Foundation, either version 3 of the License, or |
|
||||||
(at your option) any later version. |
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, |
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
GNU General Public License for more details. |
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License |
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
|
|
||||||
/*
|
|
||||||
* AP_RangeFinder_SharpGP2Y.cpp - Arduino Library for Sharpe GP2Y0A02YK0F |
|
||||||
* infrared proximity sensor |
|
||||||
* Code by Jose Julio and Randy Mackay. DIYDrones.com |
|
||||||
* |
|
||||||
* Sensor should be conected to one of the analog ports |
|
||||||
* |
|
||||||
* Sparkfun URL: http://www.sparkfun.com/products/8958
|
|
||||||
* datasheet: http://www.sparkfun.com/datasheets/Sensors/Infrared/gp2y0a02yk_e.pdf
|
|
||||||
* |
|
||||||
* Variables: |
|
||||||
* int raw_value : raw value from the sensor |
|
||||||
* int distance : distance in cm |
|
||||||
* int max_distance : maximum measurable distance (in cm) |
|
||||||
* int min_distance : minimum measurable distance (in cm) |
|
||||||
* |
|
||||||
* Methods: |
|
||||||
* read() : read value from analog port |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
#include "AP_RangeFinder_SharpGP2Y.h" |
|
||||||
|
|
||||||
// Constructor //////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
AP_RangeFinder_SharpGP2Y::AP_RangeFinder_SharpGP2Y(AP_HAL::AnalogSource *source, FilterInt16 *filter) : |
|
||||||
RangeFinder(source, filter) |
|
||||||
{ |
|
||||||
max_distance = AP_RANGEFINDER_SHARPEGP2Y_MAX_DISTANCE; |
|
||||||
min_distance = AP_RANGEFINDER_SHARPEGP2Y_MIN_DISTANCE; |
|
||||||
} |
|
||||||
|
|
||||||
// Public Methods //////////////////////////////////////////////////////////////
|
|
||||||
#endif |
|
@ -1,22 +0,0 @@ |
|||||||
#ifndef __AP_RangeFinder_SharpGP2Y_H__ |
|
||||||
#define __AP_RangeFinder_SharpGP2Y_H__ |
|
||||||
|
|
||||||
#include "RangeFinder.h" |
|
||||||
|
|
||||||
#define AP_RANGEFINDER_SHARPEGP2Y_MIN_DISTANCE 20 |
|
||||||
#define AP_RANGEFINDER_SHARPEGP2Y_MAX_DISTANCE 150 |
|
||||||
|
|
||||||
class AP_RangeFinder_SharpGP2Y : public RangeFinder |
|
||||||
{ |
|
||||||
public: |
|
||||||
AP_RangeFinder_SharpGP2Y(AP_HAL::AnalogSource *source, FilterInt16 *filter); |
|
||||||
int16_t convert_raw_to_distance(int16_t raw_value) { |
|
||||||
if (raw_value == 0) { |
|
||||||
return max_distance; |
|
||||||
} else { |
|
||||||
return 14500/raw_value; |
|
||||||
} |
|
||||||
} // read value from analog port and return distance in cm
|
|
||||||
|
|
||||||
}; |
|
||||||
#endif |
|
@ -1,14 +0,0 @@ |
|||||||
RangeFinder KEYWORD1 |
|
||||||
AP_RangeFinder KEYWORD1 |
|
||||||
AP_RangeFinder_SharpGP2Y KEYWORD1 |
|
||||||
AP_RangeFinder_MaxsonarXL KEYWORD1 |
|
||||||
read KEYWORD2 |
|
||||||
set_orientation KEYWORD2 |
|
||||||
convert_raw_to_distance KEYWORD2 |
|
||||||
raw_value KEYWORD2 |
|
||||||
distance KEYWORD2 |
|
||||||
max_distance KEYWORD2 |
|
||||||
min_distance KEYWORD2 |
|
||||||
orientation_x KEYWORD2 |
|
||||||
orientation_y KEYWORD2 |
|
||||||
orientation_z KEYWORD2 |
|
Loading…
Reference in new issue