-
Notifications
You must be signed in to change notification settings - Fork 307
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
Add notifier function to allow hwinterface switching #184
Add notifier function to allow hwinterface switching #184
Conversation
Ping? Any comments on this PR? |
18163cb
to
be40e2f
Compare
In this comment I explain a bit more about how the new function can be used together with real hardware as well. |
be40e2f
to
95d91e9
Compare
if(!notifyHardwareInterface(info_list)) | ||
{ | ||
ROS_ERROR("Could not switch controllers, because switching the HWInterface failed"); | ||
return false; |
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.
Should you also have
stop_request_.clear();
start_request_.clear();
similar to the locations above?
42f3d9e
to
e29d88a
Compare
We decided to host the new gazebo_ros_control_plugin proposed in #256 in our own repository ipa320/cob_gazebo_plugins Still, the changes proposed in this PullRequest are a prerequisite for the plugin. |
I suggest @adolfo-rt merge this! |
e29d88a
to
24034f0
Compare
squashing...full of hope... |
24034f0
to
900d38f
Compare
Ping. Still waiting for this pull request to be merged.. |
@adolfo-rt: do you need any further input on this before you can/will merge it? It's currently blocking us from releasing our packages. |
Looks good to me. I'll merge this today if you could first document in a paragraph how this feature works, on the wiki: http://wiki.ros.org/ros_control |
I will document this here, as I don't know where to put it: Within ControllerManager::switchController() several checks are done before actually switching the controllers (e.g. check for resource conflicts,...). An example, where this function is used with Gazebo and the RobotHWSim can be found here. For RobotHWSim mode switching is done by simply assigning the proper control mode to If the HardwareInterface cannot be switched, More explanation can be found here Can we please merge this? |
Long time no bump. We've been spending some cycles on this, and we've reviewed this strategy and that proposed in #180 and pal-robotics-forks/ros_controllers#41. Long story short, we would like joint mode switching to be triggered by I think that the general idea of this proposal is a very good one. The biggest change I would suggest would be to not make
class RobotHW : public InterfaceManager
{
public:
virtual bool checkForConflict(const std::list<ControllerInfo>& info) const;
protected:
virtual bool canSwitch(const std::string& resource_name,
const std::string& hw_iface) const {return true;}
virtual bool doSwitch(const std::string& resource_name,
const std::string& hw_iface) {return true;}
}; Please let me know what you think. I'l likely take these ideas for a test-drive, and see how they fare. |
I came to the same conclusion to add it in RobotHW since this class must be inherited anyway. Some thoughts on the proposed interface:
Another issue that we had to face lately: What 's happening if the mode could not be switched for one device, but for the others? Idea: Stop the old and the new controller. This results in mixed modes, but at least nothing will move. Last but not least there should be a way to notify the hardware that all (claiming) controllers have been stopped and therefore none of the commands should be processed. |
I don't understand why you need to know the controller name for a (potential) mode switch. IMO what's relevant is to know that resource At any rate, if you have a usecase where knowing the controller name is relevant, let's further discuss it.
So we can check whether the transition is possible for all resources before attempting something that could end up in an inconsistent state. For this to be actually true, we should make If we only call
Some actuators might not allow switching between any two control modes, or might not be able to do so in a single control cycle.
No problem to review the constness of the method.
I believe I answered this above. Something that should also be done and was not mentioned in my previous post is take the
|
Thinking more about this, the The example I have in mind is that of mechanical transmissions that couple multiple actuators and joints. It might be impossible to change the mode of only one of the coupled joints without changing the others. Consider a differential, where each joint is commanded by the combined contribution of two actuators. It's very likely that your hardware will only support changing the mode of the two joints at the same time, and not separately. To catch these possible inconsistencies, we need to know the complete controller configuration that will result. So, the class RobotHW : public InterfaceManager
{
public:
virtual bool checkForConflict(const std::list<ControllerInfo>& info) const;
virtual bool canSwitch(const std::list<ControllerInfo>& info) const {return true;}
virtual void doSwitch(const std::list<ControllerInfo>& info) {return true;}
}; On constness, I propose that |
Those are good points! In addition to the coupled joints, there are drives that do not map interfaces to modes one-to-one. Our driver has an internal lookup from supported drive modes to hardware_interfaces that is used at start-up to register all supported interfaces. "(const std::list& info, const std::string& hw_iface)" is redundant, since the hardware_interface ist part of the controller. Why are the new functions protected? (In other words: Which component calls these functions?) |
You are right. It should suffice to pass only the list of
Originally I thought we could call the switching methods from within We might as well cal the switching methods from the Thanks for correcting my sloppy API proposal :) |
This PR will be closed in favor of #200 soon. |
As #200 is merged, closing this one... |
This PR is motivated by the feature proposed in gazebo_ros_pkgs#256
For more details see gazebo_ros_pkgs#256
#184 adds a notification function that is called in
ControllerManager::switchController
. This function can be used to switch the HardwareInterface for the resources of the controller that is meant to be started, i.e. "Switch HardwareInterfaces on Switching Controllers.Default behaviour is simply
return true
- no effect.