The AWS DeepRacer sensor fusion ROS package creates the imu_node
, which is an additional package for AWS DeepRacer that can be used to provide Acceleration and Gyroscope readings from the built in BMI160 IMU.
This node is responsible for collecting the messages from the IMU and publishing the resulting sensor message.
The source code is released under Apache 2.0.
Follow these steps to install the AWS DeepRacer sensor fusion package.
The imu_pkg
specifically depends on the following ROS 2 packages as build and run dependencies:
geometry_msgs
: This package contains the messages for geometric messages.sensor_msgs
: This package defines messages for commonly used sensors, including cameras and scanning laser rangefinders.
Additionally the following Python Packages are needed:
smbus2
which allows communication via the i2c bus.BMI160-i2c
which is a driver for the Bosch BMI160 IMU.
Open a terminal on the AWS DeepRacer device and run the following commands as the root user.
-
Switch to the root user before you source the ROS 2 installation:
sudo su
-
Source the ROS 2 Foxy setup bash script:
source /opt/ros/foxy/setup.bash
-
Install the Python packages:
pip install BMI160-i2c smbus2
-
Create a workspace directory for the package:
mkdir -p ~/deepracer_ws cd ~/deepracer_ws
-
Clone the
imu_pkg
on the AWS DeepRacer device:git clone https://github.com/larsll/larsll-deepracer-imu-pkg.git
-
Fetch unreleased dependencies:
cd ~/deepracer_ws/larsll-deepracer-imu-pkg rosws update
-
Resolve the
imu_pkg
dependencies:cd ~/deepracer_ws/larsll-deepracer-imu-pkg && rosdep install -i --from-path . --rosdistro foxy -y
-
Build the
imu_pkg
:cd ~/deepracer_ws/larsll-deepracer-imu-pkg && colcon build --packages-select imu_pkg
The imu_node
provides the core functionality to combine the sensor data from various sensors connected to the AWS DeepRacer vehicle. Although the node is built to work with the AWS DeepRacer application, you can run it independently for development, testing, and debugging purposes.
To launch the built imu_node
as the root user on the AWS DeepRacer device, open another terminal on the AWS DeepRacer device and run the following commands as the root user:
-
Switch to the root user before you source the ROS 2 installation:
sudo su
-
Source the ROS 2 Foxy setup bash script:
source /opt/ros/foxy/setup.bash
-
Source the setup script for the installed packages:
source ~/deepracer_ws/larsll-deepracer-imu-pkg/install/setup.bash
-
Launch the
imu_node
using the launch script:ros2 launch imu_pkg imu_pkg_launch.py
The imu_pkg_launch.py
, included in this package, provides an example demonstrating how to launch the nodes independently from the core application.
from launch import LaunchDescription
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(
package='imu_pkg',
namespace='imu_pkg',
executable='imu_node',
name='imu_node'
)
])
Topic name | Message type | Description |
---|---|---|
/imu_pkg /imu_msg /raw |
Imu | Publisher that publishes the readings from the IMU in 6 dimensions. |