If you are (for example) an owner of NVIDIA Jetson Nano Developer Kit and RPLidar, you can use ROS Melodic to realize obstacle avoidance or simultaneous localization and mapping (SLAM). Here is a beginner’s tutorial for installing the necessary software.
Requirements
- Ubuntu 18.04 (Desktop Image)
- RPLIDAR A1M8 (Slamtec)
Objective
Installing ROS Melodic
on Ubuntu 18.04
with Catkin Workspace and use of Python 2.7
for RPLIDAR A1.
Preparation
If you already have the necessary packages installed, you can skip this step.
# update & upgrade
$ sudo apt update && sudo apt upgrade -y
# install needed packages
$ sudo apt install -y git build-essential
If you run Ubuntu in VirtualBox it is recommended to install the Extension Pack and the VirtualBox Guest Additions.
# install needed packages
$ sudo apt install -y dkms linux-headers-$(uname -r)
# Menu -> Devices -> Insert Guest Additions Image
# reboot system
$ sudo reboot
Install ROS Melodic
For Ubuntu 18.04 you need the latest version ROS 1 (Robot Operating System) Melodic. The packages are not included in the standard sources.
Hint: If you still want to use a newer version of Ubuntu (like 20.04) you need ROS 2 Noetic!
Note: By default the ROS Melodic is using Python 2.7. For higher Python version the following description is not working! But it would also be possible to use Python 3.x, only the steps for installation are little different.
The ROS Melodic installation is relatively easy but can take a while depending on the internet connection, as there are many packages to be installed.
# update and install packages
$ sudo apt update && sudo apt install -y ros-melodic-desktop-full python-rosdep python-rosinstall python-rosinstall-generator python-wstool
# verify installation (optional)
$ ls -la /opt/ros/melodic/
# initialize & update
$ sudo rosdep init && rosdep update
# show ros environment variables (optional)
$ printenv | grep ROS
Create a Catkin workspace
You now need the Catkin Workspace with the necessary RPLIDAR packages/binaries (RPLIDAR SDK from Slamtec).
# create and change into directory
$ mkdir -p $HOME/catkin_ws/src && cd $HOME/catkin_ws/src
# clone Git repository
$ git clone https://github.com/Slamtec/rplidar_ros.git
# change directory
$ cd $HOME/catkin_ws/
# build workspace
$ catkin_make
# verify directory content (optional)
$ ls -la devel/
# refresh environment variables
$ source devel/setup.bash
# verify path variable (optional)
$ echo $ROS_PACKAGE_PATH
# build node
$ catkin_make rplidarNode
Okay, that’s itβ¦ Wasn’t very difficult, but a lot of steps.
Start ROS Melodic
Now connect the RPLIDAR device. If you use VirtualBox, pass through the USB from host to guest.
# list USB device and verify permissions
$ ls -la /dev | grep ttyUSB
# change permissions
$ sudo chmod 0666 /dev/ttyUSB0
From now on you need two terminals! Once you have successfully gotartet roscore
in the first terminal, switch to the second terminal.
# change directory
$ cd $HOME/catkin_ws/
# launch roscore
$ roscore
Note: Don’t close the first terminal though or don’t stop the running process!
# change directory
$ cd $HOME/catkin_ws
# refresh environment variables
$ source $HOME/catkin_ws/devel/setup.bash
# run UI
$ roslaunch rplidar_ros view_rplidar.launch
Sorry for using screenshots but my provider doesn’t allow the use of certain words or characters. π