Skip to content

ROS driver for the InvenSense MPU9250 9DoF IMU.

License

Notifications You must be signed in to change notification settings

tau-adl/ros-driver_mpu9250

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

driver_mpu9250

Overview

This package includes driver software for the InvenSense MPU9250 9DoF IMU. It provides a base driver class that allows a device specific (e.g. RPi, Arduino, etc.) driver to be easily derived and implemented. In it's current state, this repository includes a derived driver for the Raspberry Pi using pigpio.

Keywords: mpu9250 imu driver raspberry_pi

License

The source code is released under a MIT license.

Author: Paul D'Angio
Maintainer: Paul D'Angio, [email protected]

The driver_mpu9250 package has been tested under ROS Melodic and Ubuntu 18.04. This is research code, expect that it changes often and any fitness for a particular purpose is disclaimed.

Installation

Building from Source

Dependencies

Building

To build from source, clone the latest version from this repository into your catkin workspace and compile the package using

# Switch to your catkin workspace directory.
cd catkin_workspace

# Clone the package into the workspace src directory.
git clone https://github.com/pcdangio/ros-driver_mpu9250.git src/driver_mpu9250

# Build the package.
catkin_make

Usage

Run any of the driver nodes with (where xxx is the driver type):

rosrun driver_mpu9250 driver_mpu9250_xxx

For example, to run the node using a driver for a Raspberry Pi:

# First, in a different terminal, start up the PiGPIO Daemon:
sudo pigpiod

# In a second terminal, start up the driver.
rosrun driver_mpu9250 driver_mpu9250_rpi

Creating Device Drivers

This package uses polymorphism with a base driver class to enable drivers to be built for a variety of hardware interfaces. To create your own device-specific driver:

  • Create a new class for your device driver that extends the base driver class in src/driver.h
  • In your derived driver class, implement the several pure abstract functions of the base driver class
  • Create a new main.cpp that instantiates your derived class and passes it to the src/ros_node.h instance through polymorphism before running the node.
  • Add the new main.cpp to your CMakeLists.txt as a new node executable.

You can refer to the following files in this package as an example for creating your custom device driver:

src/rpi_driver.h
src/rpi_driver.cpp
src/main_rpi.cpp
CMakeLists.txt

If you have created and tested a driver for a device not already covered in this package, please feel free to submit a pull request!

Nodes

rpi_node

A Raspberry Pi driver for MPU9250. Ensure that the pigpio daemon is running before starting this node, and that your username is added to the 'gpio' group.

Published Topics

Services

  • imu/calibrate_gyroscope (sensor_msgs_ext/calibrate_gyroscope) Calibrates the gyroscope by calculating and removing gyroscope bias. The bias is calculated by averaging gyroscope data over an averaging period.

Parameters

  • ~/i2c_bus (int, default: 1)
    The I2C bus to communicate with the MPU9250 over.

  • ~/i2c_address (int, default: 0x68) The I2C address of the MPU9250.

  • ~/interrupt_gpio_pin (int, default: 0)
    The GPIO input pin connected to the MPU9250's interrupt pin. NOTE: You must use GPIO numbers, not pin numbers.

  • ~/gyro_dlpf_frequency (int, default: 0)
    An enum value representing the digital low pass filter (DLPF) cutoff frequency for the gyroscopes.
    NOTE: The publishing rate of Imu, MagneticField, and Temperature messages will be approximately 2.5x the gyro OR accel DLPF frequency (whichever is larger).
    Enumerated Values:
    250Hz = 0
    184Hz = 1
    92Hz = 2
    41Hz = 3
    20Hz = 4
    10Hz = 5
    5Hz = 6

  • ~/accel_dlpf_frequency (int, default: 0)
    An enum value representing the digital low pass filter (DLPF) cutoff frequency for the accelerometers.
    NOTE: The publishing rate of Imu, MagneticField, and Temperature messages will be approximately 2.5x the gyro OR accel DLPF frequency (whichever is larger).
    Enumerated Values:
    460Hz = 0
    184Hz = 1
    92Hz = 2
    41Hz = 3
    20Hz = 4
    10Hz = 5
    5Hz = 6

  • ~/gyro_fsr (int, default: 0)
    The full scale range (FSR) of the gyroscopes.
    Enumerated Values:
    +/- 250deg/sec = 0
    +/- 500deg/sec = 1
    +/- 1000deg/sec = 2
    +/- 2000deg/sec = 3

  • ~/accel_fsr (int, default: 0)
    The full scale range (FSR) of the accelerometers.
    Enumerated Values:
    +/- 2g = 0
    +/- 4g = 1
    +/- 8g = 2
    +/- 16g = 3

  • ~/max_data_rate (float, default: 8000)
    The maximum allowable sensor data rate, in Hz. Data rate is normally calculated as half of the accel/gyro DLPF frequency (nyquist criterion). This parameter allows maximum cap on the data rate, regardless of the DLPF frequency.

Bugs & Feature Requests

Please report bugs and request features using the Issue Tracker.

About

ROS driver for the InvenSense MPU9250 9DoF IMU.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 95.8%
  • CMake 4.2%