mirror of
https://github.com/eclipse/upm.git
synced 2025-07-26 21:51:16 +03:00
Added iGyroscope interface
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
34bb12933d
commit
aa966946d5
@ -2,4 +2,5 @@ set (libname "adxrs610")
|
||||
set (libdescription "Gyro Breakout Board (300 Degrees/second)")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iGyroscope.hpp iTemperature.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -97,3 +97,24 @@ float ADXRS610::getAngularVelocity()
|
||||
else
|
||||
return -((m_zeroPoint - dataV) / m_degreeCoeff);
|
||||
}
|
||||
|
||||
std::vector<float> ADXRS610::getGyroscope()
|
||||
{
|
||||
float dataV = getDataVolts();
|
||||
|
||||
// check the deadband
|
||||
if (dataV < (m_zeroPoint + m_deadband) &&
|
||||
dataV > (m_zeroPoint - m_deadband))
|
||||
return std::vector<float>{0 ,0 ,0};
|
||||
|
||||
if (dataV > m_zeroPoint)
|
||||
{
|
||||
float v = ((dataV - m_zeroPoint) / m_degreeCoeff);
|
||||
return std::vector<float>{0 ,0 , v};
|
||||
}
|
||||
else
|
||||
{
|
||||
float v = -((m_zeroPoint - dataV) / m_degreeCoeff);
|
||||
return std::vector<float>{0 ,0 , v};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include <string>
|
||||
#include <mraa/aio.hpp>
|
||||
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
// volts per degree / second (typ)
|
||||
#define m_degreeCoeff 0.006
|
||||
|
||||
@ -69,7 +72,7 @@ namespace upm {
|
||||
* @snippet adxrs610.cxx Interesting
|
||||
*/
|
||||
|
||||
class ADXRS610 {
|
||||
class ADXRS610: virtual public iGyroscope, virtual public iTemperature {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -84,7 +87,7 @@ namespace upm {
|
||||
/**
|
||||
* ADXRS610 destructor
|
||||
*/
|
||||
~ADXRS610();
|
||||
virtual ~ADXRS610();
|
||||
|
||||
/**
|
||||
* Returns the voltage detected on the DATA analog pin
|
||||
@ -153,6 +156,16 @@ namespace upm {
|
||||
*/
|
||||
float getAngularVelocity();
|
||||
|
||||
/**
|
||||
* Return gyroscope data in degrees per second in the form of
|
||||
* a floating point vector. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
std::vector<float> getGyroscope();
|
||||
|
||||
protected:
|
||||
mraa::Aio m_aioData;
|
||||
mraa::Aio m_aioTemp;
|
||||
|
Reference in New Issue
Block a user