Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed imumath.h and other libraries, Just simple data structures #101

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ int8_t Adafruit_BNO055::getTemp() {
* VECTOR_GRAVITY]
* @return vector from specified source
*/
imu::Vector<3> Adafruit_BNO055::getVector(adafruit_vector_type_t vector_type) {
imu::Vector<3> xyz;
imu::Vector Adafruit_BNO055::getVector(adafruit_vector_type_t vector_type) {
imu::Vector xyz;
uint8_t buffer[6];
memset(buffer, 0, 6);

Expand All @@ -400,39 +400,39 @@ imu::Vector<3> Adafruit_BNO055::getVector(adafruit_vector_type_t vector_type) {
switch (vector_type) {
case VECTOR_MAGNETOMETER:
/* 1uT = 16 LSB */
xyz[0] = ((double)x) / 16.0;
xyz[1] = ((double)y) / 16.0;
xyz[2] = ((double)z) / 16.0;
xyz.x = ((double)x) / 16.0;
xyz.y = ((double)y) / 16.0;
xyz.z = ((double)z) / 16.0;
break;
case VECTOR_GYROSCOPE:
/* 1dps = 16 LSB */
xyz[0] = ((double)x) / 16.0;
xyz[1] = ((double)y) / 16.0;
xyz[2] = ((double)z) / 16.0;
xyz.x = ((double)x) / 16.0;
xyz.y = ((double)y) / 16.0;
xyz.z = ((double)z) / 16.0;
break;
case VECTOR_EULER:
/* 1 degree = 16 LSB */
xyz[0] = ((double)x) / 16.0;
xyz[1] = ((double)y) / 16.0;
xyz[2] = ((double)z) / 16.0;
xyz.x = ((double)x) / 16.0;
xyz.y = ((double)y) / 16.0;
xyz.z = ((double)z) / 16.0;
break;
case VECTOR_ACCELEROMETER:
/* 1m/s^2 = 100 LSB */
xyz[0] = ((double)x) / 100.0;
xyz[1] = ((double)y) / 100.0;
xyz[2] = ((double)z) / 100.0;
xyz.x = ((double)x) / 100.0;
xyz.y = ((double)y) / 100.0;
xyz.z = ((double)z) / 100.0;
break;
case VECTOR_LINEARACCEL:
/* 1m/s^2 = 100 LSB */
xyz[0] = ((double)x) / 100.0;
xyz[1] = ((double)y) / 100.0;
xyz[2] = ((double)z) / 100.0;
xyz.x = ((double)x) / 100.0;
xyz.y = ((double)y) / 100.0;
xyz.z = ((double)z) / 100.0;
break;
case VECTOR_GRAVITY:
/* 1m/s^2 = 100 LSB */
xyz[0] = ((double)x) / 100.0;
xyz[1] = ((double)y) / 100.0;
xyz[2] = ((double)z) / 100.0;
xyz.x = ((double)x) / 100.0;
xyz.y = ((double)y) / 100.0;
xyz.z = ((double)z) / 100.0;
break;
}

Expand Down Expand Up @@ -505,10 +505,10 @@ bool Adafruit_BNO055::getEvent(sensors_event_t *event) {
event->timestamp = millis();

/* Get a Euler angle sample for orientation */
imu::Vector<3> euler = getVector(Adafruit_BNO055::VECTOR_EULER);
event->orientation.x = euler.x();
event->orientation.y = euler.y();
event->orientation.z = euler.z();
imu::Vector euler = getVector(Adafruit_BNO055::VECTOR_EULER);
event->orientation.x = euler.x;
event->orientation.y = euler.y;
event->orientation.z = euler.z;

return true;
}
Expand All @@ -531,49 +531,49 @@ bool Adafruit_BNO055::getEvent(sensors_event_t *event,
event->timestamp = millis();

// read the data according to vec_type
imu::Vector<3> vec;
imu::Vector vec;
if (vec_type == Adafruit_BNO055::VECTOR_LINEARACCEL) {
event->type = SENSOR_TYPE_LINEAR_ACCELERATION;
vec = getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);

event->acceleration.x = vec.x();
event->acceleration.y = vec.y();
event->acceleration.z = vec.z();
event->acceleration.x = vec.x;
event->acceleration.y = vec.y;
event->acceleration.z = vec.z;
} else if (vec_type == Adafruit_BNO055::VECTOR_ACCELEROMETER) {
event->type = SENSOR_TYPE_ACCELEROMETER;
vec = getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);

event->acceleration.x = vec.x();
event->acceleration.y = vec.y();
event->acceleration.z = vec.z();
event->acceleration.x = vec.x;
event->acceleration.y = vec.y;
event->acceleration.z = vec.z;
} else if (vec_type == Adafruit_BNO055::VECTOR_GRAVITY) {
event->type = SENSOR_TYPE_ACCELEROMETER;
vec = getVector(Adafruit_BNO055::VECTOR_GRAVITY);

event->acceleration.x = vec.x();
event->acceleration.y = vec.y();
event->acceleration.z = vec.z();
event->acceleration.x = vec.x;
event->acceleration.y = vec.y;
event->acceleration.z = vec.z;
} else if (vec_type == Adafruit_BNO055::VECTOR_EULER) {
event->type = SENSOR_TYPE_ORIENTATION;
vec = getVector(Adafruit_BNO055::VECTOR_EULER);

event->orientation.x = vec.x();
event->orientation.y = vec.y();
event->orientation.z = vec.z();
event->orientation.x = vec.x;
event->orientation.y = vec.y;
event->orientation.z = vec.z;
} else if (vec_type == Adafruit_BNO055::VECTOR_GYROSCOPE) {
event->type = SENSOR_TYPE_ROTATION_VECTOR;
vec = getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);

event->gyro.x = vec.x();
event->gyro.y = vec.y();
event->gyro.z = vec.z();
event->gyro.x = vec.x;
event->gyro.y = vec.y;
event->gyro.z = vec.z;
} else if (vec_type == Adafruit_BNO055::VECTOR_MAGNETOMETER) {
event->type = SENSOR_TYPE_MAGNETIC_FIELD;
vec = getVector(Adafruit_BNO055::VECTOR_MAGNETOMETER);

event->magnetic.x = vec.x();
event->magnetic.y = vec.y();
event->magnetic.z = vec.z();
event->magnetic.x = vec.x;
event->magnetic.y = vec.y;
event->magnetic.z = vec.z;
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions Adafruit_BNO055.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "Arduino.h"
#include <Wire.h>

#include "utility/imumaths.h"
#include "imu.h"
#include <Adafruit_Sensor.h>

/** BNO055 Address A **/
Expand Down Expand Up @@ -294,7 +294,7 @@ class Adafruit_BNO055 : public Adafruit_Sensor {
void getCalibration(uint8_t *system, uint8_t *gyro, uint8_t *accel,
uint8_t *mag);

imu::Vector<3> getVector(adafruit_vector_type_t vector_type);
imu::Vector getVector(adafruit_vector_type_t vector_type);
imu::Quaternion getQuat();
int8_t getTemp();

Expand Down
5 changes: 2 additions & 3 deletions examples/bunny/bunny.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common 'type' for sensor data and some helper functions.
Expand Down Expand Up @@ -73,12 +72,12 @@ void setup(void)
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}

delay(1000);

/* Use external crystal for better accuracy */
bno.setExtCrystalUse(true);

/* Display some basic information on this sensor */
displaySensorDetails();
}
Expand Down
18 changes: 9 additions & 9 deletions examples/rawdata/rawdata.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver reads raw data from the BNO055

Expand All @@ -15,6 +14,7 @@
History
=======
2015/MAR/03 - First release (KTOWN)
2021/Jan/18 - Modified Vector code (Walchko)
*/

/* Set the delay between fresh samples */
Expand Down Expand Up @@ -71,28 +71,28 @@ void loop(void)
// - VECTOR_EULER - degrees
// - VECTOR_LINEARACCEL - m/s^2
// - VECTOR_GRAVITY - m/s^2
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
imu::Vector euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);

