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 #1369

Merged
merged 5 commits into from
Nov 18, 2024

Conversation

christophfroehlich
Copy link
Contributor

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.

@christophfroehlich christophfroehlich added the backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble. label Nov 17, 2024
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

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

Project coverage is 82.57%. Comparing base (28dd7e1) to head (b0cbe8e).
Report is 1 commits behind head on master.

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             @@
##           master    #1369      +/-   ##
==========================================
+ Coverage   81.47%   82.57%   +1.09%     
==========================================
  Files         110      112       +2     
  Lines        9823     9920      +97     
  Branches      860      867       +7     
==========================================
+ Hits         8003     8191     +188     
+ Misses       1541     1438     -103     
- Partials      279      291      +12     
Flag Coverage Δ
unittests 82.57% <90.56%> (+1.09%) ⬆️

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.00% <44.44%> (+80.00%) ⬆️
...est_nodes/publisher_joint_trajectory_controller.py 57.52% <44.44%> (+57.52%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@christophfroehlich christophfroehlich changed the title test_nodes: catch keyboard interrupt test_nodes: catch keyboard interrupt and add simple launch tests Nov 17, 2024
@christophfroehlich christophfroehlich marked this pull request as draft November 18, 2024 07:49
@christophfroehlich christophfroehlich marked this pull request as ready for review November 18, 2024 08:48
@github-actions github-actions bot requested review from fmauch and moriarty November 18, 2024 08:48
Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bmagyar bmagyar merged commit 2e57917 into master Nov 18, 2024
20 of 22 checks passed
@bmagyar bmagyar deleted the fix/publisher_nodes branch November 18, 2024 12:17
mergify bot pushed a commit that referenced this pull request Nov 18, 2024
@christophfroehlich
Copy link
Contributor Author

I'm a little bit puzzled about the fact that the code in the finally branch has zero coverage. maybe rlcpy.ok() is always false here. Should the destroy_node() be called even if the context is not valid any more? @saikishor any idea?

image

christophfroehlich added a commit that referenced this pull request Nov 18, 2024
…) (#1371)

(cherry picked from commit 2e57917)

Co-authored-by: Christoph Fröhlich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-humble This label should be used by maintainers only! Label triggers PR backport to ROS2 humble.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants