BNO055 USB Stick Linux Python Driver
Project description
BNO055 USB Stick Python driver
TL;DR: "Swiss army knife" for using
BNO055 USB Stick
under Linux from python3.
BNO055 USB Stick comes with
Development Desktop 2.0
software package,
which is available for Windows only.
If you have a BNO055 USB Stick and want to
use it on a Linux platform
(e.g. Ubuntu, Raspbian, Yocto, Suse, etc.)
this repo provides you with a python 3 driver,
capable of reading / writing registers / burst read,
and stream data read.
OS Prerequisites
-
When plugged in on a Linux system, the
BNO055 USB Stickshould appear as/dev/ttyACM*device. This device is a so-calledcdc_acm(communication device class), but let us leave these details for now. -
Your Linux user must be a member of the
dialoutgroup (e.g. see this thread) to be able to read/writettyACM*devices without root privileges. -
udevis installed on the system. We do autodetect the USB stick by relying on information from udev.
Installation
pip install bno055_usb_stick_py
Supported Python version
python v3.6+
Python dependencies
TL;DR: install
(i) pyserial,
(ii) pyudev,
(iii) dataclasses (if using python3.6), and
(iv) optionally: pyquaternion
and matplotlib,
or use
environment.yml
to create conda environment
with dependencies resolved.
For further details regarding creating conda senvironment read this guide.
Quick start
Read BNO register:
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_addr = 0x00
reg_val = bno_usb_stick.read_register(reg_addr)
print(f"bno chip id addr: 0x{reg_addr:02X}, value: 0x{reg_val:02X}")
Write register:
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_addr = 0x3F
reg_value = 0x01
bno_usb_stick.write_register(reg_addr, reg_value)
print(f"bno self test started!")
Burst register read:
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_start_addr = 0x08
num_registers = 0x12
burst_read_result = bno_usb_stick.burst_read(reg_start_addr, num_registers)
print(f"bno burst read result: {burst_read_result}")
Get 10 packets in streaming mode (using generator):
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for packet in bno_usb_stick.recv_streaming_generator(num_packets=10):
print(f"bno data: {packet}")
Get 100 packets in streaming mode (by receiving single packets):
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for _ in range(100):
packet = bno_usb_stick.recv_streaming_packet()
print(f"{packet}")
Receive infinite number of packets (in case you wait infinite time :wink: ):
from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for packet in bno_usb_stick.recv_streaming_generator():
print(f"{packet}")
Bno USB Stick Data Packet
When receiving data in streaming mode, the result
is an object of BNO055 data class (from bno055.py) file.
BNO055 data class has the following fields:
from bno055_usb_stick_py import BNO055
bno_data = BNO055()
bno_data.a_raw # raw accelerometer data (a_raw_x, a_raw_y, a_raw_z)
bno_data.g_raw # raw gyro data (g_raw_x, g_raw_y, g_raw_z)
bno_data.m_raw # raw magnetometer data (m_raw_x, m_raw_y, m_raw_z)
bno_data.euler_raw # raw euler angles (heading, roll, pitch)
bno_data.quaternion_raw # raw quaternion data (q_raw_w, q_raw_x, q_raw_y, q_raw_z)
bno_data.lin_a_raw # raw linear acceleration data (lin_a_raw_x, lin_a_raw_y, lin_a_raw_z)
bno_data.gravity_raw # raw gravity vector (gravity_raw_x, gravity_raw_y, gravity_raw_z)
bno_data.a # accelerometer (a_x, a_y, a_z)
bno_data.g # gyroscope (g_x, g_y, g_z)
bno_data.m # magnetometer (m_x, m_y, m_z)
bno_data.euler # euler angler (heading, roll, pitch)
bno_data.quaternion # quaternion values (q_w, q_x, q_y, q_z)
bno_data.lin_a # linear acceleration (lin_a_x, lin_a_y, lin_a_z)
bno_data.gravity # gravity vector (gravity_x, gravity_y, gravity_z)
bno_data.temp # temperature register
bno_data.calib_stat # calibration status (addr 0x35) register
bno_data.st_result # status result (addr 0x36) register
bno_data.int_sta # interrupt status (addr 0x37) register
bno_data.sys_clk_status # system clock status (addr 0x38) register
bno_data.sys_status # system status (addr 0x39) register
Prevent modem manager to capture serial device
When plugging bno_usb_stick on Ubuntu,
the device is unavailable for the first 10-15 seconds,
due to the fact that ModemManager process
takes over and tries to use the device.
To avoid this Ubuntu-specific behavior,
add an exception to the udev rules,
s.t. the ModemManager ignores the bno_usb_stick.
Run the script:
python disable_modem_manager_bno_usb_stick.py
The script requires root privileges. Essentially it copies
the 97-ttyacm.rules file to /etc/udev/rules.d and reloads the
udev rules.
Maintainer
Dr. Konstantin Selyunin, for suggestions / questions / comments please contact: selyunin [dot] k [dot] v [at] gmail [dot] com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bno055_usb_stick_py-0.9.5.tar.gz.
File metadata
- Download URL: bno055_usb_stick_py-0.9.5.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4e2322b47398c8016bb861676c3634c7ead939d440c89a83df91935c93a4769
|
|
| MD5 |
f09ce455b0978e676c5854845677ba86
|
|
| BLAKE2b-256 |
2e20f96a49e6b224df3d95a5a5633b38f368712d4e29b8499b90a75f04c189cb
|
File details
Details for the file bno055_usb_stick_py-0.9.5-py3-none-any.whl.
File metadata
- Download URL: bno055_usb_stick_py-0.9.5-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c45211022bd65a34591477df96ed6966804a17444ad804ce3bb94f4d1afc1497
|
|
| MD5 |
3e1fd5e658fe7bfe950fc187a59a7a53
|
|
| BLAKE2b-256 |
743f7446a988be7587bd99bbc25ba685fb259b8281ece9ec2f0d574ca85f0e66
|