/* Display the floating point data */
Serial.print("X: ");
Serial.print(euler.x());
Serial.print(euler.x);
Serial.print(" Y: ");
Serial.print(euler.y());
Serial.print(euler.y);
Serial.print(" Z: ");
Serial.print(euler.z());
Serial.print(euler.z);
Serial.print("\t\t");

/*
// Quaternion data
imu::Quaternion quat = bno.getQuat();
Serial.print("qW: ");
Serial.print(quat.w(), 4);
Serial.print(quat.w, 4);
Serial.print(" qX: ");
Serial.print(quat.x(), 4);
Serial.print(quat.x, 4);
Serial.print(" qY: ");
Serial.print(quat.y(), 4);
Serial.print(quat.y, 4);
Serial.print(" qZ: ");
Serial.print(quat.z(), 4);
Serial.print(quat.z, 4);
Serial.print("\t\t");
*/

Expand Down
3 changes: 0 additions & 3 deletions examples/read_all_data/read_all_data.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common 'type' for sensor data and some helper functions.
Expand Down Expand Up @@ -138,5 +137,3 @@ void printEvent(sensors_event_t* event) {
Serial.print(" |\tz= ");
Serial.println(z);
}


1 change: 0 additions & 1 deletion examples/restore_offsets/restore_offsets.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <EEPROM.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
Expand Down
1 change: 0 additions & 1 deletion examples/sensorapi/sensorapi.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common 'type' for sensor data and some helper functions.
Expand Down
17 changes: 8 additions & 9 deletions examples/webserial_3d/webserial_3d.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* Returns the IMU data as both a euler angles and quaternions as the WebSerial
3D Model viewer at https://adafruit-3dmodel-viewer.glitch.me/ expects.

This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common 'type' for sensor data and some helper functions.

Expand Down Expand Up @@ -76,12 +75,12 @@ void setup(void)
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}

delay(1000);

/* Use external crystal for better accuracy */
bno.setExtCrystalUse(true);

/* Display some basic information on this sensor */
displaySensorDetails();
}
Expand Down Expand Up @@ -120,15 +119,15 @@ void loop(void)

/* The WebSerial 3D Model Viewer also expects data as roll, pitch, heading */
imu::Quaternion quat = bno.getQuat();

Serial.print(F("Quaternion: "));
Serial.print((float)quat.w());
Serial.print((float)quat.w);
Serial.print(F(", "));
Serial.print((float)quat.x());
Serial.print((float)quat.x);
Serial.print(F(", "));
Serial.print((float)quat.y());
Serial.print((float)quat.y);
Serial.print(F(", "));
Serial.print((float)quat.z());
Serial.print((float)quat.z);
Serial.println(F(""));

/* Also send calibration data for each sensor. */
Expand Down
Loading