MATLAB has encountered an internal problem after deleting the action client

6 ビュー (過去 30 日間)
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 件のコメント
Prabeen Sahu
Prabeen Sahu 2021 年 11 月 9 日
Hi Xin,
When you are going to delete the simple action client and the goal is not yet completed, you probably don’t want the goal to be running in simple action server. So before deleting the client, please try cancelling the goal through the client.
gripper_actClient.cancelGoal();
pause(0.2);
delete(gripper_actClient);
This probably will resolve your issue. If not, please reach out to us through the MathWorks® Technical Support. We may need more information to help you out.
-Prabeen
Xin Xing
Xin Xing 2021 年 11 月 10 日
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

サインインしてコメントする。

採用された回答

Karthik Reddy Vennapureddy
Karthik Reddy Vennapureddy 2022 年 5 月 12 日
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
  3 件のコメント
Yongqing Li
Yongqing Li 2022 年 12 月 1 日
function [return_agent_pos_matrix,return_agent_index] = sendAllGoals(params,agent_pos,goal,ares_actClients,...
goalMsgs,ares_odomSubs, move_base_status_subs)
POSE_X = 1; %坐标 X
POSE_Y = 2; %坐标 Y
agent_num = params.agent_num;
agent_index = 1 : agent_num;
disp('sendgoal')
for i = 1:agent_num
goalMsgs(i).TargetPose.Pose.Position.X = goal(i,POSE_X);
goalMsgs(i).TargetPose.Pose.Position.Y = goal(i,POSE_Y);
goalMsgs(i).TargetPose.Pose.Orientation.Z = 0.99;
goalMsgs(i).TargetPose.Header.FrameId = 'map';
goalMsgs(i).TargetPose.Header.Stamp = rostime("now");
sendGoal(ares_actClients(i),goalMsgs(i));
end
...
% 仿真时间超过120s或者所有机器人到达设定的目标点
cancelAllGoals(ares_actClients(1));
...
return_agent_pos_matrix = agent_pos;
return_agent_index = agent_index;
end
Yongqing Li
Yongqing Li 2022 年 12 月 1 日
上面的代码在运行时,控制台一直报错,程序无法停止

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePublishers and Subscribers についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by