Skip to content

Commit 4a601ae

Browse files
authored
Merge pull request #76 from ViennaMike/fix_fusion_modes
Fix fusion modes
2 parents e7dc35e + dd0b9e7 commit 4a601ae

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

adafruit_bno055.py

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -186,37 +186,38 @@ def _reset(self):
186186
@property
187187
def mode(self):
188188
"""
189-
legend: x=on, -=off
190-
191-
+------------------+-------+---------+------+----------+
192-
| Mode | Accel | Compass | Gyro | Absolute |
193-
+==================+=======+=========+======+==========+
194-
| CONFIG_MODE | - | - | - | - |
195-
+------------------+-------+---------+------+----------+
196-
| ACCONLY_MODE | X | - | - | - |
197-
+------------------+-------+---------+------+----------+
198-
| MAGONLY_MODE | - | X | - | - |
199-
+------------------+-------+---------+------+----------+
200-
| GYRONLY_MODE | - | - | X | - |
201-
+------------------+-------+---------+------+----------+
202-
| ACCMAG_MODE | X | X | - | - |
203-
+------------------+-------+---------+------+----------+
204-
| ACCGYRO_MODE | X | - | X | - |
205-
+------------------+-------+---------+------+----------+
206-
| MAGGYRO_MODE | - | X | X | - |
207-
+------------------+-------+---------+------+----------+
208-
| AMG_MODE | X | X | X | - |
209-
+------------------+-------+---------+------+----------+
210-
| IMUPLUS_MODE | X | - | X | - |
211-
+------------------+-------+---------+------+----------+
212-
| COMPASS_MODE | X | X | - | X |
213-
+------------------+-------+---------+------+----------+
214-
| M4G_MODE | X | X | - | - |
215-
+------------------+-------+---------+------+----------+
216-
| NDOF_FMC_OFF_MODE| X | X | X | X |
217-
+------------------+-------+---------+------+----------+
218-
| NDOF_MODE | X | X | X | X |
219-
+------------------+-------+---------+------+----------+
189+
legend: x=on, -=off (see Table 3-3 in datasheet)
190+
191+
+------------------+-------+---------+------+----------+----------+
192+
| Mode | Accel | Compass | Gyro | Fusion | Fusion |
193+
| | | (Mag) | | Absolute | Relative |
194+
+==================+=======+=========+======+==========+==========+
195+
| CONFIG_MODE | - | - | - | - | - |
196+
+------------------+-------+---------+------+----------+----------+
197+
| ACCONLY_MODE | X | - | - | - | - |
198+
+------------------+-------+---------+------+----------+----------+
199+
| MAGONLY_MODE | - | X | - | - | - |
200+
+------------------+-------+---------+------+----------+----------+
201+
| GYRONLY_MODE | - | - | X | - | - |
202+
+------------------+-------+---------+------+----------+----------+
203+
| ACCMAG_MODE | X | X | - | - | - |
204+
+------------------+-------+---------+------+----------+----------+
205+
| ACCGYRO_MODE | X | - | X | - | - |
206+
+------------------+-------+---------+------+----------+----------+
207+
| MAGGYRO_MODE | - | X | X | - | - |
208+
+------------------+-------+---------+------+----------+----------+
209+
| AMG_MODE | X | X | X | - | - |
210+
+------------------+-------+---------+------+----------+----------+
211+
| IMUPLUS_MODE | X | - | X | - | X |
212+
+------------------+-------+---------+------+----------+----------+
213+
| COMPASS_MODE | X | X | - | X | - |
214+
+------------------+-------+---------+------+----------+----------+
215+
| M4G_MODE | X | X | - | - | X |
216+
+------------------+-------+---------+------+----------+----------+
217+
| NDOF_FMC_OFF_MODE| X | X | X | X | - |
218+
+------------------+-------+---------+------+----------+----------+
219+
| NDOF_MODE | X | X | X | X | - |
220+
+------------------+-------+---------+------+----------+----------+
220221
221222
The default mode is ``NDOF_MODE``.
222223
@@ -362,7 +363,7 @@ def magnetic(self):
362363
"""Gives the raw magnetometer readings in microteslas.
363364
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
364365
"""
365-
if self.mode not in [0x00, 0x03, 0x05, 0x08]:
366+
if self.mode not in [0x00, 0x01, 0x03, 0x05, 0x08]:
366367
return self._magnetic
367368
return (None, None, None)
368369

@@ -388,7 +389,7 @@ def euler(self):
388389
"""Gives the calculated orientation angles, in degrees.
389390
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
390391
"""
391-
if self.mode in [0x09, 0x0B, 0x0C]:
392+
if self.mode in [0x08, 0x09, 0x0A, 0x0B, 0x0C]:
392393
return self._euler
393394
return (None, None, None)
394395

@@ -401,7 +402,7 @@ def quaternion(self):
401402
"""Gives the calculated orientation as a quaternion.
402403
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
403404
"""
404-
if self.mode in [0x09, 0x0B, 0x0C]:
405+
if self.mode in [0x08, 0x09, 0x0A, 0x0B, 0x0C]:
405406
return self._quaternion
406407
return (None, None, None, None)
407408

@@ -414,7 +415,7 @@ def linear_acceleration(self):
414415
"""Returns the linear acceleration, without gravity, in m/s.
415416
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
416417
"""
417-
if self.mode in [0x09, 0x0B, 0x0C]:
418+
if self.mode in [0x08, 0x09, 0x0A, 0x0B, 0x0C]:
418419
return self._linear_acceleration
419420
return (None, None, None)
420421

@@ -427,7 +428,7 @@ def gravity(self):
427428
"""Returns the gravity vector, without acceleration in m/s.
428429
Returns an empty tuple of length 3 when this property has been disabled by the current mode.
429430
"""
430-
if self.mode in [0x09, 0x0B, 0x0C]:
431+
if self.mode in [0x08, 0x09, 0x0A, 0x0B, 0x0C]:
431432
return self._gravity
432433
return (None, None, None)
433434

@@ -713,37 +714,37 @@ def _temperature(self):
713714
@property
714715
def _acceleration(self):
715716
resp = struct.unpack("<hhh", self._read_register(0x08, 6))
716-
return tuple([x / 100 for x in resp])
717+
return tuple(x / 100 for x in resp)
717718

718719
@property
719720
def _magnetic(self):
720721
resp = struct.unpack("<hhh", self._read_register(0x0E, 6))
721-
return tuple([x / 16 for x in resp])
722+
return tuple(x / 16 for x in resp)
722723

723724
@property
724725
def _gyro(self):
725726
resp = struct.unpack("<hhh", self._read_register(0x14, 6))
726-
return tuple([x * 0.001090830782496456 for x in resp])
727+
return tuple(x * 0.001090830782496456 for x in resp)
727728

728729
@property
729730
def _euler(self):
730731
resp = struct.unpack("<hhh", self._read_register(0x1A, 6))
731-
return tuple([x / 16 for x in resp])
732+
return tuple(x / 16 for x in resp)
732733

733734
@property
734735
def _quaternion(self):
735736
resp = struct.unpack("<hhhh", self._read_register(0x20, 8))
736-
return tuple([x / (1 << 14) for x in resp])
737+
return tuple(x / (1 << 14) for x in resp)
737738

738739
@property
739740
def _linear_acceleration(self):
740741
resp = struct.unpack("<hhh", self._read_register(0x28, 6))
741-
return tuple([x / 100 for x in resp])
742+
return tuple(x / 100 for x in resp)
742743

743744
@property
744745
def _gravity(self):
745746
resp = struct.unpack("<hhh", self._read_register(0x2E, 6))
746-
return tuple([x / 100 for x in resp])
747+
return tuple(x / 100 for x in resp)
747748

748749
@property
749750
def offsets_accelerometer(self):

0 commit comments

Comments
 (0)