Skip to content

set the priority of callback to high introduces some delay compared to simple MultiThreadedExecutor #427

Open

Description

@xibeisiber

hi, I try to set one callback higher priority following the example cbg_executor . But It seems it introduces some delay compared to using MultiThreadedExecutor.

I publish on the topic "high_pong" at rate 100Hz. In the pong_node.cpp, I set the parameter "high_busyloop" to 1.0, and print the timestamp when receiving the msg.
Use the code in pong.cpp (setting high_prio_executor to ThreadPriority::HIGH), the output is (msg receiving interval is 1050ms):

Image

But if I simply use MultiThreadedExecutor and add the pong node:

  auto pong_node = std::make_shared<PongNode>();
  rclcpp::executors::MultiThreadedExecutor multi_executor1;
  multi_executor1.add_node(pong_node);
  multi_executor1.spin();
  rclcpp::shutdown();
  return 0;

the output is (msg receiving interval is 1000ms):

Image

Activity

  1. fujitatomoya commented on Sep 16, 2025

    @fujitatomoya
    Collaborator

    @xibeisiber can you provide the self-contained reproducible example to see the difference?

  2. xibeisiber commented on Sep 17, 2025

    @xibeisiber
    Author

    See attached file:
    cbg_executor.zip

    compile:
    colcon build --packages-up-to examples_rclcpp_cbg_executor

    In one terminal, publish on the topic at 100Hz
    ros2 topic pub /high_ping std_msgs/msg/Int32 -r 100

    case1: run (setting high_prio_executor to ThreadPriority::HIGH)
    ros2 run examples_rclcpp_cbg_executor pong

    case2: run (simply use MultiThreadedExecutor and add the pong node:)
    ros2 run examples_rclcpp_cbg_executor pong_multi_executor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions