manipulation_pipeline.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2012, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
37 #ifndef MOVEIT_PICK_PLACE_MANIPULATION_PIPELINE_
38 #define MOVEIT_PICK_PLACE_MANIPULATION_PIPELINE_
39 
41 #include <boost/thread.hpp>
42 #include <boost/shared_ptr.hpp>
43 #include <boost/function.hpp>
44 #include <vector>
45 #include <deque>
46 
47 namespace pick_place
48 {
51 {
52 public:
53  ManipulationPipeline(const std::string& name, unsigned int nthreads);
54  virtual ~ManipulationPipeline();
55 
56  const std::string& getName() const
57  {
58  return name_;
59  }
60 
61  void setSolutionCallback(const boost::function<void()>& callback)
62  {
63  solution_callback_ = callback;
64  }
65 
66  void setEmptyQueueCallback(const boost::function<void()>& callback)
67  {
68  empty_queue_callback_ = callback;
69  }
70 
71  ManipulationPipeline& addStage(const ManipulationStagePtr& next);
72  const ManipulationStagePtr& getFirstStage() const;
73  const ManipulationStagePtr& getLastStage() const;
74  void reset();
75 
76  void setVerbose(bool flag);
77 
78  void signalStop();
79  void start();
80  void stop();
81 
82  void push(const ManipulationPlanPtr& grasp);
83  void clear();
84 
85  const std::vector<ManipulationPlanPtr>& getSuccessfulManipulationPlans() const
86  {
87  return success_;
88  }
89 
90  const std::vector<ManipulationPlanPtr>& getFailedManipulationPlans() const
91  {
92  return failed_;
93  }
94 
95  void reprocessLastFailure();
96 
97 protected:
98  void processingThread(unsigned int index);
99 
100  std::string name_;
101  unsigned int nthreads_;
102  bool verbose_;
103  std::vector<ManipulationStagePtr> stages_;
104 
105  std::deque<ManipulationPlanPtr> queue_;
106  std::vector<ManipulationPlanPtr> success_;
107  std::vector<ManipulationPlanPtr> failed_;
108 
109  std::vector<boost::thread*> processing_threads_;
111  boost::mutex queue_access_lock_;
112  boost::mutex result_lock_;
113 
114  boost::function<void()> solution_callback_;
115  boost::function<void()> empty_queue_callback_;
116  unsigned int empty_queue_threads_;
117 
119 };
120 }
121 
122 #endif
boost::function< void()> empty_queue_callback_
std::vector< ManipulationStagePtr > stages_
void processingThread(unsigned int index)
Represent the sequence of steps that are executed for a manipulation plan.
std::vector< ManipulationPlanPtr > failed_
const ManipulationStagePtr & getLastStage() const
void setEmptyQueueCallback(const boost::function< void()> &callback)
unsigned int index
const ManipulationStagePtr & getFirstStage() const
const std::vector< ManipulationPlanPtr > & getFailedManipulationPlans() const
std::vector< boost::thread * > processing_threads_
std::deque< ManipulationPlanPtr > queue_
ManipulationPipeline(const std::string &name, unsigned int nthreads)
void push(const ManipulationPlanPtr &grasp)
std::vector< ManipulationPlanPtr > success_
const std::vector< ManipulationPlanPtr > & getSuccessfulManipulationPlans() const
boost::function< void()> solution_callback_
const std::string & getName() const
ManipulationPipeline & addStage(const ManipulationStagePtr &next)
void setSolutionCallback(const boost::function< void()> &callback)
boost::condition_variable queue_access_cond_


manipulation
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Wed Jul 10 2019 04:03:57