The preferred way of getting anything done on the Arduino Portenta X8 is by using Docker. So let's start by creating a Dockerfile that builds and installs the pika-spark-bno085-driver in a Docker image that already contains a ROS base image.
RUN apt-get update && \
apt-get install -y git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /tmp/colcon_ws/src
RUN git clone --recursive https://github.com/pika-spark/pika-spark-bno085-driver
RUN . /opt/ros/humble/setup.sh && colcon build --symlink-install
COPY start.sh /
RUN chmod ugo+x /start.sh
As can be seen from the Dockerfile a simple start script (
start.sh) is copied into the image which serves to navigate to the location of the BNO085 driver within the container and to run it.
echo 'Starting pika-spark-bno085-driver ...'
ros2 launch pika_spark_bno085_driver imu.py
In the next step a Docker image shall be built from the Dockerfile using
docker build --pull --no-cache --tag pika_spark_bno085_driver .
Now its time to enable the GPIOs and SPI interface used for communication between the Arduino Portenta X8's IMX8 application processor and the BNO085 IMU.
echo $GPIO_NIRQ_NUM > /sys/class/gpio/export
echo $GPIO_NRST_NUM > /sys/class/gpio/export
echo $GPIO_NBOOT_NUM > /sys/class/gpio/export
chmod ugo+rw /dev/spidev0.0
As a final step run (
docker run) the newly created
pika_spark_bno085_driver container passing the SPI interface via
--device /dev/spidev0.0 and passing the GPIO interface via mapping the sysfs GPIO interface into the container. If you want to stream network data out of the container (and we do want that, since we want to visualize it via Rviz2 on our development computer) ensure that the X8s network stack is not isolated from the container by passing
sudo -u fio docker run -it \
--ulimit nofile=1024:1024 \
-u 0 --privileged \
--device /dev/spidev0.0 \
-v /sys/class/gpio:/sys/class/gpio \
--network host \
You can verify that data is being received on your development PC by checking the output of
ros2 topic list and
ros2 topic echo /imu.
ros2 topic echo
ros2 topic echo /imu
In order to visualize data contained in the
/imu topic via Rviz2 first the rviz_imu_plugin needs to be installed.
sudo apt-get install ros-humble-imu-tools
Finally it's time to run Rviz2 with a configuration already tailored for visualizing IMU data.
rviz2 -d view_imu.rviz