-
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
[controller_manager] Fix execution point of doSwitch #211
Comments
You are right it might lead to undefined behaviour if this case is not handled properly in RobotHW, which is rather cumbersome. For CANopen it takes 2 to 10 (rough estimation) cycles to switch the mode depending on the device, which might require to switch the motor power off and on again. Maybe it's time to add proper resource states that are used for switching and detection of emergency stops, something like
In addition we would need a mechanism to propagate the state between |
Currently We've also encountered devices that take longer than one control cycle to switch.The following is a list of possible solutions that can be made to work with the single-control-cycle restriction of
You say you're using CANopen. IIRC, the CANopen state machine should be able to transition between any to modes in two control cycles, right? (mode A→idle, idle→mode B). This is what we're getting from CAN devices. |
@ipa-mdl, please let me know what strategy you propose to go about this. I don't want to break |
Thanks for waiting :) The CANopen state machines can switch directly between two modes (there is no real idle mode), but
Your option 3 is obviously not applicable here. The current What do you think about adding a non-RT I am/have been out of the office as well. I will give the hybrid interface a try in two weeks. |
Controller switching guarantees completion in a single control cycle. I'd like this behavior to remain, as it's one of the strong points of the controller manager. The
Yes, please. I don't know what you mean by ugly, but option 1 in #211 (comment) is a pretty decent compromise, and has worked well for us in joints that take a few cycles to switch. If switching is really slow, I'd advise to go for option 2 in #211 (comment), but I think this can likely be prevented using option 1. I don't want to put pressure here, but I consider this bug a blocker for the Jade release. |
Option 1 does not work if the controller starts before the hardware is ready to process the commands. Hijacking is ugly because I have to run the A compromise would be to rename If you insist on #209 (or the jade equivalent) then this is a blocker for all further |
Long answer...
I don't know if it works for you, but this is the sequence of events I'm expecting when switching from When switching is requested:
During a few control cycles:
Once hardware switches to
During switching, the first commands from More importantly, how is this worse than what you currently have?. I expect that you have the opposite. You switch modes before controllers, hence start reading from a still stopped
I'm not sure I understood the above phrase. But if we accept that controller switching cannot take longer than one control cycle, I see no big issues with offloading most of the work to
To go over this limitation in indigo, I had to make
I've been holding #209 and #210 because of your heads-up. A fix has to be pushed to indigo and jade, but it can be delayed. I'm all ears for feedback from affected downstream projects like
Our worst switching latency is two 10ms control cycles, and we observe the behavior described in the example above. It's more than acceptable. The code is not open. |
Thank you for your detailed response!
For a single joint this might be acceptable, but it is not acceptable for synchronized multi-joint motions.
Yes and no: Commands from
I guess this is the crucial point. In CANopen committing the change takes some time.
Two cycles is our best case. Typical latency will be 3-4 cycles for our hardware. Other hardware needs some additional state machine transitions in between and therefore 5 or more cycles just for the (synchronized) communication. If the motor needs to be stopped first (with moderate deceleration) the time increases of cause.
Then it's fine for jade, a rename would be nice though. IMHO breaking the behaviour (non-RT -> RT) is worse than breaking the API (const -> non-const). |
This issue can be closed now, I guess. |
When switching controllers, the robot hardware abstraction might require changing the control mode of certain resources (e.g. joints). This feature was contributed in #200. I recently realized that the current implementation has an important flaw with a straightforward fix.
When a controller switch request is made, a non real-time ROS callback checks that the switch is possible, and among other things calls
RobotHW::canSwitch(...)
. This callback doesn't perform the actual switching, but delegates it to the [real-time] control thread. Because of this, the call toRobotHW::doSwitch(...)
should also be done in the control thread. We currently do it in the ROS callback, which is wrong.This misplaced call to
RobotHW::doSwitch(...)
can cause a robot to switch the control mode of its joints before the new controllers are actually running. The ensuing behavior is undefined, and depends on how your hardware abstraction is implemented. I could reproduce this on hardware, and confirm that the fix proposed below address the issue.The fix consists of moving the execution point of
RobotHW::doSwitch(...)
, which entails that the method implementation must now be real-time safe. A fix for indigo is proposed in #209.Because the real-time safe requirements now imposed on
RobotHW::doSwitch(...)
, it now becomes much likelier thatRobotHW::canSwitch(...)
will have side-effects, i.e., change the state of theRobotHW
instance. For this reason, I additionally propose that in jade we remove the constness of theRobotHW::canSwitch(...)
method. Since jade has not been officially released, we can allow to make this small API change. A fix for jade is porposed in #210.@ipa-mdl
The text was updated successfully, but these errors were encountered: