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

refactor SwitchParams to fix the incosistencies in the spawner tests (backport #1638) #1659

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Aug 9, 2024

This PR aims to fix the inconsistencies that are observed with the spawner_unspawner tests and could be reproducible at higher frequencies as well. It seems to be that due to the wall_timer etc the manager_switch was trigger twice and causing the crashes, and upon checking there are missing guards and mutexes to protect this context.

The changes are also tested on the real hardware! :)

The following failures are caused with the current setup and is solved with the changes proposed in this PR:

1: [WARN] [1722085254.107041328] [spawner_ctrl_1]: Controller already loaded, skipping load_controller
1: [INFO] [1722085254.107959063] [test_controller_manager]: Configuring controller 'ctrl_1'
1: [WARN] [1722085254.125499381] [rcl_lifecycle]: No transition matching 3 found for current state activating
1: [ERROR] [1722085254.125529455] [ctrl_1]: Unable to start transition 3 from current state activating: Transition is not registered., at ./src/rcl_lifecycle.c:355
1: [ERROR] [1722085254.125577475] [test_controller_manager]: After activation, controller 'ctrl_1' is in state 'activating' (13), expected 'active' (3).
1: [INFO] [1722085254.136365765] [spawner_ctrl_1]: Configured and activated ctrl_1
1: [INFO] [1722085254.308361830] [test_controller_manager]: Loading controller 'ctrl_1'
1: [INFO] [1721556773.163766473] [test_controller_manager]: Configuring controller 'ctrl_3'
1: terminate called after throwing an instance of 'std::runtime_error'
1:   what():  Can not get command interface configuration until the controller is configured. The current state is : activating and ID : 13 and ACTIVE is : 3 and INACTIVE IS : 2
1: Stack trace (most recent call last) in thread 112351:
1: [INFO] [1721560930.460608458] [test_controller_manager]: Configuring controller 'ctrl_3'
1: [WARN] [1721560930.479481009] [rcl_lifecycle]: No transition matching 3 found for current state activating
1: [ERROR] [1721560930.479493504] [ctrl_1]: Unable to start transition 3 from current state activating: Transition is not registered., at ./src/rcl_lifecycle.c:355
1: [ERROR] [1721560930.479538729] [test_controller_manager]: After activation, controller 'ctrl_1' is in state 'activating' (13), expected 'active' (3).
1: terminate called after throwing an instance of 'std::runtime_error'
1:   what():  Can not get command interface configuration until the controller is configured. The current state is : activating and ID : 13 and ACTIVE is : 3 and INACTIVE IS : 2
1: Stack trace (most recent call last) in thread 227964:
1: #21   Object "", at 0xffffffffffffffff, in 
1: [INFO] [1721560930.490672863] [spawner_ctrl_1]: Configured and activated all the parsed controllers list!
1: #20   Source "../sysdeps/unix/sysv/linux/x86_64/clone3.S", line 81, in __clone3 [0x7fe73cdf584f]
1: [INFO] [1721716958.916360995] [test_controller_manager]: Loading controller 'ctrl_1'
1: [INFO] [1721716958.935490861] [spawner_ctrl_1]: Loaded ctrl_1
1: [INFO] [1721716958.936473516] [test_controller_manager]: Configuring controller 'ctrl_1'
1: [INFO] [1721716958.943142165] [spawner_ctrl_1]: Configured ctrl_1 successfully
1: [INFO] [1721716958.943535316] [spawner_ctrl_1]: Activating ctrl_1
1: [INFO] [1721716958.944450162] [test_controller_manager]: Found controller 'ctrl_1' that needs to be activateed in list of controllers. Adding to the list!
1: [INFO] [1721716958.952596909] [test_controller_manager]: Entering manager switch and before activate controllers. 3720000000
1: [INFO] [1721716958.952633229] [test_controller_manager]: Entering manager switch and before activate controllers. 3720000000
1: [INFO] [1721716958.952635535] [test_controller_manager]: Activating controllers: ctrl_1, 
1: [INFO] [1721716958.952672064] [test_controller_manager]: Activating controllers: ctrl_1, 
1: [INFO] [1721716958.952687694] [test_controller_manager]: Activating controller 'ctrl_1' with current state : inactive
1: [INFO] [1721716958.952703837] [test_controller_manager]: Activating controller 'ctrl_1' with current state : inactive
1: [INFO] [1721716958.952738683] [test_controller_manager]: Switching done : 0 at 3720000000
1: [ERROR] [1721716958.952773682] [test_controller_manager]: Could not extract state interfaces for controller 'ctrl_1': Can not get state interface configuration until the controller is configured. The current state is : activating and ID : 13 and ACTIVE is : 3 and INACTIVE IS : 2
1: terminate called after throwing an instance of 'std::runtime_error'
1:   what():  Can not get state interface configuration until the controller is configured. The current state is : activating and ID : 13 and ACTIVE is : 3 and INACTIVE IS : 2
1: [INFO] [1721716958.952890889] [test_controller_manager]: Successfully switched controllers. Activated: ctrl_1, 
1: Stack trace (most recent call last) in thread 60496:
1: #20   Object "", at 0xffffffffffffffff, in 
1: [INFO] [1721716958.963346793] [spawner_ctrl_1]: Configured and activated ctrl_1
1: [INFO] [1721716958.964605158] [test_controller_manager]: Loading controller 'ctrl_3'
1: [INFO] [1721716958.973829860] [spawner_ctrl_1]: Loaded ctrl_3

