本文整理汇总了C++中actionlib::SimpleActionServer::setPreempted方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleActionServer::setPreempted方法的具体用法?C++ SimpleActionServer::setPreempted怎么用?C++ SimpleActionServer::setPreempted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actionlib::SimpleActionServer
的用法示例。
在下文中一共展示了SimpleActionServer::setPreempted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preemptCB
// Cancel the action
void preemptCB()
{
ROS_INFO_STREAM_NAMED("pick_place_moveit","Preempted");
action_server_.setPreempted();
}
示例2: executeCB
void executeCB(const race_move_arms::CarryarmGoalConstPtr &goal)
{
// make sure that the action hasn't been canceled
if (!as_.isActive())
return;
bool success = true;
bool rightArm = true; // right arm
ROS_INFO("Executing, creating carryarm action");
// start executing the action
if (goal->carrypose == 1) // both arms are not in carrypose!
{
// check that preempt has not been requested by the client
if (as_.isPreemptRequested() || !ros::ok())
{
ROS_INFO("%s: Preempted", action_name_.c_str());
// set the action state to preempted
as_.setPreempted();
success = false;
}
else
{
ROS_INFO("Executing arm trajectory..");
switch (goal->carryarm)
{
case 0:
ROS_INFO("Using right arm");
success = moveRightArm();
break;
case 1:
ROS_INFO("Using left arm");
success = moveLeftArm();
break;
case 2:
ROS_INFO("Using both arms");
rightArm = true;
success = moveArmToAbove(rightArm);
success &= moveBothArms();
break;
default:
ROS_INFO("Unknown carryarm command, ignoring");
break;
}
}
}
else if (goal->carrypose == 2) // the other arm is already in carrypose!
{
// check that preempt has not been requested by the client
if (as_.isPreemptRequested() || !ros::ok())
{
ROS_INFO("%s: Preempted", action_name_.c_str());
// set the action state to preempted
as_.setPreempted();
success = false;
}
else
{
ROS_INFO("Executing arm trajectory..");
switch (goal->carryarm)
{
case 0:
ROS_INFO("Using right arm");
success = moveBothArms(); // trivial case
break;
case 1:
ROS_INFO("Using left arm");
//move right arm to side first
rightArm = true;
success = moveArmToAbove(rightArm);
success &= moveBothArms(); // trivial case
break;
default:
ROS_INFO("Unknown carryarm command, ignoring");
break;
}
}
}
else if (goal->carrypose == 3) // move arm to above
{
// check that preempt has not been requested by the client
if (as_.isPreemptRequested() || !ros::ok())
{
ROS_INFO("%s: Preempted", action_name_.c_str());
// set the action state to preempted
as_.setPreempted();
success = false;
}
else
{
ROS_INFO("Executing arm trajectory..");
switch (goal->carryarm)
{
case 0:
ROS_INFO("Using right arm");
rightArm = true;
//.........这里部分代码省略.........