Skip to content

Commit c82a264

Browse files
mbuijsDLu
authored andcommitted
Add preempt goal functionality to locomove_base (#40)
* Add preempt goal functionality to locomove_base * Fix whitespace issue
1 parent 33c974b commit c82a264

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

locomove_base/include/locomove_base/locomove_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class LocoMoveBase
103103

104104
// MoveBaseAction
105105
void executeCB();
106+
void preemptCB();
106107
actionlib::SimpleActionServer<move_base_msgs::MoveBaseAction> server_;
107108

108109
// Recoveries

locomove_base/src/locomove_base.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ LocoMoveBase::LocoMoveBase(const ros::NodeHandle& nh) :
203203
goal_sub_ = simple_nh.subscribe<geometry_msgs::PoseStamped>("goal", 1, boost::bind(&LocoMoveBase::goalCB, this, _1));
204204

205205
server_.registerGoalCallback(std::bind(&LocoMoveBase::executeCB, this));
206+
server_.registerPreemptCallback(std::bind(&LocoMoveBase::preemptCB, this));
206207
server_.start();
207208

208209
resetState();
@@ -628,6 +629,15 @@ void LocoMoveBase::executeCB()
628629
setGoal(nav_2d_utils::poseStampedToPose2D(move_base_goal->target_pose));
629630
}
630631

632+
void LocoMoveBase::preemptCB()
633+
{
634+
ROS_INFO("Preempting goal");
635+
plan_loop_timer_.stop();
636+
control_loop_timer_.stop();
637+
resetState();
638+
server_.setPreempted();
639+
}
640+
631641
} // namespace locomove_base
632642

633643
int main(int argc, char** argv)

0 commit comments

Comments
 (0)