Modified all iDistance sensors to return float.

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
Serban Waltter 2018-06-27 14:28:00 +03:00
parent 9653ef27b8
commit 39515cb8ee
15 changed files with 17 additions and 17 deletions

View File

@ -36,7 +36,7 @@ namespace upm
{ {
public: public:
virtual ~iDistance() {} virtual ~iDistance() {}
virtual int getDistance() = 0; virtual float getDistance() = 0;
/** /**
* Convert distance value from Cm(default) to one * Convert distance value from Cm(default) to one
* of the following: * of the following:

View File

@ -55,7 +55,7 @@ GroveUltraSonic::~GroveUltraSonic () {
mraa_gpio_close (m_pinCtx); mraa_gpio_close (m_pinCtx);
} }
int float
GroveUltraSonic::getDistance () { GroveUltraSonic::getDistance () {
// output trigger signal // output trigger signal

View File

@ -81,7 +81,7 @@ class GroveUltraSonic {
* Divide by 58 to convert distance to centimetres. * Divide by 58 to convert distance to centimetres.
* Divide by 148 to convert distance to inches. * Divide by 148 to convert distance to inches.
*/ */
int getDistance (); float getDistance ();
/** /**
* Return name of the component * Return name of the component

View File

@ -50,7 +50,7 @@ HCSR04::getDistance(HCSR04_U unit)
return hcsr04_get_distance(m_hcsr04, unit); return hcsr04_get_distance(m_hcsr04, unit);
} }
int float
HCSR04::getDistance() HCSR04::getDistance()
{ {
return getDistance(HCSR04_CM); return getDistance(HCSR04_CM);

View File

@ -76,7 +76,7 @@ class HCSR04 : virtual public iDistance {
* *
* @return distance measured in cm. * @return distance measured in cm.
*/ */
virtual int getDistance(); float getDistance();
private: private:
hcsr04_context m_hcsr04; hcsr04_context m_hcsr04;
HCSR04(const HCSR04& src) { /* do not create copied constructor */ } HCSR04(const HCSR04& src) { /* do not create copied constructor */ }

View File

@ -46,7 +46,7 @@ LIDARLITEV3::LIDARLITEV3 (int bus, int devAddr) : m_i2ControlCtx(bus) {
} }
} }
int float
LIDARLITEV3::getDistance () { LIDARLITEV3::getDistance () {
if(i2cWriteReg(ACQ_COMMAND, 0x04) < 0) if(i2cWriteReg(ACQ_COMMAND, 0x04) < 0)

View File

@ -110,7 +110,7 @@ class LIDARLITEV3 : virtual public iDistance {
* Returns distance measurement on success * Returns distance measurement on success
* Retruns -1 on failure. * Retruns -1 on failure.
*/ */
virtual int getDistance (); virtual float getDistance ();
/** /**
* Read * Read

View File

@ -63,7 +63,7 @@ int MAXSONAREZ::inches()
return int(volts / m_vI); return int(volts / m_vI);
} }
int MAXSONAREZ::getDistance() float MAXSONAREZ::getDistance()
{ {
return (inches() * 2.54); return inches() * 2.54;
} }

View File

@ -96,7 +96,7 @@ namespace upm {
* *
* @return Distance to the object in inches * @return Distance to the object in inches
*/ */
virtual int getDistance(); virtual float getDistance();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;

View File

@ -48,7 +48,7 @@ int MB704X::getRange()
return mb704x_get_range(m_mb704x); return mb704x_get_range(m_mb704x);
} }
int MB704X::getDistance() float MB704X::getDistance()
{ {
return getRange(); return getRange();
} }

View File

@ -90,7 +90,7 @@ namespace upm {
* *
* @return Distance to the object in cm * @return Distance to the object in cm
*/ */
virtual int getDistance(); virtual float getDistance();
protected: protected:
// mb704x device context // mb704x device context
mb704x_context m_mb704x; mb704x_context m_mb704x;

View File

@ -55,7 +55,7 @@ UltraSonic::~UltraSonic () {
mraa_gpio_close (m_pinCtx); mraa_gpio_close (m_pinCtx);
} }
int float
UltraSonic::getDistance () { UltraSonic::getDistance () {
// output trigger signal // output trigger signal

View File

@ -80,7 +80,7 @@ class UltraSonic {
* Divide by 58 to convert distance to centimetres. * Divide by 58 to convert distance to centimetres.
* Divide by 148 to convert distance to inches. * Divide by 148 to convert distance to inches.
*/ */
int getDistance (); float getDistance ();
/** /**
* Return name of the component * Return name of the component
@ -93,7 +93,7 @@ class UltraSonic {
/** /**
* Returns true while the sensor is busy waiting for the echo pulse * Returns true while the sensor is busy waiting for the echo pulse
*/ */
bool working() float working()
{ {
return m_doWork; return m_doWork;
} }

View File

@ -67,7 +67,7 @@ float URM37::getDistance(int degrees)
return (distance); return (distance);
} }
int URM37::getDistance() float URM37::getDistance()
{ {
/* TODO: compilation issue for swig. switched original method to not use default zero parameter. */ /* TODO: compilation issue for swig. switched original method to not use default zero parameter. */
return getDistance(0); return getDistance(0);

View File

@ -129,7 +129,7 @@ namespace upm {
* *
* @return The measured distance in cm * @return The measured distance in cm
*/ */
virtual int getDistance(); virtual float getDistance();
/** /**
* Get the temperature measurement. This is only valid in UART mode. * Get the temperature measurement. This is only valid in UART mode.