-
Notifications
You must be signed in to change notification settings - Fork 41
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
[BUG] State machine blocks with AsyncCb cannot return and busy waiting std::future. #330
Comments
Thanks @ZhenshengLee for this ticket. I am not sure if the reason why your state is stuck is because of CbLaunch. May that stuck be caused by other different client behavior? Anyways, It would be nice to get a new example inside sm_reference_library to replicate and that specific case you have. Now I will answer your generic questions (independently if this is related or not with the CbLaunch functioning) 1 - why this async behavior block? whe this client behavior happen? Asynchronous client behaviors are just client behaviors that are to to run code of the onEntry function in a detached thread. That is why onEntry "finishes" very fast. However, we asume that the Asyncrhonous Client Behavior "Is Running" while that thread is alive. Something very important to know is that the state cant be left until all the client behaviors threads are finished. In order to do that, the state tries to interrupt all of unfinished ones (but that does not always work and depends on the internal implementation of the asyncrhonous function) Then, the key question around is the following: What happens our state machine needs to move from one new state leaving the current state with some unfinished asynchronous behavior? Short answer: If the client behavior gets stuck, the state will also do that. Good client behavior needs to implement their own mechanisms to be interrupted in the case we are leaving the state.
2. when this happens, how to recovery the behavior of state machine? Must I kill the node and restart the node? I think the only solution is using asyncrhonous behaviors that are prepared to be interrupted. 3. How to avoid this client behavior blocking? Using uninterruptible client behaviors. |
I think it may be related with std::future, because similar behavior/issue happens with https://github.com/robosoft-ai/SMACC2/blob/galactic/smacc2/include/smacc2/client_behaviors/cb_call_service.hpp SMACC2/smacc2/include/smacc2/client_behaviors/cb_call_service.hpp Lines 44 to 46 in 42177d3
SMACC2/smacc2/include/smacc2/client_bases/smacc_service_client.hpp Lines 58 to 64 in 42177d3
sometimes the |
I am having the same error even with My Entry looks like this and void onEntry() override {
log_info("OnEntry, Checking pos with 2hz");
rclcpp::Rate rate(2); // 2Hz
// remember to check the shutdown request, so we don't block state transitions
while (!isShutdownRequested()) {
log_info("Is shutdown requested: " + std::to_string(isShutdownRequested()));
log_info("Checking distance...");
this->checkDistanceToTarget();
rate.sleep();
}
log_info("Exited loop...");
} My log, it will keep repeating these entries which indicates that the function
Either I am missing something, or it appears that |
@Crowdedlight your code looks good to me. One question, what branch/commit are you using? |
@ZhenshengLee thanks for notifying that problematic use case (CbServiceCall). As I mentioned, ClientBehavior should implement the "interruption ability". By the moment I created a new PR for galactic (and also for humble) to improve CbServiceCall and allow interruption of the wating process. |
once the PR being merged, this canbe closed. |
PR is merged into galactic. |
CbServiceCall improvements also merged in humble #379 |
Sorry for the late reply @pabloinigoblasco, vacation and sickness kept me away for a while. Is We are using branch |
Describe the bug
The ClRoslaunch is about to launch a python launch which will call some ros2 service call
Some times the service call in launch file would stuck, so the launch thread would block.
the output shows
waiting for finishing client behavior, before leaving the state. Is the client behavior stuck? requesting force finish
SMACC2/smacc2/src/smacc2/smacc_client_async_behavior.cpp
Lines 78 to 82 in 7f889c0
I've seen the code that launching thread in the client behavior is called by std::async, meaning that it
s a async operation and would return right away.
SMACC2/smacc2/src/smacc2/client_bases/smacc_ros_launch_client.cpp
Lines 34 to 73 in 7f889c0
QST,
┆Issue is synchronized with this Jira Task by Unito
The text was updated successfully, but these errors were encountered: