1 #ifndef HRICS_HRICS_MULTIHANDOVER_H
2 #define HRICS_HRICS_MULTIHANDOVER_H
4 #include "HRICS_Workspace.hpp"
6 #include "planner/planner.hpp"
7 #include "utils/multiHandOver/SimpleGraph.h"
8 #include "Grid/HRICS_MultiAgentGrid.hpp"
10 #include "utils/MultiHandOverAlgos.h"
11 #include "utils/MultiHandOverDisplay.h"
22 typedef enum {NONE,RANDOM_SEARCH,LWA_SEARCH,WA_SEARCH} SearchAlgo_t;
30 void setDefaultEnvVar(
void);
31 bool initFromConfXML(std::istream &is);
32 bool initFromConfXML(std::string path);
42 void setDefaultHandOverTesters(std::vector<std::string> &some_defaults){this->_handover_testers_defaults_set=some_defaults;}
46 unsigned int runScript(std::string filename);
52 unsigned int findAgents();
54 void fetchAgentsConfsInitGoTo();
55 unsigned int findManipulableObjects();
56 unsigned int computeAgentsGraph(
void);
58 void computeGrid(
void);
59 void computeFrontiers(
void){_grid->searchAllFrontiers();_progression_state=FRONTIERS_DISTANCE;}
63 void resetManipulablesConf(
void);
72 void setToComputeHOTraj(
bool activate,
int solution=-1,
int step=0);
73 void computeLongestSolutionDistance();
87 void clearSolutions(
void);
114 bool handOverPossible(
unsigned int a1,
unsigned int a2);
181 double navigationRelatedCost(
double dist,
unsigned int agent);
182 double navigationRelatedCostTime(
double dist,
unsigned int agent,
double &time);
185 bool getSolutionDataForMHP(std::vector<MHO::MultiHandOverMhpHO> &hand_overs,std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > &path,
double &cost,
double &duration, std::string &main_agent_name);
205 void setSearchAlgo(MultiHandOver::SearchAlgo_t algo){_search_algo=algo;}
206 MultiHandOver::SearchAlgo_t getSearchAlgo(){
return _search_algo;}
207 double getEpsilonForLWAstar(){
return _epsilon;}
210 double getGridCellSize(
void){
return _cellSize;}
211 void setEpsilonForLWAstar(
double e){this->_epsilon=std::max(1.,e);}
212 void setCostsFactors(
double dist,
double time,
double agent_costs,
double hri){ _f_dist=dist;_f_time=time;_f_agent_cost=agent_costs;_f_hri=hri;}
213 void getCostsFactors(
double &dist,
double &time,
double &agent_costs,
double &hri){ dist=_f_dist;time=_f_time;agent_costs=_f_agent_cost;hri=_f_hri;}
215 void setSearchSolutionStopCondition(
int max_it,
int overheat,
int time_limit_ms){ _max_iterations=max_it;_overheat_temperature=overheat;_time_limit=time_limit_ms;}
216 void getSearchSolutionStopCondition(
int &max_it,
int &overheat,
int &time_limit_ms){ max_it=_max_iterations;overheat=_overheat_temperature;time_limit_ms=_time_limit;}
218 FrontierCells::FrontierCheckStatus getFrontierMaxCheckStatus(){
return _max_frontier_check_status;}
219 void setFrontierMaxCheckStatus(FrontierCells::FrontierCheckStatus fcs){_max_frontier_check_status = fcs;}
221 const std::vector<Robot*>& getAgents(
void){
return this->_agents;}
222 const std::vector<Robot*>& getManipulableObjects(
void){
return this->_manipulable;}
228 void setFirstAgent(
Robot* f){_first_agent=f;setFirstAgentNode();}
229 Robot* getFirstAgent(
void){
return _first_agent;}
230 void setTargetAgent(
Robot* f){_target_agent=f;setTargetAgentNode();}
231 Robot* getTargetAgent(
void){
return _target_agent;}
232 void setTargetAgent(std::string name);
233 void setFirstAgent(std::string name);
234 void setTargetAgent(p3d_rob* rob);
235 void setFirstAgent(p3d_rob* rob);
236 void setRandomizeFirstTarget(
bool b){_random_first_target_agents=b;}
237 void setObject(
unsigned int i){setObject(_manipulable[i]);}
238 void setObject(
Robot* obj){_object=obj;_object_bb_vects.clear();}
239 Robot *getObject(){
return _object;}
240 void setObject(p3d_rob* obj);
242 bool usePostProcess(){
return this->_use_post_process;}
243 void usePostProcess(
bool b){this->_use_post_process=b;}
245 void setFirstAgentNode(
void);
246 void setTargetAgentNode(
void);
253 void setAgentUseCost(
unsigned int i,
double cost){this->_mho_agents[i].use_cost=cost;}
255 double getAgentUseCost(
unsigned int i){
return this->_mho_agents[i].use_cost;}
256 double getAgentUseCost(
Robot * r);
259 void setAgentSpeed(
unsigned int i,
double speed){this->_mho_agents[i].speed=speed;}
260 double getAgentSpeed(
unsigned int i){
return this->_mho_agents[i].speed;}
261 bool isHuman(
unsigned int i){
return this->_mho_agents[i].is_human;}
265 double getTimeHO(
unsigned int a1,
unsigned int a2);
266 void setTimesHO(
double rr,
double hh,
double rh){_r_r_ho_time=rr;_r_h_ho_time=rh;_h_h_ho_time=hh;}
274 void setCheckFrontierBefore(
bool b){this->_check_frontier_before=b;}
275 bool getCheckFrontiersBefore(
void){
return this->_check_frontier_before;}
283 void setUseDummySmoothInFrontierCheck(
bool b){_use_dummy_smooth_for_frontier_check=b;}
284 double getShoulderHeight(
unsigned int agent);
285 Eigen::Vector3d getObjectMainDirection(
void);
286 Configuration confForBBAxisAlign(
Robot *
object, Eigen::Vector3d
const & main_dir, Eigen::Vector3d
const & second_dir);
296 void checkAllMetaFrontiersWithObject(
void);
297 bool checkMetaFrontiersWithObject(
unsigned int a1,
unsigned int a2);
298 bool checkMetaFrontierWithObject(
unsigned int a1,
unsigned int a2,MetaFrontierPtr mf);
328 void printSolutionsForest(
void);
330 void printMainTimes(std::vector<double> times);
331 void printLWAStats();
333 void setAgentIndexToDrawGrid(
unsigned int index){
334 if(_grid) this->_grid->setAgentIndexToDrawGrid(index);
337 void setDrawAgentAccessibilityGrid(
bool b,
bool boundariesOnly=
false){
if(_grid) this->_grid->setDrawAgentAccessibilityGrid(b,boundariesOnly);}
338 void setDrawFrontiers(
bool b,
unsigned int i=0,
unsigned int j=0){
if(_grid) _grid->setDrawFrontiers(b,i,j);}
340 void drawObjectWhenFrontierChecking(
bool b){_draw_object_frontiers_checks=b;}
341 void setDrawAgentsDuringSearch(
bool b){_draw_agents_holding_conf_during_search=b;}
342 void setDraw2dPaths(
bool b){_draw_2d_path=b;}
343 void setDrawAll2dPaths(
bool b){_draw_all_2d_pathes=b;}
344 void setDrawLWA(
bool b){_draw_lwa=b;
if(_display_lwa_in_grid_obj){_display_lwa_in_grid_obj->setDraw(b);}}
346 MHO::MultiHandOverSolution::CostData getSolutionDataStudio(
int solution);
355 void getConfHandOver(
int solution,
int step, std::string robot_name, confPtr_t &conf);
356 void draw2dPath(
void);
357 void draw2dPath(std::vector<MultiAgentCell*>
const & path,
int color_id,
bool alt=
false);
361 #ifdef DRAW_OPTIMIZE_FRONTIER
367 void playTaskStepByStep(MHO::Task* task);
368 void playSolutionTrajSync(MHO::Task *task);
369 bool playSolutionTaskSyncStep(
int solution=-1);
370 void computeTaskTrajs(MHO::Task* task);
371 void setSubTaskTrajToRobot(MHO::SubTask* subtask);
372 void playSolutionTask(
int solution);
373 void setPlaySolutionTask(
int solution);
374 void setPlaySolutionTaskTraj(
int solution);
375 void setPlaySolutionSyncStepByStep(
int solution);
376 bool isEndPlaySolutionTaskTraj();
379 MultiAgentGrid *getPlanGrid(
void){
return _grid;}
385 enum {INIT, FRONTIERS_DISTANCE,FRONTIERS_OBJECT_PATH,END} _progression_state;
386 std::vector<MHO::MultiHandOverAgent> _mho_agents;
387 std::vector<Robot*> _agents;
388 std::vector<Robot*> _manipulable;
390 std::vector<mho::Node*> _agents_nodes;
392 double _r_r_ho_time,_r_h_ho_time,_h_h_ho_time;
394 double _f_dist,_f_time,_f_agent_cost,_f_hri;
395 double _max_dist, _max_time,_max_use_cost;
397 bool _use_rrt_for_frontier_check;
398 bool _use_dummy_smooth_for_frontier_check;
400 bool _check_frontier_before;
405 enum STAT_FIELDS {SF_OK,SF_COST,SF_COST_LWA,
406 SF_AGENT_FROM, SF_AGENT_TO,
407 SF_EPSILON,SF_TIME_FACT,SF_AGENT_FACT,SF_HRI_FACT,SF_DIST_FACT,
408 SF_TIME_TOT,SF_TIME_LWA,SF_TIME_POSTPROC,
409 SF_TMP_COST_NB, SF_TMP_COST_MEAN, SF_TMP_COST_STDEV,
410 SF_TRUE_COST_NB, SF_TRUE_COST_MEAN, SF_TRUE_COST_STDEV,
411 SF_HO_COST_NB, SF_HO_COST_MEAN, SF_HO_COST_STDEV,
412 SF_HEURISTIC_NB, SF_HEURISTIC_MEAN, SF_HEURISTIC_STDEV,
413 SF_AGENT_NB,SF_HO_NB,SF_OBJ_DIST,SF_EXEC_TIME,
415 std::vector< std::vector < double > > _lwa_stats;
418 FrontierCells::FrontierCheckStatus _max_frontier_check_status;
419 MHO::ToolSet *_tool_set;
420 std::vector<std::string> _handover_testers_defaults_set;
422 std::vector<Configuration> _agents_init_confs;
423 std::vector<Configuration> _agents_target_confs;
424 std::vector<Configuration> _manipulables_init_confs;
427 Robot *_target_agent;
428 bool _random_first_target_agents;
430 std::vector<Eigen::Vector3d> _object_bb_vects;
431 std::vector<int> _object_directions_sorted_for_ho;
438 vector<pair<double,vector<mho::NodeInterface*> > > _raw_solution;
440 bool _use_post_process;
442 std::vector<MHO::MultiHandOverSolution*> _solutions;
443 std::vector<MHO::Task*> _solutions_as_tasks;
444 MHO::MultiHandOverSolution * _best_solution;
446 SearchAlgo_t _search_algo;
453 int _overheat_temperature;
456 bool _compute_for_all_robots;
457 bool _compute_traj_only;
458 MHO::MultiHandOverSolution * _solution_to_compute_traj;
459 unsigned int _step_to_compute_traj;
466 bool _draw_object_frontiers_checks;
467 bool _draw_agents_holding_conf_during_search;
469 unsigned int _solution_index_to_draw;
470 unsigned int _solution_step_index_to_draw;
471 bool _play_solution_task;
472 bool _play_solution_task_traj;
473 bool _play_solution_sync_step_by_step;
474 bool _draw_all_2d_pathes;
476 MHO::DisplayLWAstarInGrid* _display_lwa_in_grid_obj;
477 MHO::MultiHandOverDisplay *_mho_display;
478 #ifdef DRAW_OPTIMIZE_FRONTIER
479 bool _draw_optimize_frontier;
485 #endif // HRICS_HRICS_MULTIHANDOVER_H
double computeNavigationTrajectories(MHO::MultiHandOverSolution *solution, int action_index=-1)
computeNavigationTrajectories
Definition: HRICS_MultiHandOver.cpp:1792
*faster but not conservative *void setUseRrtInFrontierCheck(bool b)
to use an RRT on the object as free flyer to check frontier or not.
Definition: HRICS_MultiHandOver.h:282
MHO::MultiHandOverAgent * getAgentStruct(unsigned int a)
the MHO::MultiHandOverAgent corresponding to agent ID a
Definition: HRICS_MultiHandOver.h:226
Definition: HRICS_MultiHandOver.h:16
Definition: SimpleGraph.h:19
MultiAgentCell * getAgentTargetCell(unsigned int a)
returns 0 if have_final_position is set to false for that agent, a ptr to the cell otherwise...
Definition: HRICS_MultiHandOver.cpp:928
void initToolSet()
Initialize the tool set for algorithm acording to the settings.
Definition: HRICS_MultiHandOver.cpp:321
bool randomCheckFrontiersWithObject(std::tr1::shared_ptr< FrontierCells > &frontier_found, unsigned int a1, unsigned int a2, unsigned int max_it)
check frontiers with object, stop when one if found to be OK, or max_it checks are made ...
Definition: HRICS_MultiHandOver.cpp:1213
unsigned int run()
Run function.
Definition: HRICS_MultiHandOver.cpp:656
void resetAgentsConf(void)
reset the agents to their initial configuration
Definition: HRICS_MultiHandOver.cpp:902
unsigned int runScriptFromEnvVar()
reads the environment variable $MOVE3D_SCRIPT to get a script/conf file to execute ...
Definition: HRICS_MultiHandOver.cpp:467
Plannar HRI Grid considering multiple agents systems for HRi operations.
Definition: HRICS_MultiAgentGrid.hpp:28
MultiAgentCell * findOptimalCellNullDistanceFrontier(MHO::MultiHandOverSolution *solution, unsigned int action_index)
optimalCellNullDistanceFrontier
Definition: HRICS_MultiHandOver.cpp:1719
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
MHO::MultiHandOverSolution * getLowCostRandomSolution(double sigma, int *index=0)
get a randomly selected solution, most probably with low cost
Definition: HRICS_MultiHandOver.cpp:2113
This file implements macros to help with the logging, in a way similar to ROS, using log4cxx...
bool handOverFindConfs(MHO::MultiHandOverSolution *solution, int frontier_index=-1)
handOverFindConfs
Definition: HRICS_MultiHandOver.cpp:1526
Definition: MultiHandOverUtils.hpp:92
The MultiHandOverHeuristic class provides an heuristic based on euclidian distance and minimal cost b...
Definition: MultiHandOverUtils.hpp:482
unsigned int runScript(std::string filename)
reads the given script and execute it
Definition: HRICS_MultiHandOver.cpp:478
double setSolutionStepRobotsConfs(int solution, int step, MHO::MultiHandOverSolution::CostData &cost_data)
set the robots to their conf computed in searchSolutions() for the given solution and step ...
Definition: HRICS_MultiHandOver.cpp:2989
Plannar HRI Cell.
Definition: HRICS_MultiAgentGrid.hpp:462
MHO::MultiHandOverSolution * optimizeFrontier(MHO::MultiHandOverSolution *solution, unsigned int action_index, double keep_distance, double min_distance)
optimize a frontier in a solution to minimize the cost.
Definition: HRICS_MultiHandOver.cpp:1703
Definition: MultiHandOverUtils.hpp:141
void setOrientationObjectForHO(Eigen::Vector3d &dir1)
set the orientation of the object for a handover
Definition: HRICS_MultiHandOver.cpp:1308
unsigned int computeRawSolutions(float cost_majoration)
compute possible handover successions
Definition: HRICS_MultiHandOver.cpp:1099
Classe représentant une Configuration d'un Robot.
Definition: configuration.hpp:25
void setDrawOptimizeFrontier(bool b)
sets the option of drawing the frontier optimization process as 2D cells representing the frontier cu...
Definition: HRICS_MultiHandOver.h:362
Definition: MultiHandOverUtils.hpp:248
void setGridCellSize(double size)
set the cell size for discretisation step in the grid
Definition: HRICS_MultiHandOver.h:209
void searchSolutionLWAstar(bool no_lazy)
searchSolutionLWAstar
Definition: HRICS_MultiHandOver.cpp:2382
bool checkFrontierWithObject(FrontierCells &frontier)
checkFrontierWithObject
Definition: HRICS_MultiHandOver.cpp:1328
MHO::MultiHandOverHeuristic * createAstarHeuristic(void)
returns a pointer to newly created Heuristic class for main A* search.
Definition: HRICS_MultiHandOver.cpp:359
void searchSolutions(void)
The core function of this class, it search for an optimal solution.
Definition: HRICS_MultiHandOver.cpp:2188
AStarHeuristic_t
available heuristic types for [L][W]A*
Definition: HRICS_MultiHandOver.h:202
Base class for the HRICS motion planners.
Definition: HRICS_Workspace.hpp:37