-
Notifications
You must be signed in to change notification settings - Fork 120
Replace deprecated rclcpp::spin_some() #541
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
Replace deprecated rclcpp::spin_some() #541
Conversation
… with a SingleThreadedExecutor in pid_ros_parameters_tests.cpp. Aligns the test with current rclcpp API.
…cutor in SetBadParametersTest.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #541 +/- ##
==========================================
+ Coverage 83.01% 83.13% +0.12%
==========================================
Files 29 29
Lines 1967 1981 +14
Branches 110 110
==========================================
+ Hits 1633 1647 +14
Misses 268 268
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Thanks for starting this. However, there are 8 more ocurrences of rclcpp::spin_some in pid_ros_publisher_tests, have a look at the build logs here:
2025-11-02T03:11:53.1740173Z �[1m$ ( source /home/runner/work/control_toolbox/control_toolbox/.work/upstream_ws/install/setup.bash && cd /home/runner/work/control_toolbox/control_toolbox/.work/target_ws && colcon build --event-handlers desktop_notification- status- terminal_title- --cmake-args -DCMAKE_CXX_FLAGS=-isystem /opt/ros/rolling/include; )�[0m
2025-11-02T03:11:53.1742357Z Starting >>> control_toolbox
2025-11-02T03:11:53.1742781Z --- stderr: control_toolbox
2025-11-02T03:11:53.1745149Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:�[m�[K In member function ‘�[01m�[Kvirtual void PidPublisherTest_PublishTest_Test::�[01;32m�[KTestBody�[m�[K()�[m�[K’:
2025-11-02T03:11:53.1749923Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:69:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1752326Z 69 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1752945Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1754775Z In file included from �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:25�[m�[K:
2025-11-02T03:11:53.1756708Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1758176Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1758844Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1761274Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:�[m�[K In member function ‘�[01m�[Kvirtual void PidPublisherTest_PublishTest_start_deactivated_Test::�[01;32m�[KTestBody�[m�[K()�[m�[K’:
2025-11-02T03:11:53.1765517Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:113:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1768208Z 113 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1769122Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1770260Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1771502Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1772176Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1774937Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:129:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1777745Z 129 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1778346Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1779437Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1780665Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1781330Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1784083Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:138:20:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1787102Z 138 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K; // process callbacks to ensure that no further messages are received
2025-11-02T03:11:53.1788089Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1789170Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1790415Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1791072Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1793836Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:146:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1796246Z 146 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1796886Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1798258Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1799775Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1800412Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1802715Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:�[m�[K In member function ‘�[01m�[Kvirtual void PidPublisherTest_PublishTest_prefix_Test::�[01;32m�[KTestBody�[m�[K()�[m�[K’:
2025-11-02T03:11:53.1806895Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:189:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1809531Z 189 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1810170Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1811250Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1812392Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1813182Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1815186Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:�[m�[K In member function ‘�[01m�[Kvirtual void PidPublisherTest_PublishTest_local_prefix_Test::�[01;32m�[KTestBody�[m�[K()�[m�[K’:
2025-11-02T03:11:53.1818887Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:233:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(Node::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:11:53.1820883Z 233 | �[01;35m�[Krclcpp::spin_some(node)�[m�[K;
2025-11-02T03:11:53.1821367Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~�[m�[K
2025-11-02T03:11:53.1822234Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:109:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:11:53.1823210Z 109 | �[01;36m�[Kspin_some�[m�[K(rclcpp::Node::SharedPtr node_ptr);
2025-11-02T03:11:53.1823815Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:11:53.1825700Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:�[m�[K In member function ‘�[01m�[Kvirtual void PidPublisherTest_PublishTestLifecycle_Test::�[01;32m�[KTestBody�[m�[K()�[m�[K’:
2025-11-02T03:11:53.1829501Z �[01m�[K/home/runner/work/control_toolbox/control_toolbox/.work/target_ws/src/control_toolbox/control_toolbox/test/pid_ros_publisher_tests.cpp:337:22:�[m�[K �[01;35m�[Kwarning: �[m�[K‘�[01m�[Kvoid rclcpp::�[01;32m�[Kspin_some�[m�[K(node_interfaces::NodeBaseInterface::SharedPtr)�[m�[K’ is deprecated: use SingleThreadedExecutor::spin_some instead [�[01;35m�[K-Wdeprecated-declarations�[m�[K]
2025-11-02T03:12:02.2847256Z 337 | �[01;35m�[Krclcpp::spin_some(node->get_node_base_interface())�[m�[K;
2025-11-02T03:12:02.2848537Z | �[01;35m�[K~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~�[m�[K
2025-11-02T03:12:02.2852840Z �[01m�[K/opt/ros/rolling/include/rclcpp/rclcpp/executors.hpp:90:1:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
2025-11-02T03:12:02.2856519Z 90 | �[01;36m�[Kspin_some�[m�[K(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
2025-11-02T03:12:02.2857500Z | �[01;36m�[K^~~~~~~~~�[m�[K
2025-11-02T03:12:02.2857926Z ---
2025-11-02T03:12:02.2858269Z Finished <<< control_toolbox [8.04s]
Do you mind cleaning them up all at once?
On it now! |
…Test, PublishTest_start_deactivated).
…st, PublishTest_prefix).
…st, PublishTest_local_prefix).
…st, PublishTestLifecycle), since it was previously using the node-base-interface overload we use the same executor pattern as other commits just add the lifecycle node to the executor.
2666661
|
I have now made changes to the script pid_ros_publisher_tests.cpp. Let me know if any more changes are needed. |
christophfroehlich
left a comment
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.
Thanks, there are no more warnings in the logs!
(cherry picked from commit 18c4b12)
Overview
This PR replaces deprecated rclcpp::spin_some(...) calls in control_toolbox/test/pid_ros_parameters_tests.cpp with a rclcpp::executors::SingleThreadedExecutor, as suggested in #488.
What changed
Files changed are:
In this PR we update control_toolbox/control_toolbox/test/pid_ros_parameters_tests.cpp so that the two tests which were using the deprecated rclcpp::spin_some(...) now create a rclcpp::executors::SingleThreadedExecutor, add the test node to it once, and call executor.spin_some() instead. This applies to TEST(PidParametersTest, SetParametersTest) and to TEST(PidParametersTest, SetBadParametersTest), where we replaced all the previous rclcpp::spin_some(...) calls with the executor-based version to match the current ROS 2 recommendation and to remove the deprecation warning.
Notes for Reviewer
I am very open to feedback and am happy to make any changes that are requested.