[Documentation] [TitleIndex] [WordIndex

(!) 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.

Getting Started with the TS3 on a Raspberry Pi

Description: Using the Toposens stack to connect to and display data from a TS3 3D ultrasonic sensor on a Raspberry Pi

Keywords: Toposens, TS3, ultrasound, Raspberry Pi

Tutorial Level: BEGINNER

This tutorial was tested on a Raspberry Pi 3b with Ubuntu Mate 18.04.

It is assumed that you have a catkin workspace and catkin tools are installed.

Build Driver

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 package by using catkin build:

cd ~/catkin_ws

catkin build toposens -j1

The -j1 options limits the build jobs that are run in parallel to 1. This should prevent the Raspberry Pi from running out of memory. If it still runs out of memory while building the packages and gets stuck, try increasing the swap size of the Raspberry Pi (see https://linuxize.com/post/create-a-linux-swap-file/).

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.

Enable Serial Port Permissions

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

Connect your Toposens TS3 sensor via the provided FTDI cable to any available USB port on your computer.

Obtain the connected terminal ID for the device:

dmesg | grep "FTDI USB Serial Device"

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

Visualize Data

There are three different ways of viewing the data output from a TS3 sensor, which are published to three separate topics:

The utility of these topics is further explored in the following sections.

Unlike the visualization on an x86 architecture, on an armhf architecture the sensor mesh itself is not visualized when visualizing the markers or the pointcloud. This is caused by an issue with stl compatibility with RViz.

View Raw Stream

The ts_driver_node translates the sensor data into custom toposens_msgs/TsScan messages.

Launch the driver node and start accruing data from a TS3 sensor. Set the corresponding serial port as launch argument (here: /dev/ttyUSB0):

roslaunch toposens_driver toposens_driver.launch port:=/dev/ttyUSB0

The sensor data is published to the the topic /ts_scans. View the incoming scans with:

rostopic echo /ts_scans

TsScan

Visualize Data as Markers

The ts_markers_node translates the messages of type toposens_msgs/TsScan into messages of type visualization_msgs/MarkerArray, which can be visualized in RViz.

The driver node as well as the markers node are launched from within one launch-file:

roslaunch toposens_markers toposens_markers_armhf.launch port:=/dev/ttyUSB0

The markers are visualized in RViz: (Unlike in this image, the sensor mesh will not be visualized.) RVizMarkers

View Pointcloud in RViz

The ts_cloud_node translates the messages of type toposens_msgs/TsScan into messages of type sensor_msgs/PointCloud2.

The driver node as well as the pointcloud node are launched from within one launch-file:

roslaunch toposens_pointcloud toposens_cloud_armhf.launch port:=/dev/ttyUSB0

The pointcloud is visualized in RViz: (Unlike in this image, the sensor mesh will not be visualized.) RVizPointcloud

The pointcloud is logged to the file ~/catkin_ws/src/ros-packages/toposens_pointcloud/toposens.pcd

Manipulate Parameters

To manipulate sensor parameters as well as visualization parameters live in realtime, run in an additional terminal window:

rosrun rqt_reconfigure rqt_reconfigure

The ts_driver_node respectively ts_markers_node need to be running for this to work.

Sensor Parameters

There are 6 different parameters that can be changed in the ts_driver_node.

DynRecDriver

Variable Name

Description

num_pulses

This is the only parameter that has an effect on the emitted ultrasonic signal. It defines the number of electrical pulses that the piezo transmitter is stimulated with in every transmission cycle. The higher the number, the louder and longer the emitted signal will be. As a result, increasing the value will detect objects that are further away, decreasing it will increase the sensors precision in short range.

echo_rejection_threshold

This parameter defines the minimum amplitude, i.e. the signal strength, that a received echo signal needs to have in order to be utilized for further processing. Signals that are below this threshold are discarded. As a result, increasing the value will ignore more points of smaller intensity and only allow strong reflectors to be detected.

peak_detection_window

This parameter defines the kernel size for a peak detection filter that is applied on the received ADC signals in order to find the peaks that link to the echoes of the detected objects. When it is set too high, objects that are close to each other might merge to one bigger object. Decreasing it might separate these objects but might also destabilize the resulting signal.

noise_indicator_threshold

This parameter has no effect on the visualization of the pointcloud or the markers. It is solely used to mark individual scans with a noise flag. This is done by calculating an overall noise level for the raw ADC signal of one frame. If this noise level lies above the noise_indicator_threshold, the noise flag for this scan is set. This might indicate that there are sources of ultrasonic disturbances in the scene. However the scans will be shown regardless of the noise flag.

external_temperature

This parameter defines the temperature that is used for calculating the speed to sound. Its accuracy has an effect on the correct calculation of the distance of objects. The value is only used if use_external_temperature is checked.

use_external_temperature

The TS3 also has an on-board temperature sensor. If use_external_temperature is not checked, the TS3 will use its on-board temperature sensor for speed-of-sound calculation. If it is checked, it will use the external_temperature.

Marker Parameters

There are 2 parameters that can be changed in the ts_markers_node.

DynRecMarkers

Variable Name

Description

lifetime

Duration for which a marker should remain visible

scale

Magnitude for resizing markers equally and simultaneously


2019-10-19 13:16