libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
MultiHandOverAlgos.h
1 #ifndef MULTIHANDOVERALGOS_H
2 #define MULTIHANDOVERALGOS_H
3 #include <sstream>
4 #include "MultiAgentHandOvers.h"
5 #include "MultiHandOverUtils.hpp"
6 
7 namespace HRICS {
12 namespace MHO{
13 
15 public:
17  setLogger(&_dummy_logger);
18  }
19  virtual ~AbstractSolutionTools(){}
20 
21  virtual double computeCost(MultiHandOverSolution* solution) = 0;
22  virtual double computeNavigationTrajectories(MultiHandOverSolution* solution, int action_index) =0;
23  //virtual bool handOverFindConfs(MultiHandOverSolution * solution, int frontier_index) =0;
24  //virtual bool handOverFindConfs(MultiAgentCell *c1,unsigned int a1,MultiAgentCell* c2,unsigned int a2) =0;
25  //virtual bool handOverFindConfs(FrontierPtr frontier) =0;
26  virtual double distanceCost(double d,unsigned int a) =0;
27  virtual double distanceCostNoTime(double d,unsigned int a) =0;
29  virtual double distanceTime(double d, unsigned int a)=0;
31  virtual double timeCost(double t,unsigned int a)=0;
33  virtual double objectTimeCost(double t)=0;
34  virtual double handOverCostEstimation(unsigned int i,unsigned int j)=0;
35  virtual double handOverCost(FrontierPtr frontier,double *time=0) =0;
36  virtual double handOverCost(MultiAgentCell *c1,unsigned int a1,MultiAgentCell *c2,unsigned int a2,double *time=0) =0;
37  virtual double handOverMaxDist(unsigned int a1,unsigned int a2) =0;
39  virtual double handOverSideCosts(MultiAgentCell *c1,unsigned int a1,MultiAgentCell* c2,unsigned int a2, double *coming_time=0) =0;
40  void setLogger(AlgoLoggerInterface* logger){_logger=logger;}
41 private:
42  AlgoLoggerInterface *_logger;
43  AlgoLoggerInterface _dummy_logger;
44 };
45 
46 
48 public:
50  setLogger(&_dummy_logger);
51  }
52  virtual ~AbstractFrontierOptimizer(){}
53 
54  virtual MultiHandOverSolution* optimize(MultiHandOverSolution * solution, unsigned int action_index,double keep_dist,double min_dist) =0;
55 
56  void setLogger(AlgoLoggerInterface* logger){_logger=logger;}
57 protected:
58  AlgoLoggerInterface *_logger;
59 private:
60  AlgoLoggerInterface _dummy_logger;
61 };
62 
63 
67 class ToolSet{
68 public:
69  ToolSet(FrontierTester *frontier_tester, AbstractSolutionTools *sol_tools, MultiHandOver *mho, FrontierCells::FrontierCheckStatus max_check_status);
70  AbstracHandOverObjectCheck *handoverObjectChecker;
71  AbstractSolutionTools *solutionTools;
72  FrontierTester *frontierTester;
73 
75  void setRobots(unsigned int a1,unsigned int a2);
77  void updateObject();
78  bool checkHandOverFull(MultiAgentCell *c1,unsigned int a1,MultiAgentCell* c2,unsigned int a2,double &cost,double *time=0);
79  bool checkFrontierFull(FrontierPtr frontier,MultiAgentCell *c1,unsigned int a1,MultiAgentCell *c2, unsigned int a2);
80  double getReach(unsigned int a);
81  double getReach(unsigned int a1,unsigned int a2);
82 
83  static double distanceCostStatic(void *the_this,double d,unsigned int agent){return ((ToolSet*)the_this)->solutionTools->distanceCost(d,agent);}
84 
85  double getStatsCheckHoFull(double &mean, double &variance, unsigned int &n);
86 
87 private:
88  MultiHandOver *_mho;
89  FrontierCells::FrontierCheckStatus _max_check_status;
90 
91  //STAT
92  unsigned int _full_ho_cnt;
93  double _full_ho_time_mean;
94  double _full_ho_time_M2; //for online variance computation
95 
96 };
97 
99  MOVE3D_STATIC_LOGGER;
100 public:
102  double computeCost(MultiHandOverSolution *solution);
103  double computeNavigationTrajectories(MultiHandOverSolution* solution, int action_index=-1);
104  //bool handOverFindConfs(MultiHandOverSolution * solution, int frontier_index=-1);
105  //bool handOverFindConfs(MultiAgentCell *c1,unsigned int a1,MultiAgentCell* c2,unsigned int a2);
106  //bool handOverFindConfs(FrontierPtr frontier);
107  double distanceCostNoTime(double d,unsigned int a);
108  double distanceCost(double d,unsigned int a);
109  double distanceTime(double d, unsigned int a);
110  double timeCost(double t, unsigned int a);
111  double objectTimeCost(double t);
112  double handOverCostEstimation(unsigned int i, unsigned int j);
113  double handOverCost(FrontierPtr frontier,double *time=0);
114  double handOverCost(MultiAgentCell *c1,unsigned int a1,MultiAgentCell *c2,unsigned int a2,double *time=0);
115  double handOverMaxDist(unsigned int a1, unsigned int a2);
117  double handOverSideCosts(MultiAgentCell *c1, unsigned int a1, MultiAgentCell* c2, unsigned int a2, double *coming_time=0);
118 private:
119  MultiHandOver *_mho;
120 };
121 
123 public:
124  //FrontierOptimizerClimber(MultiAgentGrid* grid, AbstractSolutionTools* solution_cost_computer,AbstracHandOverObjectCheck *ho_check);
126  virtual ~FrontierOptimizerClimber(){}
127  MultiHandOverSolution* optimize(MultiHandOverSolution *solution, unsigned int action_index,double keep_distance,double min_distance);
128  MultiAgentCell* findOptimalCellNullDistanceFrontier(MultiHandOverSolution *solution, unsigned int action_index);
129 private:
130  MultiAgentGrid* _grid;
131  ToolSet *_tool_set;
132  //AbstractSolutionTools* _solution_tools;
133  //AbstracHandOverObjectCheck* _ho_checker;
134  bool _showText;
135 };
136 
142 public:
143  HandOverDirectChecker(Robot* object, Robot *r1=0, Robot *r2=0);
144  virtual ~HandOverDirectChecker(){}
145  bool check();
146  confPtr_t getQMiddle(){return q_middle;}
147  virtual std::string getName(){return _name;}
148 private:
149  void setOrientationObjectForHO(Eigen::Vector3d & dir1);
150  Configuration confForBBAxisAlign(Eigen::Vector3d const & main_dir, Eigen::Vector3d const & second_dir);
151  confPtr_t q_middle;
152  std::vector<Eigen::Vector3d> _object_bb_vects;
153  std::vector<int> _object_directions_sorted_for_ho;
154 
158  static const std::string _name;
159 
160 };
161 
168 public:
169  HandOverWindowCheckerRRT(Robot *obj, Robot *r1=0, Robot *r2=0, bool dummy_smooth=true);
170  HandOverWindowCheckerRRT(Robot *obj, Robot *r1, Robot *r2, bool dummy_smooth,Eigen::Vector3d _shoulder1, Eigen::Vector3d _shoulder2, double reach1, double reach2);
171  virtual ~HandOverWindowCheckerRRT(){}
172  bool check();
173  void setUseDummySmooth(bool dummy){_use_dummy_smooth=dummy;}
174  confPtr_t getQMiddle(){return q_middle;}
175  virtual std::string getName(){return _name;}
176 private:
177  void constructBB();
178  void setObjectLimits();
179  void resetObjectLimits();
180  void saveObjectLimits();
181 
182  bool computeRRT(double time_limit_ms);
183  static inline Eigen::Vector2d v3dto2d(Eigen::Vector3d v3);
184 
185  vector<double> object_limits_bkp;
186 
187  std::pair<Eigen::Vector3d,Eigen::Vector3d> bb;
188  bool _use_dummy_smooth;
189 
190  confPtr_t q_middle;
191 
192  static const std::string _name;
193 };
194 
195 }
196 }
197 #endif // MULTIHANDOVERALGOS_H
double handOverSideCosts(MultiAgentCell *c1, unsigned int a1, MultiAgentCell *c2, unsigned int a2, double *coming_time=0)
Definition: MultiHandOverAlgos.cpp:218
double distanceTime(double d, unsigned int a)
the time an agent spend to run the given distance
Definition: MultiHandOverAlgos.cpp:159
virtual double objectTimeCost(double t)=0
the cost of delaying the delivery of t
Definition: HRICS_MultiHandOver.h:16
virtual double handOverSideCosts(MultiAgentCell *c1, unsigned int a1, MultiAgentCell *c2, unsigned int a2, double *coming_time=0)=0
the cost for the first agent to go to its target(final) position and for the second to come from its ...
virtual double timeCost(double t, unsigned int a)=0
the cost of making an agent wait
The ToolSet class bundles other tool classes and provides utilities to configure them easily...
Definition: MultiHandOverAlgos.h:67
Plannar HRI Grid considering multiple agents systems for HRi operations.
Definition: HRICS_MultiAgentGrid.hpp:28
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
Definition: MultiHandOverAlgos.h:98
The FrontierTester class is a unique interface for all available/desired handover/frontier testers...
Definition: MultiAgentHandOvers.h:60
The HandOverDirectChecker class makes the object go in a straigh line from its goal to target...
Definition: MultiHandOverAlgos.h:141
Definition: MultiHandOverAlgos.h:14
double objectTimeCost(double t)
the cost of delaying the delivery of t
Definition: MultiHandOverAlgos.cpp:169
Definition: MultiHandOverAlgos.h:47
virtual double distanceTime(double d, unsigned int a)=0
the time an agent spend to run the given distance
void updateObject()
sets the object in handoverObjectChecker from the MultiHandOver object
Definition: MultiHandOverAlgos.cpp:34
Plannar HRI Cell.
Definition: HRICS_MultiAgentGrid.hpp:462
Definition: MultiHandOverUtils.hpp:141
Classe représentant une Configuration d'un Robot.
Definition: configuration.hpp:25
The AlgoLoggerInterface class defines dummy logging methods that will be used for textual log and dis...
Definition: MultiHandOverUtils.hpp:36
The AbstracHandOverObjectCheck class is an abstract class providing tools to check the possibility of...
Definition: MultiAgentHandOvers.h:106
double timeCost(double t, unsigned int a)
the cost of making an agent wait
Definition: MultiHandOverAlgos.cpp:164
void setRobots(unsigned int a1, unsigned int a2)
sets the agents in handoverObjectChecker from their indices
Definition: MultiHandOverAlgos.cpp:29
The HandOverWindowCheckerRRT class gives tools to check the possibility of a hand over...
Definition: MultiHandOverAlgos.h:167
Definition: MultiHandOverAlgos.h:122