upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bno055.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016-2017 Intel Corporation.
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 #pragma once
27 
28 #include <vector>
29 #include "bno055.h"
30 
31 namespace upm {
32 
103  class BNO055 {
104 
105  public:
122  BNO055(int bus=BNO055_DEFAULT_I2C_BUS,
123  uint8_t addr=BNO055_DEFAULT_ADDR);
124 
128  virtual ~BNO055();
129 
135  void update();
136 
143  uint8_t getChipID();
144 
151  uint8_t getACCID();
152 
159  uint8_t getMAGID();
160 
167  uint8_t getGYRID();
168 
175  uint16_t getSWRevID();
176 
183  uint8_t getBootLoaderID();
184 
193  void setClockExternal(bool extClock);
194 
203  void setTemperatureSource(BNO055_TEMP_SOURCES_T src);
204 
215  void setOperationMode(BNO055_OPERATION_MODES_T mode);
216 
223  void resetSystem();
224 
235  void getCalibrationStatus(int *mag, int *acc, int *gyr, int *sys);
236 
246  std::vector<int> getCalibrationStatus();
247 
256  bool isFullyCalibrated();
257 
270  std::vector<uint8_t> readCalibrationData();
271 
282  void writeCalibrationData(std::vector<uint8_t> calibrationData);
283 
294  float getTemperature(bool fahrenheit=false);
295 
308  void getEulerAngles(float *heading, float *roll, float *pitch);
309 
319  std::vector<float> getEulerAngles();
320 
335  void getQuaternions(float *w, float *x, float *y, float *z);
336 
345  std::vector<float> getQuaternions();
346 
360  void getLinearAcceleration(float *x, float *y, float *z);
361 
370  std::vector<float> getLinearAcceleration();
371 
385  void getGravityVectors(float *x, float *y, float *z);
386 
395  std::vector<float> getGravityVectors();
396 
410  void getAccelerometer(float *x, float *y, float *z);
411 
421  std::vector<float> getAccelerometer();
422 
436  void getMagnetometer(float *x, float *y, float *z);
437 
447  std::vector<float> getMagnetometer();
448 
462  void getGyroscope(float *x, float *y, float *z);
463 
473  std::vector<float> getGyroscope();
474 
484  void setAccelerationConfig(BNO055_ACC_RANGE_T range,
485  BNO055_ACC_BW_T bw,
486  BNO055_ACC_PWR_MODE_T pwr);
487 
497  void setMagnetometerConfig(BNO055_MAG_ODR_T odr,
498  BNO055_MAG_OPR_T opr,
499  BNO055_MAG_POWER_T pwr);
500 
510  void setGyroscopeConfig(BNO055_GYR_RANGE_T range,
511  BNO055_GYR_BW_T bw,
512  BNO055_GYR_POWER_MODE_T pwr);
513 
522  void setAccelerometerUnits(bool mg=false);
523 
532  void setGyroscopeUnits(bool radians=false);
533 
542  void setEulerUnits(bool radians=false);
543 
549  void resetInterruptStatus();
550 
558  uint8_t getInterruptStatus();
559 
568  uint8_t getInterruptEnable();
569 
577  void setInterruptEnable(uint8_t enables);
578 
590  uint8_t getInterruptMask();
591 
603  void setInterruptMask(uint8_t mask);
604 
612  BNO055_SYS_STATUS_T getSystemStatus();
613 
622  BNO055_SYS_ERR_T getSystemError();
623 
624 
636  void installISR(int gpio, mraa_gpio_edge_t level,
637  void (*isr)(void *), void *arg);
638 
643  void uninstallISR();
644 
645  protected:
646  bno055_context m_bno055;
647 
659  void setPage(uint8_t page, bool force=false);
660 
668  uint8_t readReg(uint8_t reg);
669 
677  void readRegs(uint8_t reg, uint8_t *buffer, int len);
678 
686  void writeReg(uint8_t reg, uint8_t val);
687 
696  void writeRegs(uint8_t reg, uint8_t *buffer, int len);
697 
698  private:
699  /* Disable implicit copy and assignment operators */
700  BNO055(const BNO055&) = delete;
701  BNO055 &operator=(const BNO055&) = delete;
702 
703  };
704 }
void resetSystem()
Definition: bno055.cxx:222
uint8_t getInterruptStatus()
Definition: bno055.cxx:236
void setAccelerationConfig(BNO055_ACC_RANGE_T range, BNO055_ACC_BW_T bw, BNO055_ACC_PWR_MODE_T pwr)
Definition: bno055.cxx:415
void setMagnetometerConfig(BNO055_MAG_ODR_T odr, BNO055_MAG_OPR_T opr, BNO055_MAG_POWER_T pwr)
Definition: bno055.cxx:424
void writeRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: bno055.cxx:86
void writeCalibrationData(std::vector< uint8_t > calibrationData)
Definition: bno055.cxx:313
void writeReg(uint8_t reg, uint8_t val)
Definition: bno055.cxx:79
uint8_t getInterruptEnable()
Definition: bno055.cxx:246
std::vector< float > getQuaternions()
Definition: bno055.cxx:348
BNO055_SYS_STATUS_T getSystemStatus()
Definition: bno055.cxx:280
uint8_t readReg(uint8_t reg)
Definition: bno055.cxx:62
void setClockExternal(bool extClock)
Definition: bno055.cxx:160
void readRegs(uint8_t reg, uint8_t *buffer, int len)
Definition: bno055.cxx:72
BNO055_SYS_ERR_T getSystemError()
Definition: bno055.cxx:290
uint8_t getACCID()
Definition: bno055.cxx:103
std::vector< float > getGravityVectors()
Definition: bno055.cxx:372
void setGyroscopeConfig(BNO055_GYR_RANGE_T range, BNO055_GYR_BW_T bw, BNO055_GYR_POWER_MODE_T pwr)
Definition: bno055.cxx:433
std::vector< uint8_t > readCalibrationData()
Definition: bno055.cxx:300
uint8_t getInterruptMask()
Definition: bno055.cxx:263
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
uint8_t getGYRID()
Definition: bno055.cxx:123
uint16_t getSWRevID()
Definition: bno055.cxx:133
std::vector< float > getGyroscope()
Definition: bno055.cxx:408
void uninstallISR()
Definition: bno055.cxx:450
std::vector< float > getLinearAcceleration()
Definition: bno055.cxx:360
bool isFullyCalibrated()
Definition: bno055.cxx:217
void setPage(uint8_t page, bool force=false)
Definition: bno055.cxx:153
void setInterruptEnable(uint8_t enables)
Definition: bno055.cxx:256
BNO055(int bus=BNO055_DEFAULT_I2C_BUS, uint8_t addr=BNO055_DEFAULT_ADDR)
Definition: bno055.cxx:42
void setInterruptMask(uint8_t mask)
Definition: bno055.cxx:273
Definition: bno055.h:53
uint8_t getBootLoaderID()
Definition: bno055.cxx:143
void setTemperatureSource(BNO055_TEMP_SOURCES_T src)
Definition: bno055.cxx:167
void resetInterruptStatus()
Definition: bno055.cxx:229
std::vector< float > getMagnetometer()
Definition: bno055.cxx:396
void setEulerUnits(bool radians=false)
Definition: bno055.cxx:188
void setAccelerometerUnits(bool mg=false)
Definition: bno055.cxx:174
uint8_t getChipID()
Definition: bno055.cxx:93
API for the BNO055 Absolute Orientation 9DOF Fusion Hub.
Definition: bno055.hpp:103
void setOperationMode(BNO055_OPERATION_MODES_T mode)
Definition: bno055.cxx:195
void setGyroscopeUnits(bool radians=false)
Definition: bno055.cxx:181
void update()
Definition: bno055.cxx:55
std::vector< int > getCalibrationStatus()
Definition: bno055.cxx:209
float getTemperature(bool fahrenheit=false)
Definition: bno055.cxx:321
void installISR(int gpio, mraa_gpio_edge_t level, void(*isr)(void *), void *arg)
Definition: bno055.cxx:442
std::vector< float > getEulerAngles()
Definition: bno055.cxx:336
C API for the bno055 driver.
virtual ~BNO055()
Definition: bno055.cxx:50
std::vector< float > getAccelerometer()
Definition: bno055.cxx:384
uint8_t getMAGID()
Definition: bno055.cxx:113