mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +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:
parent
34bb12933d
commit
aa966946d5
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
import upm_bmg160.BMG160;
|
||||
import upm_interfaces.*;
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
|
||||
|
@ -22,6 +22,9 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.AbstractList;
|
||||
import upm_interfaces.*;
|
||||
|
||||
import upm_bmi160.BMI160;
|
||||
|
||||
public class BMI160_Example
|
||||
@ -39,25 +42,25 @@ public class BMI160_Example
|
||||
// update our values from the sensor
|
||||
sensor.update();
|
||||
|
||||
float dataA[] = sensor.getAccelerometer();
|
||||
AbstractList<Float> dataA = sensor.getAcceleration();
|
||||
|
||||
System.out.println("Accelerometer: "
|
||||
+ "AX: "
|
||||
+ dataA[0]
|
||||
+ dataA.get(0)
|
||||
+ " AY: "
|
||||
+ dataA[1]
|
||||
+ dataA.get(1)
|
||||
+ " AZ: "
|
||||
+ dataA[2]);
|
||||
+ dataA.get(2));
|
||||
|
||||
float dataG[] = sensor.getGyroscope();
|
||||
AbstractList<Float> dataG = sensor.getGyroscope();
|
||||
|
||||
System.out.println("Gryoscope: "
|
||||
+ "GX: "
|
||||
+ dataG[0]
|
||||
+ dataG.get(0)
|
||||
+ " GY: "
|
||||
+ dataG[1]
|
||||
+ dataG.get(1)
|
||||
+ " GZ: "
|
||||
+ dataG[2]);
|
||||
+ dataG.get(2));
|
||||
|
||||
float dataM[] = sensor.getMagnetometer();
|
||||
|
||||
|
@ -79,7 +79,7 @@ add_example(BISS0001_Example "biss0001;interfaces")
|
||||
add_example(BMA250E_Example "bma250e;interfaces")
|
||||
add_example(BMC150_Example "bmx055;interfaces")
|
||||
add_example(BME280_Example "bmp280;interfaces")
|
||||
add_example(BMG160_Example bmg160)
|
||||
add_example(BMG160_Example "bmg160;interfaces")
|
||||
add_example(BMI055_Example "bmx055;interfaces")
|
||||
add_example(BMI160_Example "bmi160;interfaces")
|
||||
add_example(BMM150_Example bmm150)
|
||||
@ -139,7 +139,7 @@ add_example(Hmc5883l_Example hmc5883l)
|
||||
add_example(HMTRP_Example hmtrp)
|
||||
add_example(HP20x_Example "hp20x;interfaces")
|
||||
add_example(HTU21D_Example "htu21d;interfaces")
|
||||
add_example(Itg3200_Example itg3200)
|
||||
add_example(Itg3200_Example "itg3200;interfaces")
|
||||
add_example(Jhd1313m1_Example jhd1313m1)
|
||||
add_example(Jhd1313m1_lcd_Example jhd1313m1)
|
||||
add_example(Joystick12_Example joystick12)
|
||||
|
48
include/interfaces/iGyroscope.hpp
Normal file
48
include/interfaces/iGyroscope.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Author: Serban Waltter <serban.waltter@rinftech.com>
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace upm
|
||||
{
|
||||
/**
|
||||
* @brief Interface for acceleration sensors
|
||||
*/
|
||||
class iGyroscope
|
||||
{
|
||||
public:
|
||||
virtual ~iGyroscope() {}
|
||||
|
||||
/**
|
||||
* Return gyroscope data in degrees per second in the form of
|
||||
* a floating point vector.
|
||||
*
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order in degrees/second.
|
||||
*/
|
||||
virtual std::vector<float> getGyroscope() = 0;
|
||||
};
|
||||
} // upm
|
@ -9,6 +9,7 @@
|
||||
#include "iElectromagnet.hpp"
|
||||
#include "iEmg.hpp"
|
||||
#include "iGps.hpp"
|
||||
#include "iGyroscope.hpp"
|
||||
#include "iHallEffect.hpp"
|
||||
#include "iHeartRate.hpp"
|
||||
#include "iHumidity.hpp"
|
||||
|
@ -50,6 +50,7 @@ import java.lang.Float;
|
||||
%interface_impl (upm::iElectromagnet);
|
||||
%interface_impl (upm::iEmg);
|
||||
%interface_impl (upm::iGps);
|
||||
%interface_impl (upm::iGyroscope);
|
||||
%interface_impl (upm::iHallEffect);
|
||||
%interface_impl (upm::iHeartRate);
|
||||
%interface_impl (upm::iHumidity);
|
||||
@ -78,6 +79,7 @@ import java.lang.Float;
|
||||
#include "iElectromagnet.hpp"
|
||||
#include "iEmg.hpp"
|
||||
#include "iGps.hpp"
|
||||
#include "iGyroscope.hpp"
|
||||
#include "iHallEffect.hpp"
|
||||
#include "iHeartRate.hpp"
|
||||
#include "iHumidity.hpp"
|
||||
@ -105,6 +107,7 @@ import java.lang.Float;
|
||||
%include "iElectromagnet.hpp"
|
||||
%include "iEmg.hpp"
|
||||
%include "iGps.hpp"
|
||||
%include "iGyroscope.hpp"
|
||||
%include "iHallEffect.hpp"
|
||||
%include "iHeartRate.hpp"
|
||||
%include "iHumidity.hpp"
|
||||
|
@ -267,10 +267,13 @@ function (_get_current_dot_i_file filePrefix varDotIFile)
|
||||
list (FIND module_iface "iAcceleration.hpp" _index)
|
||||
if (${_index} GREATER -1)
|
||||
set(JAVA_TYPEMAPS "%typemap(javaimports) SWIGTYPE %{\nimport upm_interfaces.*;\n\nimport java.util.AbstractList;\nimport java.lang.Float;\n%}\n")
|
||||
list (FIND module_iface "iGyroscope.hpp" _index)
|
||||
elseif(${_index} GREATER -1)
|
||||
set(JAVA_TYPEMAPS "%typemap(javaimports) SWIGTYPE %{\nimport upm_interfaces.*;\n\nimport java.util.AbstractList;\nimport java.lang.Float;\n%}\n")
|
||||
endif()
|
||||
else()
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
if ("iAcceleration.hpp" IN_LIST module_iface)
|
||||
if (("iAcceleration.hpp" IN_LIST module_iface) OR ("iGyroscope.hpp" IN_LIST module_iface))
|
||||
set(JAVA_TYPEMAPS "%typemap(javaimports) SWIGTYPE %{\nimport upm_interfaces.*;\n\nimport java.util.AbstractList;\nimport java.lang.Float;\n%}\n")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -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;
|
||||
|
@ -5,5 +5,6 @@ upm_mixed_module_init (NAME bmg160
|
||||
CPP_HDR bmg160.hpp
|
||||
CPP_SRC bmg160.cxx
|
||||
FTI_SRC bmg160_fti.c
|
||||
IFACE_HDR iGyroscope.hpp
|
||||
CPP_WRAPS_C
|
||||
REQUIRES mraa utilities-c)
|
||||
|
@ -108,6 +108,7 @@ void BMG160::getGyroscope(float *x, float *y, float *z)
|
||||
|
||||
std::vector<float> BMG160::getGyroscope()
|
||||
{
|
||||
update();
|
||||
float v[3];
|
||||
|
||||
getGyroscope(&v[0], &v[1], &v[2]);
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <mraa/gpio.hpp>
|
||||
#include "bmg160.h"
|
||||
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
@ -71,7 +73,7 @@ namespace upm {
|
||||
* @snippet bmg160.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMG160 {
|
||||
class BMG160: virtual public iGyroscope {
|
||||
public:
|
||||
/**
|
||||
* BMG160 constructor.
|
||||
|
@ -1,26 +1,22 @@
|
||||
#ifdef SWIGPYTHON
|
||||
%module (package="upm") a110x
|
||||
#endif
|
||||
|
||||
%import "interfaces/interfaces.i"
|
||||
|
||||
%include "../common_top.i"
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%include "../upm_javastdvector.i"
|
||||
|
||||
%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *);
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
|
||||
%typemap(javaimports) SWIGTYPE %{
|
||||
import upm_interfaces.*;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
%}
|
||||
|
||||
%typemap(javaout) SWIGTYPE {
|
||||
return new $&javaclassname($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) std::vector<float> {
|
||||
return (AbstractList<Float>)(new $&javaclassname($jnicall, true));
|
||||
}
|
||||
%typemap(jstype) std::vector<float> "AbstractList<Float>"
|
||||
|
||||
%template(floatVector) std::vector<float>;
|
||||
%ignore installISR (BMG160_INTERRUPT_PINS_T , int mraa::Edge , void *, void *);
|
||||
%ignore getGyroscope(float *, float *, float *);
|
||||
|
||||
%define INTERRUPT BMG160_INTERRUPT_PINS_T
|
||||
%enddef
|
||||
|
@ -4,7 +4,7 @@ upm_mixed_module_init (NAME bmi160
|
||||
C_SRC bmi160.c bosch_bmi160.c
|
||||
CPP_HDR bmi160.hpp
|
||||
CPP_SRC bmi160.cxx
|
||||
IFACE_HDR iAcceleration.hpp
|
||||
IFACE_HDR iAcceleration.hpp iGyroscope.hpp
|
||||
# FTI_SRC bmi160_fti.c
|
||||
CPP_WRAPS_C
|
||||
REQUIRES mraa utilities-c)
|
||||
|
@ -92,13 +92,13 @@ std::vector<float> BMI160::getAcceleration()
|
||||
return v;
|
||||
}
|
||||
|
||||
float *BMI160::getGyroscope()
|
||||
std::vector<float> BMI160::getGyroscope()
|
||||
{
|
||||
static float values[3]; // x, y, and then z
|
||||
|
||||
getGyroscope(&values[0], &values[1], &values[2]);
|
||||
|
||||
return values;
|
||||
return std::vector<float>(values, values + 3);
|
||||
}
|
||||
|
||||
float *BMI160::getMagnetometer()
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "bmi160.h"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define BMI160_I2C_BUS 0
|
||||
#define BMI160_DEFAULT_I2C_ADDR 0x69
|
||||
@ -74,7 +75,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet bmi160.cxx Interesting
|
||||
*/
|
||||
class BMI160: virtual public iAcceleration {
|
||||
class BMI160: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -162,7 +163,7 @@ namespace upm {
|
||||
* @return Pointer to 3 floating point values: X, Y, and Z in
|
||||
* degrees per second.
|
||||
*/
|
||||
float *getGyroscope();
|
||||
virtual std::vector<float> getGyroscope();
|
||||
|
||||
/**
|
||||
* Get the Gyroscope values. The values returned are in degrees
|
||||
|
@ -2,5 +2,5 @@ upm_mixed_module_init (NAME bmx055
|
||||
DESCRIPTION "Bosch IMU Sensor Library"
|
||||
CPP_HDR bmx055.hpp bmc150.hpp bmi055.hpp
|
||||
CPP_SRC bmx055.cxx bmc150.cxx bmi055.cxx
|
||||
IFACE_HDR iAcceleration.hpp
|
||||
IFACE_HDR iAcceleration.hpp iGyroscope.hpp
|
||||
REQUIRES mraa bmg160 bma250e bmm150)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "bmg160.hpp"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -66,7 +67,7 @@ namespace upm {
|
||||
* @snippet bmx055-bmi055.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMI055: virtual public iAcceleration {
|
||||
class BMI055: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
/**
|
||||
* BMI055 constructor.
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "bmm150.hpp"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define BMX055_DEFAULT_MAG_I2C_ADDR 0x12
|
||||
|
||||
@ -78,7 +79,7 @@ namespace upm {
|
||||
* @snippet bmx055.cxx Interesting
|
||||
*/
|
||||
|
||||
class BMX055: virtual public iAcceleration {
|
||||
class BMX055: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
/**
|
||||
* BMX055 constructor.
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "bno055.h"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
|
@ -2,4 +2,5 @@ set (libname "itg3200")
|
||||
set (libdescription "3-axis Digital Gyroscope")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iGyroscope.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -114,6 +114,14 @@ Itg3200::getRotation()
|
||||
return &m_angle[0];
|
||||
}
|
||||
|
||||
std::vector<float> Itg3200::getGyroscope()
|
||||
{
|
||||
for(int i = 0; i < 3; i++){
|
||||
m_angle[i] = m_rotation[i]/14.375;
|
||||
}
|
||||
return std::vector<float>(m_angle, m_angle + 3);
|
||||
}
|
||||
|
||||
int16_t*
|
||||
Itg3200::getRawValues()
|
||||
{
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define READ_BUFFER_LENGTH 8
|
||||
|
||||
namespace upm {
|
||||
@ -56,7 +58,7 @@ namespace upm {
|
||||
* @image html itg3200.jpeg
|
||||
* @snippet itg3200.cxx Interesting
|
||||
*/
|
||||
class Itg3200 {
|
||||
class Itg3200: virtual public iGyroscope {
|
||||
public:
|
||||
/**
|
||||
* Creates an Itg3200 object
|
||||
@ -86,6 +88,16 @@ public:
|
||||
*/
|
||||
float* getRotation();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Returns a pointer to an int[3] that contains raw register values for X, Y, and Z
|
||||
*
|
||||
|
@ -1,7 +1,20 @@
|
||||
#ifdef SWIGPYTHON
|
||||
%module (package="upm") a110x
|
||||
#endif
|
||||
|
||||
%import "interfaces/interfaces.i"
|
||||
|
||||
%include "../common_top.i"
|
||||
|
||||
/* BEGIN Java syntax ------------------------------------------------------- */
|
||||
#ifdef SWIGJAVA
|
||||
%typemap(javaimports) SWIGTYPE %{
|
||||
import upm_interfaces.*;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.lang.Float;
|
||||
%}
|
||||
|
||||
%typemap(jni) float* "jfloatArray"
|
||||
%typemap(jstype) float* "float[]"
|
||||
%typemap(jtype) float* "float[]"
|
||||
|
@ -3,5 +3,6 @@ if (MRAA_IIO_FOUND)
|
||||
set (libdescription "Tri-axis Digital Gyroscope")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iGyroscope.hpp)
|
||||
upm_module_init(mraa)
|
||||
endif (MRAA_IIO_FOUND)
|
||||
|
@ -273,6 +273,16 @@ void L3GD20::getGyroscope(float *x, float *y, float *z)
|
||||
*z = m_gyrZ;
|
||||
}
|
||||
|
||||
std::vector<float> L3GD20::getGyroscope()
|
||||
{
|
||||
update();
|
||||
std::vector<float> values(3);
|
||||
values[0] = m_gyrX;
|
||||
values[1] = m_gyrY;
|
||||
values[2] = m_gyrZ;
|
||||
return values;
|
||||
}
|
||||
|
||||
void L3GD20::update()
|
||||
{
|
||||
int bufLen = 6;
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <mraa/iio.h>
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define L3GD20_DEFAULT_I2C_BUS 0
|
||||
// if SDO tied to GND
|
||||
#define L3GD20_DEFAULT_I2C_ADDR 0x6a
|
||||
@ -74,7 +76,7 @@ namespace upm
|
||||
* @snippet l3gd20-i2c.cxx Interesting
|
||||
*/
|
||||
|
||||
class L3GD20
|
||||
class L3GD20: virtual public iGyroscope
|
||||
{
|
||||
public:
|
||||
typedef struct {
|
||||
@ -479,6 +481,16 @@ class L3GD20
|
||||
*/
|
||||
void getGyroscope(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Set the power mode of the device. I2C only.
|
||||
*
|
||||
|
@ -5,6 +5,6 @@ upm_mixed_module_init (NAME lsm6ds3h
|
||||
CPP_HDR lsm6ds3h.hpp
|
||||
CPP_SRC lsm6ds3h.cxx
|
||||
FTI_SRC lsm6ds3h_fti.c
|
||||
IFACE_HDR iAcceleration.hpp
|
||||
IFACE_HDR iAcceleration.hpp iGyroscope.hpp
|
||||
CPP_WRAPS_C
|
||||
REQUIRES mraa utilities-c)
|
||||
|
@ -124,6 +124,7 @@ void LSM6DS3H::getGyroscope(float *x, float *y, float *z)
|
||||
|
||||
std::vector<float> LSM6DS3H::getGyroscope()
|
||||
{
|
||||
update();
|
||||
float v[3];
|
||||
|
||||
getGyroscope(&v[0], &v[1], &v[2]);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "lsm6ds3h.h"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -66,7 +67,7 @@ namespace upm {
|
||||
* @snippet lsm6ds3h.cxx Interesting
|
||||
*/
|
||||
|
||||
class LSM6DS3H: virtual public iAcceleration {
|
||||
class LSM6DS3H: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ upm_mixed_module_init (NAME lsm6dsl
|
||||
C_SRC lsm6dsl.c
|
||||
CPP_HDR lsm6dsl.hpp
|
||||
CPP_SRC lsm6dsl.cxx
|
||||
IFACE_HDR iAcceleration.hpp
|
||||
IFACE_HDR iAcceleration.hpp iGyroscope.hpp
|
||||
FTI_SRC lsm6dsl_fti.c
|
||||
CPP_WRAPS_C
|
||||
REQUIRES mraa utilities-c)
|
||||
|
@ -125,6 +125,7 @@ void LSM6DSL::getGyroscope(float *x, float *y, float *z)
|
||||
|
||||
std::vector<float> LSM6DSL::getGyroscope()
|
||||
{
|
||||
update();
|
||||
float v[3];
|
||||
|
||||
getGyroscope(&v[0], &v[1], &v[2]);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "lsm6dsl.h"
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -65,7 +66,7 @@ namespace upm {
|
||||
* @snippet lsm6dsl.cxx Interesting
|
||||
*/
|
||||
|
||||
class LSM6DSL: virtual public iAcceleration {
|
||||
class LSM6DSL: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -2,5 +2,5 @@ set (libname "lsm9ds0")
|
||||
set (libdescription "Triaxial Gyroscope/accelerometer/magnetometer Sensor")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iAcceleration.hpp)
|
||||
set (module_iface iAcceleration.hpp iGyroscope.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <mraa/gpio.hpp>
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define LSM9DS0_I2C_BUS 1
|
||||
#define LSM9DS0_DEFAULT_XM_ADDR 0x1d
|
||||
@ -79,7 +80,7 @@ namespace upm {
|
||||
* @snippet lsm9ds0.cxx Interesting
|
||||
*/
|
||||
|
||||
class LSM9DS0: virtual public iAcceleration {
|
||||
class LSM9DS0: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
|
||||
// NOTE: reserved registers must not be written into or permanent
|
||||
@ -1074,7 +1075,7 @@ namespace upm {
|
||||
/**
|
||||
* LSM9DS0 Destructor
|
||||
*/
|
||||
~LSM9DS0();
|
||||
virtual ~LSM9DS0();
|
||||
|
||||
/**
|
||||
* set up initial values and start operation
|
||||
|
@ -2,5 +2,5 @@ set (libname "mpu9150")
|
||||
set (libdescription "IMU Sensor Library Based On the Mpu9150")
|
||||
set (module_src ${libname}.cxx ak8975.cxx mpu60x0.cxx mpu9250.cxx)
|
||||
set (module_hpp ${libname}.hpp ak8975.hpp mpu60x0.hpp mpu9250.hpp)
|
||||
set (module_iface iAcceleration.hpp)
|
||||
set (module_iface iAcceleration.hpp iGyroscope.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -325,6 +325,13 @@ void MPU60X0::getGyroscope(float *x, float *y, float *z)
|
||||
*z = m_gyroZ / m_gyroScale;
|
||||
}
|
||||
|
||||
std::vector<float> MPU60X0::getGyroscope()
|
||||
{
|
||||
update();
|
||||
return std::vector<float> {m_gyroX / m_gyroScale, m_gyroY / m_gyroScale, m_gyroZ / m_gyroScale};
|
||||
}
|
||||
|
||||
|
||||
float MPU60X0::getTemperature()
|
||||
{
|
||||
// this equation is taken from the datasheet
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <mraa/gpio.hpp>
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define MPU60X0_I2C_BUS 0
|
||||
#define MPU60X0_DEFAULT_I2C_ADDR 0x68
|
||||
@ -62,7 +63,7 @@ namespace upm {
|
||||
* @image html mpu60x0.jpg
|
||||
* @snippet mpu9150-mpu60x0.cxx Interesting
|
||||
*/
|
||||
class MPU60X0: virtual public iAcceleration {
|
||||
class MPU60X0: virtual public iAcceleration, virtual public iGyroscope {
|
||||
public:
|
||||
|
||||
// NOTE: These enums were composed from both the mpu6050 and
|
||||
@ -811,6 +812,13 @@ namespace upm {
|
||||
*/
|
||||
void getGyroscope(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* get the gyroscope values in degrees per second
|
||||
*
|
||||
* @return std::vector containing X, Y, Z gyroscope values
|
||||
*/
|
||||
std::vector<float> getGyroscope();
|
||||
|
||||
/**
|
||||
* get the temperature value
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user