From 81c7adac1fcaf24a5f2531fb9e7686df25b1bb17 Mon Sep 17 00:00:00 2001 From: "jack.song" Date: Thu, 15 Dec 2022 13:12:16 +0800 Subject: [PATCH 1/4] task-scheduling Signed-off-by: jack.song --- .../ros-nodes/task-scheduling.md | 92 ++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md index 18e0866021e..2e6eb6c75d9 100644 --- a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md +++ b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md @@ -1,5 +1,93 @@ # Task scheduling -!!! warning +## Scheduing in autoware - Under Construction +The software of autoware is the system of multiple nodes.In ROS2 the executor uses one or more threads of the underlying operating system to invoke the callbacks. The different type of callback has the different priority. +In autoware,there are two types about "publish-subscribe": +- Timer callback +- Subscription callback + +Timer callback has the high priority.For those with the same priority, the execution order is determined according to the registration order. +For example about timer callback: +```C++ + const auto planning_hz = declare_parameter("planning_hz", 10.0); + const auto period_ns = rclcpp::Rate(planning_hz).period(); + timer_ = rclcpp::create_timer( + this, get_clock(), period_ns, std::bind(&BehaviorPathPlannerNode::run, this)); +``` +For example about subscription callback: +```C++ + route_subscriber_ = create_subscription( + "~/input/route", qos_transient_local, std::bind(&BehaviorPathPlannerNode::onRoute, this, _1), + createSubscriptionOptions(this)); +``` +In autoware,you can use the create_callback_group() to organizing the callbacks of a node in groups. +For example: +```C++ + rclcpp::CallbackGroup::SharedPtr callback_group = + node_ptr->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); +``` +The type of MutuallyExclusive ensure that callbacks of this group must not be executed in parallel.You can see more information about scheduling of ROS2 in theses links: +- +- + +## Analyse of data flow and running time + +In autoware,there are many topics used by different nodes.You can analyse the data flow and running time of multiple nodes in the whole software. By the analyse,you can intuitively understand the nodes operation path and input/output flow.You can use CARET or TILDE of autoware to finish the analyse. + +### CARET + +By using caret,you can trace the application without changing codes of application.You can analyse the latency and the running time of nodes. + You can install TIDLE by following steps: + 1. Clone caret and enter the directory. + ```bash + git clone https://github.com/tier4/caret.git ros2_caret_ws + cd ros2_caret_ws + ``` + 2. Create the src directory and clone repositories into it. + ```bash + mkdir src + vcs import src < caret.repos --recursive + ``` + 3. Run setup_caret.sh. + ```bash + ./setup_caret.sh + ``` + 4. Build the workspace. + ```bash + source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) + colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release + ``` + 5. Check whether CARET (ros2-tracing) is enabled. + ```bash + source ~/ros2_caret_ws/install/local_setup.bash + ros2 run tracetools status # return Tracing enabled + ``` + +You can get more information in the link: + +- + +### TILDE + +TILDE is a framework for latency measurement and deadline detection across multiple nodes. TILDE can track the topic output from the node and identify the original input topic. Latency measurement and deadline detection are possible to trace from input to output.By using the TILDE,you need change the codes of application and add the apis of TILDE in the application. +You can install TIDLE by following steps: + 1. Clone TILDE and enter the directory. + ```bash + git clone https://github.com/tier4/TILDE.git ros2_TILDE_ws + cd ros2_TILDE_ws + ``` + 2. Create the src directory and clone repositories into it. + ```bash + mkdir src + vcs import src < build_depends.repos + ``` + 3. Build the workspace. + ```bash + source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) + colcon build --symlink-install --cmake-args --cmake-args -DCMAKE_BUILD_TYPE=Release + ``` + +You can get more information in the link: + +- From 3527d25804d683a3ba7f701a65d692f7d50e5b1d Mon Sep 17 00:00:00 2001 From: "jack.song" Date: Thu, 15 Dec 2022 13:20:33 +0800 Subject: [PATCH 2/4] task-scheduling Signed-off-by: jack.song --- .../ros-nodes/task-scheduling.md | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md index 2e6eb6c75d9..20eb4717152 100644 --- a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md +++ b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md @@ -4,32 +4,40 @@ The software of autoware is the system of multiple nodes.In ROS2 the executor uses one or more threads of the underlying operating system to invoke the callbacks. The different type of callback has the different priority. In autoware,there are two types about "publish-subscribe": + - Timer callback - Subscription callback Timer callback has the high priority.For those with the same priority, the execution order is determined according to the registration order. For example about timer callback: + ```C++ const auto planning_hz = declare_parameter("planning_hz", 10.0); const auto period_ns = rclcpp::Rate(planning_hz).period(); timer_ = rclcpp::create_timer( this, get_clock(), period_ns, std::bind(&BehaviorPathPlannerNode::run, this)); ``` + For example about subscription callback: + ```C++ route_subscriber_ = create_subscription( "~/input/route", qos_transient_local, std::bind(&BehaviorPathPlannerNode::onRoute, this, _1), createSubscriptionOptions(this)); ``` + In autoware,you can use the create_callback_group() to organizing the callbacks of a node in groups. For example: + ```C++ rclcpp::CallbackGroup::SharedPtr callback_group = node_ptr->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive); ``` + The type of MutuallyExclusive ensure that callbacks of this group must not be executed in parallel.You can see more information about scheduling of ROS2 in theses links: + - -- +- ## Analyse of data flow and running time @@ -39,26 +47,36 @@ In autoware,there are many topics used by different nodes.You can analyse the da By using caret,you can trace the application without changing codes of application.You can analyse the latency and the running time of nodes. You can install TIDLE by following steps: + 1. Clone caret and enter the directory. + ```bash git clone https://github.com/tier4/caret.git ros2_caret_ws cd ros2_caret_ws ``` + 2. Create the src directory and clone repositories into it. + ```bash mkdir src vcs import src < caret.repos --recursive ``` + 3. Run setup_caret.sh. + ```bash ./setup_caret.sh ``` + 4. Build the workspace. + ```bash source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release ``` + 5. Check whether CARET (ros2-tracing) is enabled. + ```bash source ~/ros2_caret_ws/install/local_setup.bash ros2 run tracetools status # return Tracing enabled @@ -72,17 +90,23 @@ You can get more information in the link: TILDE is a framework for latency measurement and deadline detection across multiple nodes. TILDE can track the topic output from the node and identify the original input topic. Latency measurement and deadline detection are possible to trace from input to output.By using the TILDE,you need change the codes of application and add the apis of TILDE in the application. You can install TIDLE by following steps: + 1. Clone TILDE and enter the directory. + ```bash git clone https://github.com/tier4/TILDE.git ros2_TILDE_ws cd ros2_TILDE_ws ``` + 2. Create the src directory and clone repositories into it. + ```bash mkdir src vcs import src < build_depends.repos ``` + 3. Build the workspace. + ```bash source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) colcon build --symlink-install --cmake-args --cmake-args -DCMAKE_BUILD_TYPE=Release From c222d70961e98320bf6bd093fc05718f65033060 Mon Sep 17 00:00:00 2001 From: "jack.song" Date: Thu, 15 Dec 2022 13:38:51 +0800 Subject: [PATCH 3/4] task-scheduling Signed-off-by: jack.song --- .../ros-nodes/task-scheduling.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md index 20eb4717152..dceef859672 100644 --- a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md +++ b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md @@ -36,9 +36,9 @@ For example: The type of MutuallyExclusive ensure that callbacks of this group must not be executed in parallel.You can see more information about scheduling of ROS2 in theses links: -- +- - - + ## Analyse of data flow and running time In autoware,there are many topics used by different nodes.You can analyse the data flow and running time of multiple nodes in the whole software. By the analyse,you can intuitively understand the nodes operation path and input/output flow.You can use CARET or TILDE of autoware to finish the analyse. @@ -46,36 +46,36 @@ In autoware,there are many topics used by different nodes.You can analyse the da ### CARET By using caret,you can trace the application without changing codes of application.You can analyse the latency and the running time of nodes. - You can install TIDLE by following steps: +You can install TIDLE by following steps: - 1. Clone caret and enter the directory. +1. Clone caret and enter the directory. ```bash git clone https://github.com/tier4/caret.git ros2_caret_ws cd ros2_caret_ws ``` - 2. Create the src directory and clone repositories into it. +2. Create the src directory and clone repositories into it. ```bash mkdir src vcs import src < caret.repos --recursive ``` - 3. Run setup_caret.sh. +3. Run setup_caret.sh. ```bash ./setup_caret.sh ``` - 4. Build the workspace. +4. Build the workspace. ```bash source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release ``` - 5. Check whether CARET (ros2-tracing) is enabled. +5. Check whether CARET (ros2-tracing) is enabled. ```bash source ~/ros2_caret_ws/install/local_setup.bash @@ -91,21 +91,21 @@ You can get more information in the link: TILDE is a framework for latency measurement and deadline detection across multiple nodes. TILDE can track the topic output from the node and identify the original input topic. Latency measurement and deadline detection are possible to trace from input to output.By using the TILDE,you need change the codes of application and add the apis of TILDE in the application. You can install TIDLE by following steps: - 1. Clone TILDE and enter the directory. +1. Clone TILDE and enter the directory. ```bash git clone https://github.com/tier4/TILDE.git ros2_TILDE_ws cd ros2_TILDE_ws ``` - 2. Create the src directory and clone repositories into it. +2. Create the src directory and clone repositories into it. ```bash mkdir src vcs import src < build_depends.repos ``` - 3. Build the workspace. +3. Build the workspace. ```bash source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) From 6b683cb03192d0762cac3c38aa2fd64e33ff5a24 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 05:39:09 +0000 Subject: [PATCH 4/4] style(pre-commit): autofix --- .../ros-nodes/task-scheduling.md | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md index dceef859672..c1c6043ed0a 100644 --- a/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md +++ b/docs/contributing/coding-guidelines/ros-nodes/task-scheduling.md @@ -6,7 +6,7 @@ The software of autoware is the system of multiple nodes.In ROS2 the executor us In autoware,there are two types about "publish-subscribe": - Timer callback -- Subscription callback +- Subscription callback Timer callback has the high priority.For those with the same priority, the execution order is determined according to the registration order. For example about timer callback: @@ -50,37 +50,37 @@ You can install TIDLE by following steps: 1. Clone caret and enter the directory. - ```bash - git clone https://github.com/tier4/caret.git ros2_caret_ws - cd ros2_caret_ws - ``` + ```bash + git clone https://github.com/tier4/caret.git ros2_caret_ws + cd ros2_caret_ws + ``` 2. Create the src directory and clone repositories into it. - ```bash - mkdir src - vcs import src < caret.repos --recursive - ``` + ```bash + mkdir src + vcs import src < caret.repos --recursive + ``` 3. Run setup_caret.sh. - ```bash - ./setup_caret.sh - ``` + ```bash + ./setup_caret.sh + ``` 4. Build the workspace. - ```bash - source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) - colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release - ``` + ```bash + source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) + colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release + ``` 5. Check whether CARET (ros2-tracing) is enabled. - ```bash - source ~/ros2_caret_ws/install/local_setup.bash - ros2 run tracetools status # return Tracing enabled - ``` + ```bash + source ~/ros2_caret_ws/install/local_setup.bash + ros2 run tracetools status # return Tracing enabled + ``` You can get more information in the link: @@ -93,24 +93,24 @@ You can install TIDLE by following steps: 1. Clone TILDE and enter the directory. - ```bash - git clone https://github.com/tier4/TILDE.git ros2_TILDE_ws - cd ros2_TILDE_ws - ``` + ```bash + git clone https://github.com/tier4/TILDE.git ros2_TILDE_ws + cd ros2_TILDE_ws + ``` 2. Create the src directory and clone repositories into it. - ```bash - mkdir src - vcs import src < build_depends.repos - ``` + ```bash + mkdir src + vcs import src < build_depends.repos + ``` 3. Build the workspace. - ```bash - source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) - colcon build --symlink-install --cmake-args --cmake-args -DCMAKE_BUILD_TYPE=Release - ``` + ```bash + source /opt/ros/galactic/setup.bash(or source /opt/ros/humble/setup.bash) + colcon build --symlink-install --cmake-args --cmake-args -DCMAKE_BUILD_TYPE=Release + ``` You can get more information in the link: