MATLAB has encountered an internal problem after deleting the action client

5 views (last 30 days)
Hallo,
Before, I used MATLAB to define actionclient to control the actionserver in ROS. After using it, I didn’t want to disconnect from ROS so that I could continue to send goals to actionserver. Therefore, I only deleted the current actionclient, as in the following example.
[gripper_actClient, gripper_msg] = rosactionclient('/gripper_action');
waitForServer(gripper_actClient);
gripper_msg.Type = 0;
[resultMsg, resultState] = sendGoalAndWait(gripper_actClient, gripper_msg);
delete(gripper_actClient);
However, after that, when I wanted to perform any operation in MATLAB, an error message appeared.
Connection to process with Exchange: "45b2b5d4-bb67-48e5-bf98-267b41dba48d " was lost.
I had to close matlab and restart it. When I run the above code again, it was still the same result. Has anyone encountered the same problem?
I used MATLAB R2021b in windows. I have also tried in Ubuntu 16.04 and there was same problem, but in macOS Big Sur (Version 11) not.
  4 Comments
Xin Xing
Xin Xing on 10 Nov 2021
Hi Prabeen,
Unfortunately, I still have the same problem after trying a few times. :( But thank you so much for your help, I will ask MathWorks® Technical Support for help.
- Xin

Sign in to comment.

Accepted Answer

Karthik Reddy Vennapureddy
Hi Xin,
In the action server callback implementation, the Preempt logic is outside the while loop and is never reached when the goal is being cancelled. When the goal is running by the server and we send a cancelGoal request from action client to action server, due to incorrect implementation of action server callback the goal keeps running and tries to send the feedback even if the actionclient is deleted and hence the issue.
The goal will be active until we make the status of goal as preempted or aborted in the action server. In this case, this is being done outside of while loop, which makes it infinite loop. So, to avoid this error please follow one of the below solutions.
Solution 1: Move the Preempt logic into while condition as below.
while(as.isActive())
{
...
...
//----------------------- Preempt -----------------
if(as.isPreemptRequested() || !ros::ok())
{
ROS_WARN("%s: Preempted", action_name.c_str());
as.setPreempted();
success = false;
}
else
{
success = true;
ROS_INFO("\nType: %i [0 - Basic mode 1 - Pinch mode 2 - Wide mode 3 - Scissor mode] \nWidth: %i \nSpeed: %i of 255\nForce: %i of 255", goal->type, weite, gswk, kraft);
}
oldStatus++;
r.sleep();
}
The same is recommended by ROS Community : Link.
Solution 2: Change the while condition as below:
while(as.isActive() && !as.isPreemptRequested() && ros::ok())
{
....
}
Thanks,
Karthik Reddy

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!