diff --git a/autoware_reference_system/CMakeLists.txt b/autoware_reference_system/CMakeLists.txt index af6dae6a..b727c034 100644 --- a/autoware_reference_system/CMakeLists.txt +++ b/autoware_reference_system/CMakeLists.txt @@ -49,6 +49,10 @@ if(${FRAMEWORK} STREQUAL ros) add_benchmark_executable(autoware_default_prioritized src/ros2/executor/autoware_default_prioritized.cpp) + # Prioritized Executor using REP-2017's feature + add_benchmark_executable(autoware_default_prioritized_using_rep2017 + src/ros2/executor/autoware_default_prioritized_using_rep2017.cpp) + # API `add_callback_group` not available in Foxy if(NOT $ENV{ROS_DISTRO} MATCHES "foxy") # Multiple executors on callback-group-level with suitable prioritization of critical path. @@ -150,5 +154,5 @@ if(${BUILD_TESTING}) endif() ament_auto_package( - INSTALL_TO_SHARE test scripts + INSTALL_TO_SHARE test scripts cfg ) diff --git a/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml b/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml index a516b641..2258a024 100644 --- a/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml +++ b/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml @@ -1,8 +1,8 @@ -- priority: 10 +- priority: 10 name: RCLCPP_EXECUTOR_SINGLE_THREADED core_affinity: [] scheduling_policy: RR -- priority: 10 +- priority: 10 name: RCLCPP_EXECUTOR_MULTI_THREADED core_affinity: [] scheduling_policy: RR diff --git a/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml b/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml index 1aa80530..3ae3e0b5 100644 --- a/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml +++ b/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml @@ -1,4 +1,4 @@ -- priority: 1 +- priority: 1 name: RCLCPP_EXECUTOR_HOTPATH core_affinity: [1,2,3] scheduling_policy: RR diff --git a/misc/getting_started_thread_attribute_configuration_extention_rep2017.md b/misc/getting_started_thread_attribute_configuration_extention_rep2017.md new file mode 100755 index 00000000..a9f817db --- /dev/null +++ b/misc/getting_started_thread_attribute_configuration_extention_rep2017.md @@ -0,0 +1,107 @@ +# Getting started to use the REP-2017's infrastructure. +This memo explains how to use the REP-2017's infrastructure proposed in the pull-request below. +https://github.com/ros-infrastructure/rep/pull/385 + +Throughout the procedures below, you can prepare the environment where the ROS 2 and benchmark application use the thread attribute configuration feature. + +## [Host PC] Create an SD card for Raspberry Pi 4 +````bash +$ 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 +# +$ sudo rpi-imager --cli ubuntu-22.04.1-rt-ros2-arm64+raspi.img.xz [SD card's device node, e.g. /dev/sdc] +```` +After booting with the SD card above, you have to configure the Raspberry Pi 4 to connect to the internet. + +## Prepare the build/execution environment for ROS 2 and sample benchmark. +````bash +$ sudo apt purge -y needrestart +$ sudo apt update && sudo apt install -y locales +$ sudo locale-gen en_US en_US.UTF-8 +$ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +$ export LANG=en_US.UTF-8 +$ sudo apt update && sudo apt install -y software-properties-common +$ sudo add-apt-repository universe +$ sudo apt update && sudo apt install -y curl +$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg +$ 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 +$ sudo apt update && sudo apt install -y \ + python3-flake8-docstrings \ + python3-pip \ + python3-pytest-cov \ + ros-dev-tools +$ sudo apt update && sudo apt install -y \ + python3-flake8-blind-except \ + python3-flake8-builtins \ + python3-flake8-class-newline \ + python3-flake8-comprehensions \ + python3-flake8-deprecated \ + python3-flake8-import-order \ + python3-flake8-quotes \ + python3-pytest-repeat \ + python3-pytest-rerunfailures +$ sudo apt update && sudo apt install -y libacl1-dev +## needed to execute reference system's benchmark below +## https://github.com/ros-realtime/reference-system +$ sudo pip install bokeh==2.4.3 +$ sudo pip install pandas +$ sudo pip install psrecord +## Disable preinstalled ROS 2 humble. +$ sudo rm /etc/profile.d/99-source-ros.sh +$ sudo reboot +```` +## Build ROS 2 Rolling, adopting the patches related to the REP-2017. +````bash +$ mkdir -p ros2_rolling/src +$ cd ros2_rolling +$ vcs import -w 1 src < ~/rolling-with-thread-attribute-configuration-extention-rep2017.repos +# Copy the repos file above from the repository below. +# https://github.com/esol-community/reference-system/tree/rep2017_demo/misc +$ touch src/gazebo-release/COLCON_IGNORE +$ touch src/ros2/rviz/COLCON_IGNORE +$ sudo rosdep init +$ rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers" +$ colcon build --symlink-install --executor sequential +# It takes at least 10 hours to self-build on the Raspberry Pi 4. +```` + +## Build reference-system benchmark modified to use the REP-2017 infrastructure. +````bash +$ mkdir -p ~/ros2_ws/src +$ cd ~/ros2_ws/src +$ git clone -b rep2017_demo https://github.com/esol-community/reference-system.git +$ cd ~/ros2_ws +$ source ~/ros2_rolling/install/setup.bash +$ colcon build --symlink-install --executor sequential +```` + +## Execute the benchmark(prioritized). +To get the result without thread attribute settings, execute the benchmark +without the dedicated environment variable (ROS_THREAD_ATTRS_FILE). +````bash +$ export ROS_THREAD_ATTRS_FILE= +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_prioritized_using_rep2017 +```` +To get the result with the thread attribute settings, execute the benchmark after setting the environment variable to point to the YAML configuration file. +````bash +$ export ROS_THREAD_ATTRS_FILE=~/ros2_ws/install/autoware_reference_system/share/autoware_reference_system/cfg/thread_attr_for_prioritized.yaml +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_prioritized_using_rep2017 +```` + +## Execute the benchmark(singlethreaded/multithreaded). +To get the result without thread attribute settings, execute the benchmark +without the dedicated environment variable (ROS_THREAD_ATTRS_FILE). +````bash +$ export ROS_THREAD_ATTRS_FILE= +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_singlethreaded +or +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_multithreaded + +```` +To get the result with the thread attribute settings, execute the benchmark after setting the environment variable to point to the YAML configuration file. +````bash +$ export ROS_THREAD_ATTRS_FILE=~/ros2_ws/install/autoware_reference_system/share/autoware_reference_system/cfg/thread_attr_for_existing_executors.yaml +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_singlethreaded +or +$ python3 $(ros2 pkg prefix --share autoware_reference_system)/scripts/benchmark.py 120 autoware_default_multithreaded +```` + diff --git a/misc/rolling-with-thread-attribute-configuration-extention-rep2017.repos b/misc/rolling-with-thread-attribute-configuration-extention-rep2017.repos new file mode 100755 index 00000000..e7db030b --- /dev/null +++ b/misc/rolling-with-thread-attribute-configuration-extention-rep2017.repos @@ -0,0 +1,433 @@ +repositories: + ament/ament_cmake: + type: git + url: https://github.com/ament/ament_cmake.git + version: 77c1dd758dc65f80bd6644ec80261c0f3bfa6f7f + ament/ament_index: + type: git + url: https://github.com/ament/ament_index.git + version: 1.6.0 + ament/ament_lint: + type: git + url: https://github.com/ament/ament_lint.git + version: 0.15.0 + ament/ament_package: + type: git + url: https://github.com/ament/ament_package.git + version: 0.16.2 + ament/google_benchmark_vendor: + type: git + url: https://github.com/ament/google_benchmark_vendor.git + version: 0.4.0 + ament/googletest: + type: git + url: https://github.com/ament/googletest.git + version: 1.10.9005 + ament/uncrustify_vendor: + type: git + url: https://github.com/ament/uncrustify_vendor.git + version: 2.2.0 + eProsima/Fast-CDR: + type: git + url: https://github.com/eProsima/Fast-CDR.git + version: c69dff2d908011ac0fd76dffdf35f6c56bf36059 + eProsima/Fast-DDS: + type: git + url: https://github.com/eProsima/Fast-DDS.git + version: f07a0213e655202188840b864be4438ae1067a13 + eProsima/foonathan_memory_vendor: + type: git + url: https://github.com/eProsima/foonathan_memory_vendor.git + version: v1.3.1 + eclipse-cyclonedds/cyclonedds: + type: git + url: https://github.com/eclipse-cyclonedds/cyclonedds.git + version: 1d528dec7357b7cde18336fe935a64287dcf8dc8 + eclipse-iceoryx/iceoryx: + type: git + url: https://github.com/eclipse-iceoryx/iceoryx.git + version: v2.0.3 + gazebo-release/gz_cmake2_vendor: + type: git + url: https://github.com/gazebo-release/gz_cmake2_vendor.git + version: 0.2.0 + gazebo-release/gz_math6_vendor: + type: git + url: https://github.com/gazebo-release/gz_math6_vendor.git + version: 0.2.0 + ignition/ignition_cmake2_vendor: + type: git + url: https://github.com/ignition-release/ignition_cmake2_vendor.git + version: 0.0.2 + ignition/ignition_math6_vendor: + type: git + url: https://github.com/ignition-release/ignition_math6_vendor.git + version: 0.0.2 + osrf/osrf_pycommon: + type: git + url: https://github.com/osrf/osrf_pycommon.git + version: 944277347f91843d4684bc310d42f6f14fab3c83 + osrf/osrf_testing_tools_cpp: + type: git + url: https://github.com/osrf/osrf_testing_tools_cpp.git + version: 1.7.0 + ros-perception/image_common: + type: git + url: https://github.com/ros-perception/image_common.git + version: 4.3.0 + ros-perception/laser_geometry: + type: git + url: https://github.com/ros-perception/laser_geometry.git + version: 2.6.0 + ros-planning/navigation_msgs: + type: git + url: https://github.com/ros-planning/navigation_msgs.git + version: 2.3.0 + ros-tooling/keyboard_handler: + type: git + url: https://github.com/ros-tooling/keyboard_handler.git + version: 0.2.0 + ros-tooling/libstatistics_collector: + type: git + url: https://github.com/ros-tooling/libstatistics_collector.git + version: 456fd903e8c3d5d0696fb55287ff231fad05d8d5 + ros-visualization/interactive_markers: + type: git + url: https://github.com/ros-visualization/interactive_markers.git + version: 2.5.0 + ros-visualization/python_qt_binding: + type: git + url: https://github.com/ros-visualization/python_qt_binding.git + version: 1.3.0 + ros-visualization/qt_gui_core: + type: git + url: https://github.com/ros-visualization/qt_gui_core.git + version: 1cd7985936dd11d936d0395978b68b647b32d32d + ros-visualization/rqt: + type: git + url: https://github.com/ros-visualization/rqt.git + version: b1395e86cec2fcc1a38f2f9d47aa18b73b72d36e + ros-visualization/rqt_action: + type: git + url: https://github.com/ros-visualization/rqt_action.git + version: 2.2.0 + ros-visualization/rqt_bag: + type: git + url: https://github.com/ros-visualization/rqt_bag.git + version: b9111d9a8538d33c25f833183ec9726513cd46ce + ros-visualization/rqt_console: + type: git + url: https://github.com/ros-visualization/rqt_console.git + version: 2.2.0 + ros-visualization/rqt_graph: + type: git + url: https://github.com/ros-visualization/rqt_graph.git + version: 1.5.1 + ros-visualization/rqt_msg: + type: git + url: https://github.com/ros-visualization/rqt_msg.git + version: 1ddf70b7d949b90ea88b5a138cc35d0dbf268970 + ros-visualization/rqt_plot: + type: git + url: https://github.com/ros-visualization/rqt_plot.git + version: 1.3.1 + ros-visualization/rqt_publisher: + type: git + url: https://github.com/ros-visualization/rqt_publisher.git + version: 1.7.0 + ros-visualization/rqt_py_console: + type: git + url: https://github.com/ros-visualization/rqt_py_console.git + version: 1.2.0 + ros-visualization/rqt_reconfigure: + type: git + url: https://github.com/ros-visualization/rqt_reconfigure.git + version: 1.4.0 + ros-visualization/rqt_service_caller: + type: git + url: https://github.com/ros-visualization/rqt_service_caller.git + version: 1.2.0 + ros-visualization/rqt_shell: + type: git + url: https://github.com/ros-visualization/rqt_shell.git + version: 1.2.0 + ros-visualization/rqt_srv: + type: git + url: https://github.com/ros-visualization/rqt_srv.git + version: 1.2.0 + ros-visualization/rqt_topic: + type: git + url: https://github.com/ros-visualization/rqt_topic.git + version: 1.7.0 + ros-visualization/tango_icons_vendor: + type: git + url: https://github.com/ros-visualization/tango_icons_vendor.git + version: 0.3.0 + ros/class_loader: + type: git + url: https://github.com/ros/class_loader.git + version: 2.6.0 + ros/kdl_parser: + type: git + url: https://github.com/ros/kdl_parser.git + version: 2.10.0 + ros/pluginlib: + type: git + url: https://github.com/ros/pluginlib.git + version: 5.3.0 + ros/resource_retriever: + type: git + url: https://github.com/ros/resource_retriever.git + version: 3.3.0 + ros/robot_state_publisher: + type: git + url: https://github.com/ros/robot_state_publisher.git + version: ed51b1a2dd4590125549280dedfa9f98fd994bf2 + ros/ros_environment: + type: git + url: https://github.com/ros/ros_environment.git + version: 4.2.0 + ros/ros_tutorials: + type: git + url: https://github.com/ros/ros_tutorials.git + version: 1.7.2 + ros/urdfdom: + type: git + url: https://github.com/ros/urdfdom.git + version: b5fffec979cabb9563f6f0ad3aebd92bdc978bae + ros/urdfdom_headers: + type: git + url: https://github.com/ros/urdfdom_headers.git + version: 1fd21b64ed78493508a174f98af982605d1e4607 + ros2/ament_cmake_ros: + type: git + url: https://github.com/ros2/ament_cmake_ros.git + version: 0.12.0 + ros2/common_interfaces: + type: git + url: https://github.com/ros2/common_interfaces.git + version: bf7dbe8e451704c690d4c495114a933962663790 + ros2/console_bridge_vendor: + type: git + url: https://github.com/ros2/console_bridge_vendor.git + version: 1.7.0 + ros2/demos: + type: git + url: https://github.com/ros2/demos.git + version: 1b820ba0e1ace22870be64ccd6cd3f37b3b0285e + ros2/eigen3_cmake_module: + type: git + url: https://github.com/ros2/eigen3_cmake_module.git + version: 0.3.0 + ros2/example_interfaces: + type: git + url: https://github.com/ros2/example_interfaces.git + version: 0.11.0 + ros2/examples: + type: git + url: https://github.com/ros2/examples.git + version: 780ab412ca1e9bf1b318ae555d03ec69ff5f7e1e + ros2/geometry2: + type: git + url: https://github.com/ros2/geometry2.git + version: 0.32.1 + ros2/launch: + type: git + url: https://github.com/ros2/launch.git + version: 913eae2883a821657a9535f90ca91c1903caeb1d + ros2/launch_ros: + type: git + url: https://github.com/ros2/launch_ros.git + version: 0.25.0 + ros2/libyaml_vendor: + type: git + url: https://github.com/ros2/libyaml_vendor.git + version: 1.6.0 + ros2/message_filters: + type: git + url: https://github.com/ros2/message_filters.git + version: 878f656246b1956162880dfc4dd9da796f3c4917 + ros2/mimick_vendor: + type: git + url: https://github.com/ros2/mimick_vendor.git + version: 0.4.0 + ros2/orocos_kdl_vendor: + type: git + url: https://github.com/ros2/orocos_kdl_vendor.git + version: 0.4.0 + ros2/performance_test_fixture: + type: git + url: https://github.com/ros2/performance_test_fixture.git + version: 0.2.0 + ros2/pybind11_vendor: + type: git + url: https://github.com/ros2/pybind11_vendor.git + version: 3.1.0 + ros2/python_cmake_module: + type: git + url: https://github.com/ros2/python_cmake_module.git + version: 0.11.0 + ros2/rcl: + type: git + url: https://github.com/esol-community/rcl + version: origin/sched_param_control_for_osrf + ros2/rcl_interfaces: + type: git + url: https://github.com/ros2/rcl_interfaces.git + version: 1.7.0 + ros2/rcl_logging: + type: git + url: https://github.com/ros2/rcl_logging.git + version: 2.6.0 + ros2/rclcpp: + type: git + url: https://github.com/esol-community/rclcpp + version: origin/sched_param_control_for_osrf + ros2/rclpy: + type: git + url: https://github.com/ros2/rclpy.git + version: 20125a4de2d955948db9ff58810efd03cb5603f3 + ros2/rcpputils: + type: git + url: https://github.com/esol-community/rcpputils + version: origin/sched_param_control_for_osrf + ros2/rcutils: + type: git + url: https://github.com/esol-community/rcutils + version: origin/sched_param_control_for_osrf + ros2/realtime_support: + type: git + url: https://github.com/ros2/realtime_support.git + version: 0.16.0 + ros2/rmw: + type: git + url: https://github.com/ros2/rmw.git + version: e523e4706ae6e20134fb835a91d18b74a134175e + ros2/rmw_connextdds: + type: git + url: https://github.com/ros2/rmw_connextdds.git + version: 0.15.1 + ros2/rmw_cyclonedds: + type: git + url: https://github.com/ros2/rmw_cyclonedds.git + version: 1.7.0 + ros2/rmw_dds_common: + type: git + url: https://github.com/ros2/rmw_dds_common.git + version: 2.1.0 + ros2/rmw_fastrtps: + type: git + url: https://github.com/ros2/rmw_fastrtps.git + version: 2ae7b41b85976e9b8f3b1b21e9b1f5de4d62ca4b + ros2/rmw_implementation: + type: git + url: https://github.com/ros2/rmw_implementation.git + version: 2.13.0 + ros2/ros2_tracing: + type: git + url: https://github.com/ros2/ros2_tracing.git + version: 6.4.1 + ros2/ros2cli: + type: git + url: https://github.com/ros2/ros2cli.git + version: 8523728a4f4bbb7b6fbe2b883e1ecd479c19f22b + ros2/ros2cli_common_extensions: + type: git + url: https://github.com/ros2/ros2cli_common_extensions.git + version: 0.3.0 + ros2/ros_testing: + type: git + url: https://github.com/ros2/ros_testing.git + version: 0.6.0 + ros2/rosbag2: + type: git + url: https://github.com/ros2/rosbag2.git + version: 02a70b4f76f0966f0089aa93fd97e3a68ed06b03 + ros2/rosidl: + type: git + url: https://github.com/ros2/rosidl.git + version: e3b71ece1a5c351f4656e4ce6cbe421910936bc7 + ros2/rosidl_core: + type: git + url: https://github.com/ros2/rosidl_core.git + version: 0.2.0 + ros2/rosidl_dds: + type: git + url: https://github.com/ros2/rosidl_dds.git + version: 0.11.0 + ros2/rosidl_defaults: + type: git + url: https://github.com/ros2/rosidl_defaults.git + version: 1.6.0 + ros2/rosidl_dynamic_typesupport: + type: git + url: https://github.com/ros2/rosidl_dynamic_typesupport + version: 0.1.0 + ros2/rosidl_dynamic_typesupport_fastrtps: + type: git + url: https://github.com/ros2/rosidl_dynamic_typesupport_fastrtps + version: 0.1.0 + ros2/rosidl_python: + type: git + url: https://github.com/ros2/rosidl_python.git + version: 0.19.0 + ros2/rosidl_runtime_py: + type: git + url: https://github.com/ros2/rosidl_runtime_py.git + version: 0.13.0 + ros2/rosidl_typesupport: + type: git + url: https://github.com/ros2/rosidl_typesupport.git + version: 9062d91c09a79c3b9902a8f06bca4e994121cc52 + ros2/rosidl_typesupport_fastrtps: + type: git + url: https://github.com/ros2/rosidl_typesupport_fastrtps.git + version: 3.1.0 + ros2/rpyutils: + type: git + url: https://github.com/ros2/rpyutils.git + version: 0.4.0 + ros2/rviz: + type: git + url: https://github.com/ros2/rviz.git + version: 349cb1aca46cbf732dae6f3f7c2fb2d6b0af40e1 + ros2/spdlog_vendor: + type: git + url: https://github.com/ros2/spdlog_vendor.git + version: 1.5.0 + ros2/sros2: + type: git + url: https://github.com/ros2/sros2.git + version: 0.12.1 + ros2/system_tests: + type: git + url: https://github.com/ros2/system_tests.git + version: 0.16.1 + ros2/test_interface_files: + type: git + url: https://github.com/ros2/test_interface_files.git + version: 0.11.0 + ros2/tinyxml2_vendor: + type: git + url: https://github.com/ros2/tinyxml2_vendor.git + version: 0.9.0 + ros2/tinyxml_vendor: + type: git + url: https://github.com/ros2/tinyxml_vendor.git + version: 0.10.0 + ros2/tlsf: + type: git + url: https://github.com/ros2/tlsf.git + version: 0.9.0 + ros2/unique_identifier_msgs: + type: git + url: https://github.com/ros2/unique_identifier_msgs.git + version: 2.4.0 + ros2/urdf: + type: git + url: https://github.com/ros2/urdf.git + version: 2.9.0 + ros2/yaml_cpp_vendor: + type: git + url: https://github.com/ros2/yaml_cpp_vendor.git + version: 8.2.0