Skip to content

added gravity vector validated with BNO085 #40

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

Merged
merged 1 commit into from
Apr 20, 2023
Merged
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
23 changes: 14 additions & 9 deletions adafruit_bno08x/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
BNO_REPORT_LINEAR_ACCELERATION = const(0x04)
# Rotation Vector
BNO_REPORT_ROTATION_VECTOR = const(0x05)
# Gravity Vector (m/s2). Vector direction of gravity
BNO_REPORT_GRAVITY = const(0x06)
# Game Rotation Vector
BNO_REPORT_GAME_ROTATION_VECTOR = const(0x08)

BNO_REPORT_GEOMAGNETIC_ROTATION_VECTOR = const(0x09)
Expand Down Expand Up @@ -139,6 +142,7 @@
}
_AVAIL_SENSOR_REPORTS = {
BNO_REPORT_ACCELEROMETER: (_Q_POINT_8_SCALAR, 3, 10),
BNO_REPORT_GRAVITY: (_Q_POINT_8_SCALAR, 3, 10),
BNO_REPORT_GYROSCOPE: (_Q_POINT_9_SCALAR, 3, 10),
BNO_REPORT_MAGNETOMETER: (_Q_POINT_4_SCALAR, 3, 10),
BNO_REPORT_LINEAR_ACCELERATION: (_Q_POINT_8_SCALAR, 3, 10),
Expand Down Expand Up @@ -370,15 +374,6 @@ def _separate_batch(packet, report_slices):
next_byte_index = next_byte_index + required_bytes


# class Report:
# _buffer = bytearray(DATA_BUFFER_SIZE)
# _report_obj = Report(_buffer)

# @classmethod
# def get_report(cls)
# return cls._report_obj


class Packet:
"""A class representing a Hillcrest LaboratorySensor Hub Transport packet"""

Expand Down Expand Up @@ -597,6 +592,16 @@ def acceleration(self):
except KeyError:
raise RuntimeError("No accel report found, is it enabled?") from None

@property
def gravity(self):
"""A tuple representing the gravity vector in the X, Y, and Z components
axes in meters per second squared"""
self._process_available_packets()
try:
return self._readings[BNO_REPORT_GRAVITY]
except KeyError:
raise RuntimeError("No gravity report found, is it enabled?") from None

@property
def gyro(self):
"""A tuple representing Gyro's rotation measurements on the X, Y, and Z
Expand Down