Skip to content

Implement C++ Lifecycle Node for BNO055 IMU Driver#8

Draft
Copilot wants to merge 6 commits intomain_c++from
copilot/convert-bno055-driver-to-cpp
Draft

Implement C++ Lifecycle Node for BNO055 IMU Driver#8
Copilot wants to merge 6 commits intomain_c++from
copilot/convert-bno055-driver-to-cpp

Conversation

Copy link

Copilot AI commented Feb 5, 2026

Converts Python BNO055 driver to C++17 Lifecycle Node for ROS2 Humble, replacing threading with timers and adding explicit state management.

Architecture

Lifecycle State Machine

  • on_configure: Hardware connection, chip verification, register configuration
  • on_activate: Publisher activation, timer initialization (data/calibration/watchdog)
  • on_deactivate: Timer shutdown, publisher deactivation, connection maintained
  • on_cleanup: Hardware disconnection, resource release
  • on_error: Safe cleanup with exception handling

Hardware Communication

  • I2CConnector: Direct i2c-dev syscalls with 32-byte chunking, auto-incrementing registers
  • UARTConnector: termios-based serial with non-blocking open, timeout-based reads
  • Both implement abstract Connector interface for polymorphism

Data Pipeline

  • SensorService: Manages publishers, timers, and data acquisition
  • Single 45-byte bulk read from ACCEL_DATA_X_LSB_ADDR
  • Publishes 6 topics: imu, imu_raw, mag, grav, temp, calib_status
  • Quaternion normalization and covariance matrix population

Key Changes

Build System

  • package.xml: ament_python → ament_cmake, added C++ dependencies
  • CMakeLists.txt: Compiles lifecycle node executable
  • Headers in include/bno055/, sources in src/

Performance

  • rclcpp::Timer replaces Python threading.Lock
  • 3 independent timers: data query, calibration logging, watchdog
  • Watchdog monitors system_status/self_test registers every 500ms

Launch

  • bno055_lifecycle.launch.py: Auto-transitions through configure→activate
  • Preserves Python node for backward compatibility

Example Usage

# Automatic lifecycle management
ros2 launch bno055 bno055_lifecycle.launch.py

# Manual control
ros2 lifecycle set /bno055 configure
ros2 lifecycle set /bno055 activate
ros2 lifecycle set /bno055 deactivate

Implementation Notes

  • BNO055 supports register auto-increment; I2C connector exploits this for efficient bulk reads
  • UART uses O_NONBLOCK on open to prevent blocking on unavailable ports
  • Calibration logging uses DEBUG level to avoid 10Hz spam
  • All std::vector allocations sized upfront to minimize reallocations
Original prompt

Görev: Mevcut ROS2 Python BNO055 sürücüsünü, ROS2 Humble standartlarına uygun, yüksek performanslı bir C++ Lifecycle Node (Managed Node) yapısına dönüştür.

Teknik Gereksinimler:

Dil ve Standart: C++17, ROS2 Humble rclcpp_lifecycle.

Kütüphane Seçimi: I2C/Serial iletişimi için io_context veya libi2c gibi düşük seviyeli, asenkron olmayan, bloklanmayan kütüphaneler tercih edilmeli.

Lifecycle Durum Yönetimi:

on_configure: Parametreleri oku (port, address, frame_id), donanım bağlantısını başlat.

on_activate: Publisher'ları (sensor_msgs/msg/Imu) aktif et ve veri okuma döngüsünü (timer) başlat.

on_deactivate: Timer'ı durdur ve veri akışını kes.

on_cleanup: Donanım kaynaklarını serbest bırak.

on_error: Bağlantı kopması durumunda hata logla ve güvenli bir şekilde temizlik yap.

Performans ve Kararlılık: > * Python'daki threading yapısı yerine C++ rclcpp::Timer kullan.

Sensörden gelen "system_status" ve "self_test" verilerini düzenli kontrol ederek bağlantı kopmalarını erkenden tespit et ve lifecycle durumunu kullanarak yeniden bağlanmayı dene.

Veri Dönüşümü: Ham verileri Quaternion ve Covariance matrisleri dahil olacak şekilde standart IMU mesaj formatına uygun hale getir.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 5, 2026 10:50
Co-authored-by: Zarqu0n <72468520+Zarqu0n@users.noreply.github.com>
Co-authored-by: Zarqu0n <72468520+Zarqu0n@users.noreply.github.com>
Co-authored-by: Zarqu0n <72468520+Zarqu0n@users.noreply.github.com>
Co-authored-by: Zarqu0n <72468520+Zarqu0n@users.noreply.github.com>
Co-authored-by: Zarqu0n <72468520+Zarqu0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert existing ROS2 Python BNO055 driver to C++ lifecycle node Implement C++ Lifecycle Node for BNO055 IMU Driver Feb 5, 2026
Copilot AI requested a review from Zarqu0n February 5, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants