Skip to content
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

test_nodes: catch keyboard interrupt and add simple launch tests (backport #1369) #1371

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 18, 2024

When the test nodes are shut down by ctrl-c keyboard interrupt we see this verbose console output

    [publisher_forward_position_controller-15] Traceback (most recent call last):
    [publisher_forward_position_controller-15]   File "/home/runner/work/ros2_control_demos/ros2_control_demos/.work/upstream_ws/install/ros2_controllers_test_nodes/lib/ros2_controllers_test_nodes/publisher_forward_position_controller", line 33, in <module>
    [publisher_forward_position_controller-15]     sys.exit(load_entry_point('ros2-controllers-test-nodes==3.28.0', 'console_scripts', 'publisher_forward_position_controller')())
    [publisher_forward_position_controller-15]   File "/home/runner/work/ros2_control_demos/ros2_control_demos/.work/upstream_ws/install/ros2_controllers_test_nodes/lib/python3.10/site-packages/ros2_controllers_test_nodes/publisher_forward_position_controller.py", line 71, in main
    [publisher_forward_position_controller-15]     rclpy.spin(publisher_forward_position)
    [publisher_forward_position_controller-15]   File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/__init__.py", line 228, in spin
    [publisher_forward_position_controller-15]     executor.spin_once()
    [publisher_forward_position_controller-15]   File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 787, in spin_once
    [publisher_forward_position_controller-15]     self._spin_once_impl(timeout_sec)
    [publisher_forward_position_controller-15]   File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 776, in _spin_once_impl
    [publisher_forward_position_controller-15]     handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
    [publisher_forward_position_controller-15]   File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 762, in wait_for_ready_callbacks
    [publisher_forward_position_controller-15]     return next(self._cb_iter)
    [publisher_forward_position_controller-15]   File "/opt/ros/iron/lib/python3.10/site-packages/rclpy/executors.py", line 666, in _wait_for_ready_callbacks
    [publisher_forward_position_controller-15]     wait_set.wait(timeout_nsec)
    [publisher_forward_position_controller-15] KeyboardInterrupt

With the proposed changes, we get a nice

 $ ros2 run ros2_controllers_test_nodes publisher_forward_position_controller --ros-args --params-file src/ros2_control_demos/example_1/bringup/config/rrbot_forward_position_publisher.yaml 
[INFO] [1731859611.015984561] [publisher_forward_position_controller]: Publishing 4 goals on topic '/forward_position_controller/commands' every 5 s'
[INFO] [1731859616.018749700] [publisher_forward_position_controller]: Publishing: "array('d', [0.785, 0.785])"
^CKeyboard interrupt received. Shutting down node.
```<hr>This is an automatic backport of pull request #1369 done by [Mergify](https://mergify.com).

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 90.56604% with 10 lines in your changes missing coverage. Please review.

Project coverage is 66.27%. Comparing base (5fcc9fd) to head (e723cdd).
Report is 1 commits behind head on humble.

Files with missing lines Patch % Lines
...est_nodes/publisher_forward_position_controller.py 44.44% 4 Missing and 1 partial ⚠️
...est_nodes/publisher_joint_trajectory_controller.py 44.44% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           humble    #1371      +/-   ##
==========================================
+ Coverage   65.27%   66.27%   +1.00%     
==========================================
  Files         108      110       +2     
  Lines       12562    12662     +100     
  Branches     7805     7815      +10     
==========================================
+ Hits         8200     8392     +192     
+ Misses       1522     1415     -107     
- Partials     2840     2855      +15     
Flag Coverage Δ
unittests 66.27% <90.56%> (+1.00%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ros2_controllers_test_nodes/setup.py 0.00% <ø> (ø)
...st_publisher_forward_position_controller_launch.py 100.00% <100.00%> (ø)
...st_publisher_joint_trajectory_controller_launch.py 100.00% <100.00%> (ø)
...est_nodes/publisher_forward_position_controller.py 80.43% <44.44%> (+80.43%) ⬆️
...est_nodes/publisher_joint_trajectory_controller.py 54.03% <44.44%> (+54.03%) ⬆️

@christophfroehlich christophfroehlich merged commit 1d152cb into humble Nov 18, 2024
10 of 13 checks passed
@christophfroehlich christophfroehlich deleted the mergify/bp/humble/pr-1369 branch November 18, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant