-
Notifications
You must be signed in to change notification settings - Fork 305
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
HW interface switch feature with unit tests #200
HW interface switch feature with unit tests #200
Conversation
+1 thanks for putting the effort into the unit tests. i'd really like to see this feature merged, its been nearly 2 years since i made the first implementation |
@@ -440,6 +472,16 @@ bool ControllerManager::switchController(const std::vector<std::string>& start_c | |||
return false; | |||
} | |||
|
|||
if (!robot_hw_->canSwitch(start_list, stop_list)) | |||
{ | |||
ROS_ERROR("Could not switch controllers, due to mode conflicts"); |
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.
I see that you try to maintain parallelism with the resource conflict message, but I find the error message not so clear. Now there's no explicit notion of modes, or what a mode conflict is. Here's some alternatives.
More explicit in blaming the robot for the failure:
"Could not switch controllers, requested controller state cannot be realized by robot"
Less explicit, more compact:
"Could not switch controllers, requested controller state is unfeasible"
Most verbose:
"Could not switch controllers. The resource combination for the requested controller state is unfeasible"
Please add your affiliation to the copyright statement of the affected files. |
@@ -0,0 +1,380 @@ | |||
#include <gtest/gtest.h> |
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.
Add license statement with copyright
All my comments are minor. A great +1 to this PR. |
Thanks for the review! I will use "hardware interface switching" (as in the PR title) throughout the code and docs, because this is the view of the controller_manager. |
I have just updated the code based on your remarks. |
This is looking good. Go ahead and squash the commits, and let's merge this one! |
c248255
to
e5b9581
Compare
Squashed :) |
HW interface switch feature with unit tests
Merged, at last! |
Haha, awesome! |
A Pull Request to ros_controls enforced STRICT controller switching to mean that already stopped controllers cannot be stopped again: ros-controls/ros_control#200 Passing in a value of STRICT to the controller manager didn't matter before because it was never properly implemented. According to the service Request definition: * STRICT means that switching will fail if anything goes wrong (an invalid controller name, a controller that failed to start, etc. ) * BEST_EFFORT means that even when something goes wrong with on controller, the service will still try to start/stop the remaining controllers We were relying on STRICT functionality not being fully implemented. Instead, we will use BEST_EFFORT for a more forgiving controller switching strategy. This design decision should be revisited in the development cycle.
As reported in Issue #49 **ros_control upgrade breaks baxter_gazebo simulation** A pull request to ros_controls enforced STRICT controller switching to mean that already stopped controllers cannot be stopped again: ros-controls/ros_control#200 This resulted in baxter_simulator being unable to start any controllers since it preemptively closes controllers whether or not they have been started. This was caused by the chosen strategy for switching controllers. Passing in a value of STRICT to the controller manager didn't matter before because it was never properly implemented. According to the service Request definition: * STRICT means that switching will fail if anything goes wrong (an invalid controller name, a controller that failed to start, etc. ) * BEST_EFFORT means that even when something goes wrong with on controller, the service will still try to start/stop the remaining controllers We were relying on STRICT functionality not being fully implemented. Instead, we will use BEST_EFFORT for a more forgiving controller switching strategy. This design decision should be revisited in the development cycle.
As reported in Issue #49 **ros_control upgrade breaks baxter_gazebo simulation** A pull request to ros_controls enforced STRICT controller switching to mean that already stopped controllers cannot be stopped again: ros-controls/ros_control#200 This resulted in baxter_simulator being unable to start any controllers since it preemptively closes controllers whether or not they have been started. This was caused by the chosen strategy for switching controllers. Passing in a value of STRICT to the controller manager didn't matter before because it was never properly implemented. According to the service Request definition: * STRICT means that switching will fail if anything goes wrong (an invalid controller name, a controller that failed to start, etc. ) * BEST_EFFORT means that even when something goes wrong with on controller, the service will still try to start/stop the remaining controllers We were relying on STRICT functionality not being fully implemented. Instead, we will use BEST_EFFORT for a more forgiving controller switching strategy. This design decision should be revisited in the development cycle. (cherry picked from commit 535cbb1)
As promised in #197 I have implemented a new version of the HW interface switch.
The RobotHW class got new members as discussed beforehand:
These should check and execute the switches on the hardware.
The
switchController
filters the start and stop list as follows:I have put a lot of effort into the unit tests, they should cover most cases, including the filters, resource and inter-controller mode conflicts.
The SwitchBot only allows direct (in one function call) switches if new_hwi >= old_hwi (string comparison).
@ipa-fxm will implement a gazebo plugin again, I will test it with https://github.com/ipa320/ros_canopen.