step_plan.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2018, Alexander Stumpf, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Simulation, Systems Optimization and Robotics
13 // group, TU Darmstadt nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 #ifndef VIGIR_FOOTSTEP_PLANNING_STEP_PLAN_H__
30 #define VIGIR_FOOTSTEP_PLANNING_STEP_PLAN_H__
31 
32 #include <ros/ros.h>
33 
34 #include <tf/tf.h>
35 
36 #include <boost/thread/shared_mutex.hpp>
37 
39 
40 
41 
43 {
48 class StepPlan
49 {
50 public:
51  StepPlan(const msgs::StepPlan& step_plan);
52  StepPlan();
53 
54  StepPlan& operator=(const msgs::StepPlan& step_plan);
55  StepPlan& operator+(const msgs::StepPlan& step_plan);
56  StepPlan& operator|(const msgs::StepPlan& step_plan);
57 
58  StepPlan& operator+(const msgs::Step& step);
59  StepPlan& operator|(const msgs::Step& step);
60  StepPlan& operator-(const msgs::Step& step);
61 
62  void clear()
63  {
64  boost::unique_lock<boost::shared_mutex> lock(step_plan_mutex);
65  _clear();
66  }
67  bool empty() const
68  {
69  boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
70  return _empty();
71  }
72  size_t size() const
73  {
74  boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
75  return _size();
76  }
77 
78  int getFirstStepIndex() const;
79  int getLastStepIndex() const;
80 
81  msgs::ErrorStatus insertStep(const msgs::Step& step);
82  msgs::ErrorStatus updateStep(const msgs::Step& step);
83 
84  bool hasStep(unsigned int step_index) const
85  {
86  boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
87  return _hasStep(step_index);
88  }
89 
90  static bool getStep(msgs::Step& step, const msgs::StepPlan& step_plan, unsigned int step_index);
91  inline bool getStep(msgs::Step& step, unsigned int step_index) const
92  {
93  boost::shared_lock<boost::shared_mutex> lock(step_plan_mutex);
94  return _getStep(step, step_index);
95  }
96 
97  bool getStepAt(msgs::Step& step, unsigned int position) const;
98  bool getfirstStep(msgs::Step& step) const;
99  bool getLastStep(msgs::Step& step) const;
100 
101  bool popStep(msgs::Step& step);
102  bool popStep();
103 
104  void removeStep(unsigned int step_index);
105  void removeStepAt(unsigned int position);
106 
107  void removeSteps(unsigned int from_step_index, int to_step_index = -1);
108 
114  msgs::ErrorStatus appendStepPlan(const msgs::StepPlan& step_plan);
115 
122  msgs::ErrorStatus updateStepPlan(const msgs::StepPlan& step_plan); // caution: Very unrestrictive for input step_plan, does not perform consisty checks!
123 
135  msgs::ErrorStatus stitchStepPlan(const msgs::StepPlan& step_plan, int step_index = 0);
136 
144  static tf::Transform getTransform(const geometry_msgs::Pose& current, const geometry_msgs::Pose& target);
145  static void transformStepPlan(msgs::StepPlan& step_plan, const tf::Transform& transform);
146 
147  msgs::ErrorStatus fromMsg(const msgs::StepPlan& step_plan);
148  msgs::ErrorStatus toMsg(msgs::StepPlan& step_plan) const;
149 
150  // typedefs
153 
154 protected:
156  void _clear();
157  bool _empty() const;
158  size_t _size() const;
159 
160  bool _hasStep(unsigned int step_index) const;
161 
162  bool _getStep(msgs::Step& step, unsigned int step_index) const;
163 
170  msgs::ErrorStatus _insertStep(const msgs::Step& step);
171 
178  msgs::ErrorStatus _updateStep(const msgs::Step& step);
179 
185  msgs::ErrorStatus _appendStepPlan(const msgs::StepPlan& step_plan);
186 
193  msgs::ErrorStatus _updateStepPlan(const msgs::StepPlan& step_plan); // caution: Very unrestrictive for input step_plan, does not perform consisty checks!
194 
205  msgs::ErrorStatus _stitchStepPlan(const msgs::StepPlan& step_plan, int step_index = 0);
206 
207  mutable boost::shared_mutex step_plan_mutex;
208 
209  std_msgs::Header header;
210  msgs::Feet start;
211  msgs::Feet goal;
212  std::map<unsigned int, msgs::Step> steps;
213  uint8_t mode;
214  std::vector<uint8_t> data;
215 };
216 }
217 
218 #endif
static bool getStep(msgs::Step &step, const msgs::StepPlan &step_plan, unsigned int step_index)
Definition: step_plan.cpp:85
bool getStep(msgs::Step &step, unsigned int step_index) const
Definition: step_plan.h:91
msgs::ErrorStatus updateStep(const msgs::Step &step)
Definition: step_plan.cpp:79
std::map< unsigned int, msgs::Step > steps
Definition: step_plan.h:212
boost::shared_ptr< StepPlan > Ptr
Definition: step_plan.h:151
bool hasStep(unsigned int step_index) const
Definition: step_plan.h:84
bool getfirstStep(msgs::Step &step) const
Definition: step_plan.cpp:114
void removeSteps(unsigned int from_step_index, int to_step_index=-1)
Definition: step_plan.cpp:172
boost::shared_ptr< const StepPlan > ConstPtr
Definition: step_plan.h:152
bool getLastStep(msgs::Step &step) const
Definition: step_plan.cpp:127
msgs::ErrorStatus insertStep(const msgs::Step &step)
Definition: step_plan.cpp:73
std::vector< uint8_t > data
Definition: step_plan.h:214
StepPlan & operator|(const msgs::StepPlan &step_plan)
Definition: step_plan.cpp:29
StepPlan & operator-(const msgs::Step &step)
Definition: step_plan.cpp:47
msgs::ErrorStatus toMsg(msgs::StepPlan &step_plan) const
Definition: step_plan.cpp:517
msgs::ErrorStatus _updateStepPlan(const msgs::StepPlan &step_plan)
Merges the given step plan to current step plan. Already exisiting steps will be tagged as modified...
Definition: step_plan.cpp:398
msgs::ErrorStatus _stitchStepPlan(const msgs::StepPlan &step_plan, int step_index=0)
Stitches the given step plan into the current step plan starting at step_index. Hereby the all in ran...
Definition: step_plan.cpp:421
StepPlan & operator=(const msgs::StepPlan &step_plan)
Definition: step_plan.cpp:17
msgs::ErrorStatus appendStepPlan(const msgs::StepPlan &step_plan)
Appends a step plan to current step plan. No transformation will be done!
Definition: step_plan.cpp:188
msgs::ErrorStatus fromMsg(const msgs::StepPlan &step_plan)
Definition: step_plan.cpp:484
bool _hasStep(unsigned int step_index) const
Definition: step_plan.cpp:322
unsigned int step
void removeStep(unsigned int step_index)
Definition: step_plan.cpp:160
msgs::ErrorStatus _updateStep(const msgs::Step &step)
Inserts step into step plan. If the step does already exists it will be overwritten and tagged as mod...
Definition: step_plan.cpp:352
bool getStepAt(msgs::Step &step, unsigned int position) const
Definition: step_plan.cpp:99
static tf::Transform getTransform(const geometry_msgs::Pose &current, const geometry_msgs::Pose &target)
Determines transformation T from current to target coordinate system represented by the given poses i...
Definition: step_plan.cpp:256
StepPlan & operator+(const msgs::StepPlan &step_plan)
Definition: step_plan.cpp:23
static void transformStepPlan(msgs::StepPlan &step_plan, const tf::Transform &transform)
Definition: step_plan.cpp:269
boost::shared_mutex step_plan_mutex
Definition: step_plan.h:207
void removeStepAt(unsigned int position)
Definition: step_plan.cpp:166
msgs::ErrorStatus updateStepPlan(const msgs::StepPlan &step_plan)
Merges the given step plan to current step plan. Already exisiting steps will be tagged as modified...
Definition: step_plan.cpp:210
bool _getStep(msgs::Step &step, unsigned int step_index) const
Definition: step_plan.cpp:327
msgs::ErrorStatus _appendStepPlan(const msgs::StepPlan &step_plan)
Appends a step plan to current step plan. No transformation will be done!
Definition: step_plan.cpp:370
msgs::ErrorStatus stitchStepPlan(const msgs::StepPlan &step_plan, int step_index=0)
Stitches the given step plan into the current step plan starting at step_index. Hereby the all in ran...
Definition: step_plan.cpp:230
msgs::ErrorStatus _insertStep(const msgs::Step &step)
Inserts step into step plan. If the step does already exists it will be overwritten and not tagged as...
Definition: step_plan.cpp:338


vigir_footstep_planning_msgs
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:45:25