Repository Summary

Description
Checkout URI https://github.com/hsgwa/ros2_timer_latency_measurement.git
VCS Type git
VCS Version master
Last Updated 2020-10-27
Dev Status UNKNOWN
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

Name Version
ros2_timer_latency_measurement 0.0.0

README

ros2_timer_latency_measurement

Overview

This measure the accuracy of the timer when the priority of the ROS2-generated child thread change. Following Latencies are measured.

  • Latency of nanosleep wake-up between child threads policies TS and RR There are two patterns of child threads, as follows
    • child threads : rclcpp::init() generated only.
    • child threads : rclcpp::init() + node decleration generated
  • Latency of Timer callback between nanosleep + spin_some vs spin Each measurement point is as follows.
    • nanosleep + spin_some : The latency between the time nanosleep expected to wake-up and the callback is actually called.
    • spin : The latency between the time callback expected to be called and actually called.

Setup

Environment

The main environment is as follows:

  • Hardware : Raspberry Pi 3B +
  • OS : ubuntu 18.04 4.19.55-rt24-v7+
  • ROS Distro : ROS 2 Eloquent Elusor
  • DDS : FastRTPS(v1.9.3P1) or CycloneDDS(0.1.0)

For building environment, see setup.md.

Cyclictest results before and after setup. cyclictest result

Build

source ~/ros2_eloquent/install/setup.bash
cd ~/ros2_ws/src
git clone https://github.com/hsgwa/ros2_timer_latency_measurement.git
colcon build --symlink-install

Run

Example

source ~/ros2_eloquent/install/setup.bash
source ~/ros2_ws/install/local_setup.sh
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp

taskset -c 1 ~/ros2_ws/build/ros2_timer_latency_measurement/init_thread \
        --use_realtime_child_thread \
        --timeseries_filename timeseries.csv \
        --hist_filename raw/hist.csv \
        --topn_filename raw/topn.csv \
        --rttest_args -m 200mb -d 200mb -t 98 -s rr -u 10ms -i 720000

Excuetable files

The following is a list of executable files.

executable file measurement target conditons
init_thread nanosleep wake-up latency rclcpp::init generated thread
init_and_node_thread_thread nanosleep wake-up latency rclcpp::init and DDS generated threads
timer_cb_latency_spin_some callback latency nanosleep + spin_some executor
timer_cb_latency_spin callback latency single thread executor

Comand line options

Each executable can be configured with command line options.

options descriptions
–use_realtime_child_thread Set child threads policy. real-time (inherit rttest_args)
–unuse_realtime_child_thread Set child threads policy. TS
–timeseries_filename Set filepath to export time-series cav data
–hist_filename Set filepath to export histgram csv data
–topn_filename Set filepath to export topN latency data.

The options after –rttest_args will be sent to rttest. The availabile options are as follows. Here, rttest version is tag:0.9.0.

options descriptions
-m Set maximum stack prefault size for static stack prefaulting.
-d Set maximum heap prefault size for dynamic memory prefaulting.
-t Set the thread priority of all threads launched by the test program.
-s Set scheduling policy fifo/rr
-u Specify the update period.
-i Specify how many iterations to run the real-time loop.

Please see rttest for more information on each option.

Results

Comparison of nanosleep wake-up latency between child threads policies TS and RR

File truncated at 100 lines see the full file