abstract_execution_base.cpp
Go to the documentation of this file.
00001 /*
00002  *  Copyright 2018, Sebastian Pütz
00003  *
00004  *  Redistribution and use in source and binary forms, with or without
00005  *  modification, are permitted provided that the following conditions
00006  *  are met:
00007  *
00008  *  1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  *
00011  *  2. Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *
00016  *  3. Neither the name of the copyright holder nor the names of its
00017  *     contributors may be used to endorse or promote products derived
00018  *     from this software without specific prior written permission.
00019  *
00020  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031  *  POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  *  abstract_execution_base.cpp
00034  *
00035  *  author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
00036  *
00037  */
00038 
00039 #include "mbf_abstract_nav/abstract_execution_base.h"
00040 
00041 namespace mbf_abstract_nav{
00042 
00043   AbstractExecutionBase::AbstractExecutionBase(std::string name,
00044                                                boost::function<void()> setup_fn,
00045                                                boost::function<void()> cleanup_fn)
00046     : outcome_(255), cancel_(false), name_(name), setup_fn_(setup_fn), cleanup_fn_(cleanup_fn)
00047   {
00048   }
00049 
00050   bool AbstractExecutionBase::start()
00051   {
00052     //setState(STARTED); // TODO
00053     thread_ = boost::thread(&AbstractExecutionBase::run, this);
00054     return true;
00055   }
00056 
00057   void AbstractExecutionBase::stop()
00058   {
00059     ROS_WARN_STREAM("Trying to stop the planning rigorously by interrupting the thread!");
00060     thread_.interrupt();
00061     //setState(STOPPED); // TODO
00062   }
00063 
00064   void AbstractExecutionBase::join(){
00065     thread_.join();
00066   }
00067 
00068   void AbstractExecutionBase::waitForStateUpdate(boost::chrono::microseconds const &duration)
00069   {
00070     boost::mutex mutex;
00071     boost::unique_lock<boost::mutex> lock(mutex);
00072     condition_.wait_for(lock, duration);
00073   }
00074 
00075   uint32_t AbstractExecutionBase::getOutcome()
00076   {
00077     return outcome_;
00078   }
00079 
00080   std::string AbstractExecutionBase::getMessage()
00081   {
00082     return message_;
00083   }
00084 
00085   std::string AbstractExecutionBase::getName()
00086   {
00087     return name_;
00088   }
00089 
00090 
00091 } /* namespace mbf_abstract_nav */


mbf_abstract_nav
Author(s): Sebastian Pütz
autogenerated on Mon Jun 17 2019 20:11:35