ros2 / rclcpp

rclcpp (ROS Client Library for C++)
Apache License 2.0
513 stars 412 forks source link

StaticSingleThreadedExecutor uses spin_once in spin #2470

Open jmachowinski opened 3 months ago

jmachowinski commented 3 months ago

This change seems to have been made in https://github.com/ros2/rclcpp/pull/2142

https://github.com/ros2/rclcpp/blob/c5bc4b65284c71a86fc1758cc7eeb22204aa2bdd/rclcpp/src/rclcpp/executors/static_single_threaded_executor.cpp#L41C1-L43C4

  while (rclcpp::ok(this->context_) && spinning.load()) {
    this->spin_once_impl(std::chrono::nanoseconds(-1));
  }

I guess it should be

  while (rclcpp::ok(this->context_) && spinning.load()) {
    this->spin_all(std::chrono::nanoseconds(0));
  }

@mjcarroll @wjwwood

alsora commented 3 months ago

I think that in theory, with https://github.com/ros2/rclcpp/pull/2142, the performance of the SingleThreadedExecutor should have become comparable to the StaticSingleThreadedExecutor, which could thus be removed.