(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Use a TS3 Sensor for Mapping with a TurtleBot3

Description: Attaching a TS3 ultrasonic sensor to a TurtleBot3 Burger and mapping the environment with it

Keywords: Toposens, TS3, ultrasound, TurtleBot

Tutorial Level: INTERMEDIATE

Basic mapping of the environment with sensor_msgs/PointCloud2 can be done by orchestrating a TurtleBot3 Burger with a TS3 ultrasonic sensor.

Setup

This tutorial assumes that the TurtleBot3 Burger has already been setup, its onboard computer (Raspberry Pi) is running ROS Melodic e.g. on Ubuntu Mate 18.04 and its IP address is known (<turtlebot_ip>, e.g. 192.168.0.179).

Additionally it is assumed that either Ubuntu 16.04 with ROS Kinetic or Ubuntu 18.04 with ROS Melodic is used on the remote PC. It is also assumed that you have a catkin workspace and catkin tools are installed (both on the TurtleBot's onboard computer and the remote PC).

In order to access the TurtleBot's onboard computer, use SSH:

ssh pi@<turtlebot_ip>

Setup TurtleBot Packages

[On Remote PC]:

  • Clone the TurtleBot repositories into the source folder of your catkin workspace:

    cd ~/catkin_ws/src
    git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
    git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
    In your catkin workspace build the packages by using catkin build:
    cd ~/catkin_ws
    catkin build turtlebot3_msgs turtlebot3

    Source your build space by running "source ~/catkin_ws/devel/setup.bash". This needs to be done in every new terminal or you can add this command to your bashrc for it to be executed automatically.

[On TurtleBot]:

  • Clone the TurtleBot repositories into the source folder of your catkin workspace:

    cd ~/catkin_ws/src
    git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
    git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
    git clone https://github.com/ROBOTIS-GIT/hls_lfcd_lds_driver.git

    (The latter repository is only needed if the TurtleBot's Laser Distance Sensor shall be used.)

  • In your catkin workspace build the packages by using catkin build:
    cd ~/catkin_ws
    catkin build turtlebot3_msgs turtlebot3 hls_lfcd_lds_driver

    Source your build space by either adding "source ~/catkin_ws/devel/setup.bash" to your bashrc or running the command in every new terminal.

Build Toposens Driver

[On Remote PC]:

  • Clone the toposens metapackage into the source folder of your catkin workspace:
    cd ~/catkin_ws/src
    git clone https://gitlab.com/toposens/public/ros-packages.git
    Use rosdep to install missing dependencies:
    rosdep update
    rosdep install --from-paths ~/catkin_ws/src/ros-packages/ --ignore-src --rosdistro <distro> -y
    In your catkin workspace build the packages by using catkin build:
    cd ~/catkin_ws
    catkin build toposens

[On TurtleBot]:

  • Clone the toposens metapackage into the source folder of your catkin workspace:
    cd ~/catkin_ws/src
    git clone https://gitlab.com/toposens/public/ros-packages.git
    Use rosdep to install missing dependencies:
    rosdep update
    rosdep install --from-paths ~/catkin_ws/src/ros-packages/ --ignore-src --rosdistro melodic -y
    In your catkin workspace build the packages by using catkin build:
    cd ~/catkin_ws
    catkin build toposens

Enable Serial Port Permissions

[On TurtleBot]:

  • Add yourself to the “dialout” group:
    sudo adduser $USER dialout
    Trigger updated group permissions to take effect:
    newgrp dialout
    Re-login or reboot for the updated group permissions to take effect permanently.

Connect TS3 Sensor

[On TurtleBot]:

  • Connect your Toposens TS3 sensor via the provided USB cable (for TS3 versions v1.0 & v1.1: FTDI cable) to any available USB port on the Raspberry Pi. The sensor can be mounted on a TurtleBot3 Burger via the mounting device, as can be seen in the picture below. An STL file of the mounting device can be found in the package toposens_description.

    TurtleBotTS3

  • Obtain the connected terminal ID for the device:
      dmesg | grep "cp210x" | tail -n 1 | awk 'NF{print $NF}'

    For TS3 v1.0 & v1.1:

      dmesg | grep "FTDI" | tail -n 1 | awk 'NF{print $NF}'

    In the case below, the terminal ID would be ttyUSB0 ttyPort

Network Configuration

[On Remote PC]:

  • Get to know your own IP address (<master_ip>, e.g. 192.168.0.118):

    ifconfig | grep inet
    Add necessary parameters to your machine's bashrc (~/.bashrc):
       1 export TURTLEBOT3_MODEL='burger'
       2 export ROS_MASTER_URI=http://<master_ip>:11311
       3 export ROS_HOSTNAME=<master_ip>
    
    Source the bashrc:
    source ~/.bashrc

[On TurtleBot]:

  • Add necessary parameters in the TurtleBot's bashrc (~/.bashrc):

       1 export TURTLEBOT3_MODEL='burger'
       2 export ROS_MASTER_URI=http://<master_ip>:11311
       3 export ROS_HOSTNAME=<turtlebot_ip>
    
    Source the bashrc:
    source ~/.bashrc

Manipulate Parameters

See the previous tutorial for how to manipulate sensor parameters.

Do the Mapping

[On Remote PC]:

  • Launch the pointcloud node:
    roslaunch toposens_pointcloud turtlebot_cloud.launch

[On TurtleBot]:

  • Launch the driver node:
    roslaunch toposens_driver toposens_turtlebot.launch

    In case the terminal ID for the TS3 sensor obtained above is unequal to ttyUSB0, this needs to be changes in this launch file.

[On Remote PC]:

  • The TurtleBot can be controlled via the keyboard. For an instruction see the TurtleBot3 Documentation. It is not required to launch the launchfile for teleoperation. This is already done by the command above.

    When navigating through a room, the robot is accumulating the TS3 sensor data and mapping the environment via sensor_msgs/PointCloud2 by making use of the TurtleBot's odometry. Make sure to set the "Decay Time" of the pointcloud large enough in RViz.

    TurtleBotMappingPhoto

    TurtleBotMappingRViz

Visualizing Normal Vectors

  • Since version 2.0 the package makes use of the standard PointCloud type PointXYZINormal instead of the custom type TsPoint. As a result the PointCloud also contains information about the surface normals.

    Due to the specular reflection behavior of ultrasound, the surface normal of the detected object can be represented by a vector pointing from the detected point towards the sensor’s position while the point was recorded. This normal vector is added to the PointCloud representation. For a more detailed explanation of the physics behind Toposens sensors see Physics of 3D Ultrasonic Sensors. In order to visualize the surface normal vectors, run the launch-file with the corresponding argument:

    roslaunch toposens_pointcloud turtlebot_cloud.launch port:=/dev/ttyUSB0 lifetime_normals_vis:=1.0

    TurtleBotMappingRVizNormals Be aware that this map is generated from an arena that has a different layout than the one that is shown further up.

Wiki: toposens/Tutorials/Use a TS3 Sensor for Mapping with a TurtleBot3 (last edited 2020-01-13 14:30:33 by SebastianDengler)