记录
错误:To transition to a succeeded state, the goal must be in a preempting or active state, it is currently in state: 2
原因:不能在抢占回调后server端仍然发送setSucceeded(),因为抢占后便放弃了之前的执行,错在此处
server.setSucceeded();
解决:加入一个bool变量标识符在执行函数中,解决抢断的逻辑问题
执行函数修改如下
void ExecuteCb(const franka_msgs::PickGoalConstPtr& goal)
{
action_ = true;//为保证标识符有效且不影响正常运行,应进入执行函数时便设置为true
...//(此处为代码块省略)
if(action_){
server.setSucceeded();
}
}
抢断函数修改如下:
void preemptCb()
{
//会自动执行第一个目标再执行第二个。;
ROS_INFO_STREAM("into preemptCB ...");
action_ = false;//此处告知:我抢断了,就别发succeed了
group_->stop();
server.setPreempted();
}
实际跑测有效
来源:CSDN
作者:红鲤鱼与彩虹
链接:https://blog.csdn.net/qq_38787214/article/details/103804180