-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(contributing): add task scheduling #282
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,117 @@ | ||||||||||||||
# 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": | ||||||||||||||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Reference documentation: https://docs.ros2.org/latest/api/rclpy/api/execution_and_callbacks.html#module-rclpy.executors Also made some small fixes like spaces after commas and periods. |
||||||||||||||
|
||||||||||||||
- 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<LaneletRoute>( | ||||||||||||||
"~/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: | ||||||||||||||
|
||||||||||||||
- <https://docs.ros.org/en/humble/Concepts/About-Executors.html> | ||||||||||||||
- <https://docs.ros.org/en/humble/How-To-Guides/Using-callback-groups.html> | ||||||||||||||
|
||||||||||||||
## 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 | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
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) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Installation of caret for galactic should not be mentioned here, I think.
Suggested change
|
||||||||||||||
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: | ||||||||||||||
|
||||||||||||||
- <https://tier4.github.io/CARET_doc/> | ||||||||||||||
|
||||||||||||||
### 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: | ||||||||||||||
|
||||||||||||||
- <https://github.com/tier4/TILDE/blob/master/doc/README.md> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that there are two types of trigger for executing callback, but it is not "publish-subscribe", strictly speaking.