Fixes: #1637
Fixes: #1368
Fixes: #1647
Fixes: #1657
Fixes: #1644
Fixes: ros-controls/ros2_control_ci#105
Fixes: ros-controls/ros2_control_ci#106
Fixes: ros-controls/ros2_control_ci#107
Fixes: ros-controls/ros2_control_ci#108


This is an automatic backport of pull request #1638 done by [Mergify](https://mergify.com).

…1638)

(cherry picked from commit a1ad523)

# Conflicts:
#	controller_manager/src/controller_manager.cpp
Copy link
Contributor Author

mergify bot commented Aug 9, 2024

Cherry-pick of a1ad523 has failed:

On branch mergify/bp/humble/pr-1638
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit a1ad523.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   controller_manager/include/controller_manager/controller_manager.hpp
	modified:   controller_manager/test/test_controller_manager_srvs.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   controller_manager/src/controller_manager.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the conflicts label Aug 9, 2024
@christophfroehlich christophfroehlich linked an issue Aug 11, 2024 that may be closed by this pull request
Copy link

codecov bot commented Aug 11, 2024

Codecov Report

Attention: Patch coverage is 85.18519% with 4 lines in your changes missing coverage. Please review.

Project coverage is 87.00%. Comparing base (c04a16f) to head (6062b90).
Report is 13 commits behind head on humble.

Files Patch % Lines
controller_manager/src/controller_manager.cpp 75.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           humble    #1659      +/-   ##
==========================================
- Coverage   87.00%   87.00%   -0.01%     
==========================================
  Files          97       97              
  Lines        7505     7527      +22     
  Branches      677      678       +1     
==========================================
+ Hits         6530     6549      +19     
- Misses        688      691       +3     
  Partials      287      287              
Flag Coverage Δ
unittests 87.00% <85.18%> (-0.01%) ⬇️

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

Files Coverage Δ
.../include/controller_manager/controller_manager.hpp 100.00% <100.00%> (ø)
...ller_manager/test/test_controller_manager_srvs.cpp 99.16% <100.00%> (+<0.01%) ⬆️
controller_manager/src/controller_manager.cpp 71.95% <75.00%> (+0.08%) ⬆️

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

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

this breaks ABI of an internal class, so this should not be a big deal?

@christophfroehlich christophfroehlich linked an issue Aug 14, 2024 that may be closed by this pull request
@bmagyar bmagyar merged commit 8779757 into humble Aug 14, 2024
7 of 10 checks passed
@bmagyar bmagyar deleted the mergify/bp/humble/pr-1638 branch August 14, 2024 12:52
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.

CI build job humble/testing failed! CI build job humble/main failed!
3 participants