Working with Recorded Camera Data from RealSense D400 series

PREFACE

Intel® RealSense™ D400 Series Depth Cameras record video files in .bag format. These .bag files contain uncompressed and unfiltered data and hence tend to be rather large (in the order of 100 MB per one second of recording). To those coming across this time for the first time, this is an extension of open ROS-bag format, meaning they can also be opened using existing robotics tools like rqt-bag. rqt_bag provides a GUI plugin for displaying and replaying ROS bag files and are readily available as part of the ROS(Robot Operating System) software, which is not yet supported on Windows*, directly. You can find out the supported platforms from here. 

The workaround for running ROS is via the Windows Subsystem for Linux* (WSL). For those already using a Linux machine, skip this and dive straight in to the ROS Installation.

WSL is a compatibility layer which allows to run linux binaries natively on Windows 10. With the advent of the Windows 10 Creators Update in March 2017, the WSL was heavily updated and now is able to run ROS lunar. 

NOTE - This blog details setting up ROS Melodic Morenia (Released May 2018, Latest LTS (while writing this blog), supported until May, 2023).

To install the Windows Subsystem for Linux and Bash on Windows, follow this guide to install Ubuntu. To move forward you need to have atleast xenial (16.04) installed. If you're installing for the first time, skip this step. To check which version is actually installed, start an instance of bash and run lsb_release -a.The output should look like

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:    bionic

INSTALL ROS

Since WSL is based on Ubuntu*, you can follow the official ROS installation guide for Ubuntu by the word, more or less. The only difference is while setting up the public key authentication, where one gets the following error:

gpg: connecting dirmngr at '/tmp/apt-key-gpghome.5HsklTAZk8/S.dirmngr' 
failed: IPC connect call failed 
gpg: keyserver receive 
failed: No dirmngr

The workaround for which is detailed below:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x5523BAEEB01FA116" | sudo apt-key add
sudo apt-get update
sudo apt install ros-melodic-desktop-full
sudo rosdep init
rosdep update
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

#For dependencies and if you want to source ros melodic automatically for every bash session, rather than doing it everytime
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

To run applications with graphical output, you need to install an X Server on Windows. In this case I installed Xming.

#A good way to check is to ensure that environment variables like ROS_ROOT and ROS_PACKAGE_PATH are set
printenv | grep ROS

The next step is to setup a node using rosnode. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Moreover we also need to install the rqt_bag plugin, which provides a GUI plugin for displaying and replaying ROS bag files. 

rosnode
sudo apt-get install ros-melodic-rqt
sudo apt-get install ros-melodic-rqt-common-plugins
rqt_bag

Once the main windows launches, we have to find a way of opening the RealSense video recording, located in the local filesystem. This can be done using the /mnt directory. Which allows access to the local machine’s filesystem from within the Linux Bash shell. Since the default path of recording in Windows and Ubuntu is ~/user/Documents. Once you've opened the .bag file, it'll look something like this:

SUMMARY

In this document we installed Ubuntu on a Windows 10 machine using WSL. From there we installed the ROS(Robot Operating System) and it's libraries to finally be able to make more sense of the pictures/videos saved by the RealSense Camera. In a future blog, I'd be detailing how to save .bag in either jpeg (images) or mpeg/mp4 (videos).

有关编译器优化的更完整信息,请参阅优化通知