step_plan.h
Go to the documentation of this file.
00001 //=================================================================================================
00002 // Copyright (c) 2018, Alexander Stumpf, TU Darmstadt
00003 // All rights reserved.
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //     * Redistributions of source code must retain the above copyright
00008 //       notice, this list of conditions and the following disclaimer.
00009 //     * Redistributions in binary form must reproduce the above copyright
00010 //       notice, this list of conditions and the following disclaimer in the
00011 //       documentation and/or other materials provided with the distribution.
00012 //     * Neither the name of the Simulation, Systems Optimization and Robotics
00013 //       group, TU Darmstadt nor the names of its contributors may be used to
00014 //       endorse or promote products derived from this software without
00015 //       specific prior written permission.
00016 
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //=================================================================================================
00028 
00029 #ifndef VIGIR_FOOTSTEP_PLANNING_STEP_PLAN_H__
00030 #define VIGIR_FOOTSTEP_PLANNING_STEP_PLAN_H__
00031 
00032 #include <ros/ros.h>
00033 
00034 #include <tf/tf.h>
00035 
00036 #include <boost/thread/shared_mutex.hpp>
00037 
00038 #include <vigir_footstep_planning_msgs/footstep_planning_msgs.h>
00039 
00040 
00041 
00042 namespace vigir_footstep_planning
00043 {
00048 class StepPlan
00049 {
00050 public:
00051   StepPlan(const msgs::StepPlan& step_plan);
00052   StepPlan();
00053 
00054   StepPlan& operator=(const msgs::StepPlan& step_plan);
00055   StepPlan& operator+(const msgs::StepPlan& step_plan);
00056   StepPlan& operator|(const msgs::StepPlan& step_plan);
00057 
00058   StepPlan& operator+(const msgs::Step& step);
00059   StepPlan& operator|(const msgs::Step& step);
00060   StepPlan& operator-(const msgs::Step& step);
00061 
00062   void clear()
00063   {
00064     boost::unique_lock<boost::shared_mutex> lock(step_plan_mutex);
00065     _clear();
00066   }
00067   bool empty() const
00068   {
00069     boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
00070     return _empty();
00071   }
00072   size_t size() const
00073   {
00074     boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
00075     return _size();
00076   }
00077 
00078   int getFirstStepIndex() const;
00079   int getLastStepIndex() const;
00080 
00081   msgs::ErrorStatus insertStep(const msgs::Step& step);
00082   msgs::ErrorStatus updateStep(const msgs::Step& step);
00083 
00084   bool hasStep(unsigned int step_index) const
00085   {
00086     boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
00087     return _hasStep(step_index);
00088   }
00089 
00090   static bool getStep(msgs::Step& step, const msgs::StepPlan& step_plan, unsigned int step_index);
00091   inline bool getStep(msgs::Step& step, unsigned int step_index) const
00092   {
00093     boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
00094     return _getStep(step, step_index);
00095   }
00096 
00097   bool getStepAt(msgs::Step& step, unsigned int position) const;
00098   bool getfirstStep(msgs::Step& step) const;
00099   bool getLastStep(msgs::Step& step) const;
00100 
00101   bool popStep(msgs::Step& step);
00102   bool popStep();
00103 
00104   void removeStep(unsigned int step_index);
00105   void removeStepAt(unsigned int position);
00106 
00107   void removeSteps(unsigned int from_step_index, int to_step_index = -1);
00108 
00114   msgs::ErrorStatus appendStepPlan(const msgs::StepPlan& step_plan);
00115 
00122   msgs::ErrorStatus updateStepPlan(const msgs::StepPlan& step_plan); // caution: Very unrestrictive for input step_plan, does not perform consisty checks!
00123 
00135   msgs::ErrorStatus stitchStepPlan(const msgs::StepPlan& step_plan, int step_index = 0);
00136 
00144   static tf::Transform getTransform(const geometry_msgs::Pose& current, const geometry_msgs::Pose& target);
00145   static void transformStepPlan(msgs::StepPlan& step_plan, const tf::Transform& transform);
00146 
00147   msgs::ErrorStatus fromMsg(const msgs::StepPlan& step_plan);
00148   msgs::ErrorStatus toMsg(msgs::StepPlan& step_plan) const;
00149 
00150   // typedefs
00151   typedef boost::shared_ptr<StepPlan> Ptr;
00152   typedef boost::shared_ptr<const StepPlan> ConstPtr;
00153 
00154 protected:
00156   void _clear();
00157   bool _empty() const;
00158   size_t _size() const;
00159 
00160   bool _hasStep(unsigned int step_index) const;
00161 
00162   bool _getStep(msgs::Step& step, unsigned int step_index) const;
00163 
00170   msgs::ErrorStatus _insertStep(const msgs::Step& step);
00171 
00178   msgs::ErrorStatus _updateStep(const msgs::Step& step);
00179 
00185   msgs::ErrorStatus _appendStepPlan(const msgs::StepPlan& step_plan);
00186 
00193   msgs::ErrorStatus _updateStepPlan(const msgs::StepPlan& step_plan); // caution: Very unrestrictive for input step_plan, does not perform consisty checks!
00194 
00205   msgs::ErrorStatus _stitchStepPlan(const msgs::StepPlan& step_plan, int step_index = 0);
00206 
00207   mutable boost::shared_mutex step_plan_mutex;
00208 
00209   std_msgs::Header header;
00210   msgs::Feet start;
00211   msgs::Feet goal;
00212   std::map<unsigned int, msgs::Step> steps;
00213   uint8_t mode;
00214   std::vector<uint8_t> data;
00215 };
00216 }
00217 
00218 #endif


vigir_footstep_planning_msgs
Author(s): Alexander Stumpf
autogenerated on Thu Jun 6 2019 20:43:43