Skip to content

Build with local librealsense2

doronhi edited this page Jun 29, 2020 · 1 revision

For users who wish to build both librealsense2 and realsense2_camera from code, without installing librealsense2 system-wide, it is possible to use catkin_make_isolated.

Assuming ROS is already installed, the following commands will clone and build both librealsense2 and realsense2_camera

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

# clone source code:
git clone -v --progress https://github.com/intel-ros/realsense.git
git clone https://github.com/IntelRealSense/librealsense.git

# install dependencies:
sudo apt-get install -y cmake
sudo apt-get install -y git libgtk-3-dev
if [ $DIST_CODENAME == "xenial" ]; then
    echo "xenial"
    sudo apt-get install -y libglfw3-dev
elif [ $DIST_CODENAME == "bionic" ]; then
    echo "bionic"
    sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
fi
rosdep install --from-paths src --ignore-src -y

# udev rules:
./librealsense/scripts/setup_udev_rules.sh

cd ~/catkin_ws
catkin_make_isolated -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DFORCE_RSUSB_BACKEND=ON --install
echo "source ~/catkin_ws/devel_isolated/setup.bash" >> ~/.bashrc
source ~/.bashrc

Notice the flag -DFORCE_RSUSB_BACKEND=ON. It is used here because we chose, in this example, to to update the kernel with realsense kernel patches. If you choose to update the kernel and your OS is supported, you may omit this flag.