Skip to content

Commit 89768a2

Browse files
committed
Added missing files and a simple getting started manual for the demo
using the infrastructure proposed in the REP-2017 below. ros-infrastructure/rep#385 The demo is to explain how to use the infrastructure in the process that has multiple single-threaded executors as a reply to the question below. ros-infrastructure/rep#385 (comment) The YAML files for the existing executors are to demonstrate that the existing executors can be enhanced with our proposed infrastructure, supporting our mention below. ros-infrastructure/rep#385 (comment) Signed-off-by: Shoji Morita <s-morita@esol.co.jp>
1 parent 7d9c801 commit 89768a2

5 files changed

Lines changed: 548 additions & 4 deletions

autoware_reference_system/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ if(${FRAMEWORK} STREQUAL ros)
4949
add_benchmark_executable(autoware_default_prioritized
5050
src/ros2/executor/autoware_default_prioritized.cpp)
5151

52+
# Prioritized Executor using REP-2017's feature
53+
add_benchmark_executable(autoware_default_prioritized_using_rep2017
54+
src/ros2/executor/autoware_default_prioritized_using_rep2017.cpp)
55+
5256
# API `add_callback_group` not available in Foxy
5357
if(NOT $ENV{ROS_DISTRO} MATCHES "foxy")
5458
# Multiple executors on callback-group-level with suitable prioritization of critical path.
@@ -150,5 +154,5 @@ if(${BUILD_TESTING})
150154
endif()
151155

152156
ament_auto_package(
153-
INSTALL_TO_SHARE test scripts
157+
INSTALL_TO_SHARE test scripts cfg
154158
)

autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
- priority: 10
1+
- priority: 10
22
name: RCLCPP_EXECUTOR_SINGLE_THREADED
33
core_affinity: []
44
scheduling_policy: RR
5-
- priority: 10
5+
- priority: 10
66
name: RCLCPP_EXECUTOR_MULTI_THREADED
77
core_affinity: []
88
scheduling_policy: RR

autoware_reference_system/cfg/thread_attr_for_prioritized.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- priority: 1
1+
- priority: 1
22
name: RCLCPP_EXECUTOR_HOTPATH
33
core_affinity: [1,2,3]
44
scheduling_policy: RR
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Getting started to use the REP-2017's infrastructure.
2+
This memo explains how to use the REP-2017's infrastructure proposed in the pull-request below.
3+
https://github.com/ros-infrastructure/rep/pull/385
4+
5+
Throughout the procedures below, you can prepare the environment where the ROS 2 and benchmark application use the thread attribute configuration feature.
6+
7+
## [Host PC] Create an SD card for Raspberry Pi 4
8+
````bash
9+
$ wget https://github.com/ros-realtime/ros-realtime-rpi4-image/releases/download/22.04.1_v5.15.39-rt42-raspi_ros2_humble/ubuntu-22.04.1-rt-ros2-arm64+raspi.img.xz
10+
#
11+
$ sudo rpi-imager --cli ubuntu-22.04.1-rt-ros2-arm64+raspi.img.xz [SD card's device node, e.g. /dev/sdc]
12+
````
13+
After booting with the SD card above, you have to configure the Raspberry Pi 4 to connect to the internet.
14+
15+
## Prepare the build/execution environment for ROS 2 and sample benchmark.
16+
````bash
17+
$ sudo apt purge -y needrestart
18+
$ sudo apt update && sudo apt install -y locales
19+
$ sudo locale-gen en_US en_US.UTF-8
20+
$ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
21+
$ export LANG=en_US.UTF-8
22+
$ sudo apt update && sudo apt install -y software-properties-common
23+
$ sudo add-apt-repository universe
24+
$ sudo apt update && sudo apt install -y curl
25+
$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
26+
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
27+
$ sudo apt update && sudo apt install -y \
28+
python3-flake8-docstrings \
29+
python3-pip \
30+
python3-pytest-cov \
31+
ros-dev-tools
32+
$ sudo apt update && sudo apt install -y \
33+
python3-flake8-blind-except \
34+
python3-flake8-builtins \
35+
python3-flake8-class-newline \
36+
python3-flake8-comprehensions \
37+
python3-flake8-deprecated \
38+
python3-flake8-import-order \
39+
python3-flake8-quotes \
40+
python3-pytest-repeat \
41+
python3-pytest-rerunfailures
42+
$ sudo apt update && sudo apt install -y libacl1-dev
43+
## needed to execute reference system's benchmark below
44+
## https://github.com/ros-realtime/reference-system
45+
$ sudo pip install bokeh==2.4.3
46+
$ sudo pip install pandas
47+
$ sudo pip install psrecord
48+
## Disable preinstalled ROS 2 humble.
49+
$ sudo rm /etc/profile.d/99-source-ros.sh
50+
$ sudo reboot
51+
````
52+
## Build ROS 2 Rolling, adopting the patches related to the REP-2017.
53+
````bash
54+
$ mkdir -p ros2_rolling/src
55+
$ cd ros2_rolling
56+
$ vcs import -w 1 src < ~/rolling-with-thread-attribute-configuration-extention-rep2017.repos
57+
# Copy the repos file above from the repository below.
58+
# https://github.com/esol-community/reference-system/tree/rep2017_demo/misc
59+
$ touch src/gazebo-release/COLCON_IGNORE
60+
$ touch src/ros2/rviz/COLCON_IGNORE
61+
$ sudo rosdep init
62+
$ rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
63+
$ colcon build --symlink-install --executor sequential
64+
# It takes at least 10 hours to self-build on the Raspberry Pi 4.
65+
````
66+
67+
## Build reference-system benchmark modified to use the REP-2017 infrastructure.
68+
````bash
69+
$ mkdir -p ~/ros2_ws/src
70+
$ cd ~/ros2_ws/src
71+
$ git clone -b rep2017_demo https://github.com/esol-community/reference-system.git
72+
$ cd ~/ros2_ws
73+
$ source ~/ros2_rolling/install/setup.bash
74+
$ colcon build --symlink-install --executor sequential
75+
````
76+
77+
## Execute the benchmark(prioritized).
78+
To get the result without thread attribute settings, execute the benchmark
79+
without the dedicated environment variable (ROS_THREAD_ATTRS_FILE).
80+
````bash
81+
$ export ROS_THREAD_ATTRS_FILE=
82+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_prioritized_using_rep2017
83+
````
84+
To get the result with the thread attribute settings, execute the benchmark after setting the environment variable to point to the YAML configuration file.
85+
````bash
86+
$ export ROS_THREAD_ATTRS_FILE=~/ros2_ws/install/autoware_reference_system/share/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml
87+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_prioritized_using_rep2017
88+
````
89+
90+
## Execute the benchmark(singlethreaded/multithreaded).
91+
To get the result without thread attribute settings, execute the benchmark
92+
without the dedicated environment variable (ROS_THREAD_ATTRS_FILE).
93+
````bash
94+
$ export ROS_THREAD_ATTRS_FILE=
95+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_singlethreaded
96+
or
97+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_multithreaded
98+
99+
````
100+
To get the result with the thread attribute settings, execute the benchmark after setting the environment variable to point to the YAML configuration file.
101+
````bash
102+
$ export ROS_THREAD_ATTRS_FILE=~/ros2_ws/install/autoware_reference_system/share/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml
103+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_singlethreaded
104+
or
105+
$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_multithreaded
106+
````
107+

0 commit comments

Comments
 (0)