Skip to content

Commit

Permalink
Bump version, improve docs (#54)
Browse files Browse the repository at this point in the history
* Improve the doc strings for the connectors

Signed-off-by: Evan Flynn <[email protected]>

* Bump version for new release

Signed-off-by: Evan Flynn <[email protected]>

* Update CHANGELOG for new release

Signed-off-by: Evan Flynn <[email protected]>

Signed-off-by: Evan Flynn <[email protected]>
  • Loading branch information
flynneva authored Jan 14, 2023
1 parent b96c8d1 commit f04b088
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,49 @@
Changelog for package bno055
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.4.0
-----------
* Update CHANGELOG for new release
* Improve the doc strings for the connectors
* Add I2C implementation (`#52 <https://github.com/flynneva/bno055/issues/52>`_)
* Add I2C implementation
* Updates after review
* Revert one file change
* Add newline
* Revert to UART as default
* Fix typo
* nit
* Merge pull request `#50 <https://github.com/flynneva/bno055/issues/50>`_ from flynneva/fix-invalid-log-print
Fix invalid log string variable expansion
* Update CI to include Humble
* Fix invalid log string variable expansion
* Merge pull request `#49 <https://github.com/flynneva/bno055/issues/49>`_ from sjev/operation_mode
* add device mode setting
* Contributors: Andrew Symington, Evan Flynn, Jev Kuznetsov

Forthcoming
-----------
* Bump version for new release
* Update CHANGELOG for new release
* Improve the doc strings for the connectors
* Add I2C implementation (`#52 <https://github.com/flynneva/bno055/issues/52>`_)
* Add I2C implementation
* Updates after review
* Revert one file change
* Add newline
* Revert to UART as default
* Fix typo
* nit
* Merge pull request `#50 <https://github.com/flynneva/bno055/issues/50>`_ from flynneva/fix-invalid-log-print
Fix invalid log string variable expansion
* Update CI to include Humble
* Fix invalid log string variable expansion
* Merge pull request `#49 <https://github.com/flynneva/bno055/issues/49>`_ from sjev/operation_mode
* add device mode setting
* Contributors: Andrew Symington, Evan Flynn, Jev Kuznetsov

0.3.0
-----------
* Merge pull request `#43 <https://github.com/flynneva/bno055/issues/43>`_ from flynneva/develop
bring over updates
* Merge pull request `#44 <https://github.com/flynneva/bno055/issues/44>`_ from Towflos/develop
Expand Down
26 changes: 26 additions & 0 deletions bno055/connectors/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,38 @@


class I2C(Connector):
"""Connector implementation for I2C connection to the sensor."""

CONNECTIONTYPE_I2C = 'i2c'

def __init__(self, node: Node, i2c_bus=0, i2c_addr=registers.BNO055_ADDRESS_A):
"""Initialize the I2C class.
:param node: a ROS node
:param i2c_bus: I2C bus to use
:param i2c_addr: I2C address to connect to
:return:
"""
super().__init__(node)
self.bus = SMBus(i2c_bus)
self.address = i2c_addr

def connect(self):
"""Connect to the sensor
:return:
"""
returned_id = self.bus.read_byte_data(self.address, registers.BNO055_CHIP_ID_ADDR)
if returned_id != registers.BNO055_ID:
raise TransmissionException('Could not get BNO055 chip ID via I2C')

def read(self, reg_addr, length):
"""Read data from sensor via I2C.
:param reg_addr: The register address
:param length: The data length
:return:
"""
buffer = bytearray()
bytes_left_to_read = length
while bytes_left_to_read > 0:
Expand All @@ -62,6 +81,13 @@ def read(self, reg_addr, length):
return buffer

def write(self, reg_addr, length, data: bytes):
"""Write data to sensor via I2C.
:param reg_addr: The register address
:param length: The data length
:param data: data to transmit
:return:
"""
bytes_left_to_write = length
while bytes_left_to_write > 0:
write_len = min(bytes_left_to_write, 32)
Expand Down
21 changes: 19 additions & 2 deletions bno055/connectors/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ class UART(Connector):
CONNECTIONTYPE_UART = 'uart'

def __init__(self, node: Node, baudrate, port, timeout):
# Initialize parent class
"""Initialize the UART class.
:param node: a ROS node
:param baudrate: baudrate to configure UART communication to
:param port: UART port to connect to
:param timeout: timeout to use
:return:
"""
super().__init__(node)

self.node = node
Expand All @@ -55,6 +62,10 @@ def __init__(self, node: Node, baudrate, port, timeout):
self.serialConnection = None

def connect(self):
"""Connect to the sensor.
:return:
"""
self.node.get_logger().info('Opening serial port: "%s"...' % self.port)

try:
Expand All @@ -65,6 +76,12 @@ def connect(self):
sys.exit(1)

def read(self, reg_addr, length):
"""Read data from sensor via UART.
:param reg_addr: The register address
:param length: The data length
:return:
"""
buf_out = bytearray()
buf_out.append(registers.COM_START_BYTE_WR)
buf_out.append(registers.COM_READ)
Expand Down Expand Up @@ -119,9 +136,9 @@ def read(self, reg_addr, length):
def write(self, reg_addr, length, data: bytes):
"""
Transmit data packages to the sensor.
:param reg_addr: The register address
:param length: The data length
:param data: data to transmit
:return:
"""
buf_out = bytearray()
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>bno055</name>
<version>0.3.0</version>
<version>0.4.0</version>
<description>Bosch BNO055 IMU driver for ROS2</description>
<maintainer email="[email protected]">flynneva</maintainer>
<license>BSD</license>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name=package_name,
version='0.3.1',
version='0.4.0.',
# find sub-packages automatically in order to allow sub-modules, etc. to be imported:
# packages=[package_name],
packages=find_packages(exclude=['test']),
Expand Down

0 comments on commit f04b088

Please sign in to comment.