Intel Realsens on Ubuntu 20.04 + ROS noetic (installation desription)

asked 2020-10-21 02:24:21 -0600

Markus Bader gravatar image

updated 2021-02-18 04:19:44 -0600

[deprecated] Feb 2021

Ubuntu 20.04 LTS is now natively supported by the RealSenseā„¢ SDK 2.0.

Intel Realsens on Ubuntu 20.04

I just like to share my installation desription for my intel realsense d435 on ubuntu 20.04 with ros noetic. At the moment the realsense interface is without python bindings.

librealsens

# preparations
export REALSENSE_SOURCE_DIR=$HOME/projects/librealsense/
sudo apt-get install guvcview git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
git clone https://github.com/IntelRealSense/librealsense.git $REALSENSE_SOURCE_DIR
mkdir $REALSENSE_SOURCE_DIR/build
cd $REALSENSE_SOURCE_DIR/build

# build
export REALSENSE_INSTALL_PREFIX=/opt/realsense
sudo mkdir -p $REALSENSE_INSTALL_PREFIX; 
sudo chown $USER:$USER -R $REALSENSE_INSTALL_PREFIX # not relay needed -> you could run _make_ followed by _sudo make install_
cmake ../ -DFORCE_RSUSB_BACKEND=true -DBUILD_PYTHON_BINDINGS=false -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=true -DCMAKE_INSTALL_PREFIX=$REALSENSE_INSTALL_PREFIX
make install

# extend the ld search path
sudo sh -c "echo $REALSENSE_INSTALL_PREFIX/lib > /etc/ld.so.conf.d/realsense.conf"
sudo ldconfig

# udev rules
cd ~/projects/librealsense/
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/99-realsense-libusb.rules && sudo udevadm control --reload-rules && udevadm trigger

# make cmake config avaliable
echo "export realsense2_DIR=/opt/realsense/lib/cmake/realsense2" >> ~/.bashrc

# reboot

Test

/opt/realsense/bin/realsense-viewer

ROS

export REALSENSE_ROS_WS=$HOME/projects/ros/ws00
sudo apt install ros-noetic-ddynamic-reconfigure
git clone https://github.com/IntelRealSense/realsense-ros.git $REALSENSE_ROS_WS/src/realsense-ros
cd $REALSENSE_ROS_WS
catkin_make

Uninstall

rm -rf /opt/realsense
sudo rm /etc/ld.so.conf.d/realsense.conf
sudo ldconfig
sudo rm /etc/udev/rules.d/99-realsense-libusb.rules
sudo udevadm control --reload-rules && udevadm trigger
# --> remove the line "export realsense2_DIR=/opt/realsense/lib/cmake/realsense2" from ~/.bashrc
edit retag flag offensive close merge delete

Comments

Thanks a ton! This really helped me!

BuilderMike gravatar image BuilderMike  ( 2020-10-30 22:59:46 -0600 )edit

Does this require to install an older kernel? Because the first apt-get throws an error:

ERROR (dkms apport): kernel package linux-headers-5.4.0-56-generic is not supported
Error! Bad return status for module build on kernel: 5.4.0-56-generic (x86_64)
Consult /var/lib/dkms/librealsense2-dkms/1.3.12/build/make.log for more information.
thodor gravatar image thodor  ( 2020-12-11 07:48:59 -0600 )edit

@thodor I used a vanilla 20.04 that I downloaded on Oct 30; and I'm pretty sure the kernel was a 5.4.0, as that is the kernel for 20.04 (https://ubuntu.com/blog/ubuntu-kernel...) My current kernel is 5.4.0-56-generic, but it's possible that the patch revision was less than 56 at the time this procedure worked for me; however I think the kernel and the patch number might not be the issue. Hope it works out for you...

BuilderMike gravatar image BuilderMike  ( 2020-12-12 15:53:32 -0600 )edit

Note: To preserve compatibility by staying on a 5.4 kernel on 20.04 and not the newer 5.8 kernel (that by default you will get auto-upgraded to as of ~Jan 2021), you can hold some packages like described here: https://askubuntu.com/questions/93849... (No idea what's up with that failure with a 5.4.0-56 kernel though :/ )

erelson gravatar image erelson  ( 2021-04-19 12:55:24 -0600 )edit

How would this change if it were to apply python bindings? Is it as simple as changing -DBUILD_PYTHON_BINDINGS=false to -DBUILD_PYTHON_BINDINGS=true?

honchozthename gravatar image honchozthename  ( 2022-02-28 23:05:21 -0600 )edit