Perception-Driver

Unitree quadrupeds Aliengo and A1 are equipped with depth cameras. Here for the sake this documentation Unitree A1 is tested which has Intel Realsense D435i. Moreover for this specific model we have Rasberry Pi 4b(Later will be referred to RPI), so all the installation instructions are specific to this specific model.

Driver Installation

Intel RealSense has its ROS driver available. This ROS driver is dependent on librealsense RealSense SDK which also has a few dependencies. So here we’ll start by first installing dependencies for RealSense SDK.

  • Let’s start by updating, upgrading the system and installing dependencies and some useful tools.

sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install automake libtool vim cmake libusb-1.0-0-dev libx11-dev xorg-dev libglu1-mesa-dev
  • Next task is to expand the filesystem in RPI by selecting the menu entry Advanced Options and reboot.

sudo raspi-config
  • After successful reboot now increase SWAP size in /etc/dphys-swapfile by adding CONF_SWAPSIZE=2048 and commenting out the deafult one(usually its CONF_SWAPSIZE=100)

sudo vim /etc/dphys-swapfile
  • Apply the above mentioned SWAP changes by:

sudo /etc/init.d/dphys-swapfile restart swapon -s
  • Create a new udev rule for the installation by running following commands:

cd ~
git clone https://github.com/IntelRealSense/librealsense.git
cd librealsense
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
  • Apply udev changes within root:

sudo su
udevadm control --reload-rules && udevadm trigger
exit
  • Add the following line to your .bashrc file to modify the path:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
  • Apply the changes made so far by:

source ~/.bashrc

Dependencies

  1. Install protobuf — Google’s platform-neutral, language-neutral, extensible mechanism for serializing structured data by(in case of errors in this installatio go to next step 1.1. for binary installations):

cd ~
git clone --depth=1 -b v3.10.0 https://github.com/google/protobuf.git
cd protobuf
./autogen.sh
./configure
make -j1
sudo make install
cd python
export LD_LIBRARY_PATH=../src/.libs
python3 setup.py build --cpp_implementation
python3 setup.py test --cpp_implementation
sudo python3 setup.py install --cpp_implementation
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=3
sudo ldconfig
protoc --version

1.1. To install protobuf binaries:

sudo apt install protobuf-c*
sudo apt install python3-protobuf
  1. Install C++ parallelism library libtbb-dev:

cd ~
wget https://github.com/PINTO0309/TBBonARMv7/raw/master/libtbb-dev_2018U2_armhf.deb
sudo dpkg -i ~/libtbb-dev_2018U2_armhf.deb
sudo ldconfig
rm libtbb-dev_2018U2_armhf.deb

RealSense SDK

  • Install librealsense RealSense SDK:

cd ~/librealsense
mkdir  build  && cd build
cmake .. -DBUILD_EXAMPLES=true -DCMAKE_BUILD_TYPE=Release -DFORCE_LIBUVC=true
make -j1
sudo make install
  • Let’s just install Python bindings pyrealsense2 forlibrealsense`:

cd ~/librealsense/build
cmake .. -DBUILD_PYTHON_BINDINGS=bool:true -DPYTHON_EXECUTABLE=$(which python3)
make -j1
sudo make install
  • Modify the PYTHONPATH environment variable by adding the following line to `.bashrc’

export PYTHONPATH=$PYTHONPATH:/usr/local/lib
  • Apply the changes by:

source ~/.bashrc
  • OpenGL installation:

sudo apt-get install python-opengl
sudo -H pip3 install pyopengl
sudo -H pip3 install pyopengl_accelerate==3.1.3rc1
  • Change RPI settings to enable OpenGL:

sudo raspi-config
# "7. Advanced Options" – "A8 GL Driver" – "G2 GL (Fake KMS)"

ROS Driver

RealSense ROS driver in RPI is not availble from binaies, so let’s install the driver from sources and its one depndency ddynamic_reconfiure. Follow the steps below for the installation.

  • Create catkin_ws

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
cd realsense-ros/
git checkout `git tag | sort -V | grep -P "^2.\d+\.\d+" | tail -1`
cd ..
catkin_init_workspace
cd ..
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
source ~/catkin_ws/devel/setup.bash

Usage

To use the installed driver run the following command:

roslaunch realsense2_camera rs_camera.launch enable_sync:=true

Now you can run rviz or some other tools to see the depth camera feed:

rosrun rviz rviz

Add a new frame of RGB image or depth one to see the result.