libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
worldState.hpp
1 #ifndef WORLDSTATE_HPP
2 #define WORLDSTATE_HPP
3 
4 #include "P3d-pkg.h"
5 #include "API/Device/robot.hpp"
6 #include "API/scene.hpp"
7 #include "lightPlanner/proto/ManipulationPlanner.hpp"
8 
9 #include "../../planner/plannerFunctions.hpp"
10 #include "../lightPlanner/proto/lightPlanner.h"
11 #include "../lightPlanner/proto/lightPlannerApi.h"
12 
13 #include "API/facts.hpp"
14 
15 #include "graspPlanning/include/gpGrasp.h"
16 #include "taskConstraints.hpp"
17 
18 #include "mightabilitiesGrids.hpp"
19 
20 #include "solutionTools/structTools.hpp"
21 
22 #include "jsoncpp/json/value.h"
23 
24 class TaskSolution;
25 class TaskConstraints;
26 class MightabilitiesGrid;
27 
28 struct Attachement;
29 
31 {
32  MOVE3D_STATIC_LOGGER;
33 public:
34  WorldState();
35  WorldState(Scene* sce);
37  WorldState(Json::Value root, Scene* sce);
38 
39  void load();
40  void loadConf(confPtr_t q);
41  void saveAll();
42  void saveRobot(Robot* rob);
43  void saveConf(confPtr_t q);
44  bool replaceConf(confPtr_t q);
45  void clear();
46 
47  bool isEqualTo(WorldState* WS);
48 
49  void addAttachement(Robot* rob, Robot* obj);
50  void addAttachement(Robot* rob, Robot* obj, gpGrasp gr, int armId);
51  void addAttachement(Attachement a);
52 
53  std::vector<Attachement> getAttachements() {return attachements_list;}
54  void setAttachements(std::vector<Attachement> va) {attachements_list = va;}
55  Attachement getAttachement(Robot* rob, Robot* obj);
56  void clearAttachement();
57  void removeAttachements(Robot* rob, Robot* obj);
58  bool hasAttachement(Robot* rob);
59  bool hasAttachement(Robot* rob,Robot* obj);
60 
61  void saveCurrentAttachement();
62  void resetCurrentAttachements();
63  void loadAttachements();
64  Attachement getCurrentAttachment();
65 
66  std::vector<SurfaceAttachement> getSurfaceAttachements() {return surfaceAttachements_list;}
67  void setSurfaceAttachements(std::vector<SurfaceAttachement> va) {surfaceAttachements_list = va;}
68  void loadSurfaceAttachements();
69  void clearSurfaceAttachements();
70 
71  std::vector<confPtr_t > getRobotConfs() {return _robotsConfs;}
72  confPtr_t getRobotConf(Robot* rob);
73 
74  int getId() {return _id;}
75 // void setId(int id) {_id = id;}
76 
77  Scene* getScene() {return _sce;}
78 
79  std::vector<Fact> getFacts();
80  std::vector<Fact> getAllFacts();
81  //does not compare the values of the facts
82  Fact getThisFact(Fact FI);
83 
84  TaskSolution* getTSThatEndWithThisWS() {return endingStateOf;}
85  std::pair<int,int> getTSIndexThatEndWithThisWS() {return endingStateOfIndex;}
86  bool setTSThatEndWithThisWS(TaskSolution* TS, bool forceSetting = true);
87 
88  TaskConstraints* getTCForNextTask() {return _TCForNextTask;}
89  void setTCForNextTask(TaskConstraints* tc) {_TCForNextTask = tc;}
90  void clearTCForNextTask();
91 
92  void saveToDisk(FILE *file, std::string text);
93 
94  void initMightabilities();
95  MightabilitiesGrid* getMightabilities();
96 
97  double distanceTo(WorldState* ws);
98 
99  void updateRobotVirtualObj(Robot* r);
100 
101  gpGrasp getGraspFromId(int graspId, Robot* object, int armId, Robot *rob);
102 
103  Json::Value toJson();
104  void fromJson(Json::Value root);
105 
106 
107 
108 
109 private:
110  std::vector<confPtr_t > _robotsConfs;
111  std::vector<Attachement> attachements_list;
112  std::vector<SurfaceAttachement> surfaceAttachements_list;
113  //adding trajectories
114 
115  Scene* _sce;
116 
117  int _id;
118 
119  WorldStateFacts* WSF;
120  bool areFactsComputed;
121 
122  TaskSolution* endingStateOf;
123  std::pair<int,int> endingStateOfIndex;
124 
125  TaskConstraints* _TCForNextTask;
126 
127  MightabilitiesGrid* _MG;
128 
129  static int _idCount;
130 
131 };
132 
133 #endif // WORLDSTATE_HPP
Definition: taskSolution.hpp:9
Definition: facts.hpp:106
Definition: taskConstraints.hpp:34
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
Definition: mightabilitiesGrids.hpp:52
Class that represents a Scene, Described by a p3d file.
Definition: scene.hpp:22
Definition: worldState.hpp:30
Definition: facts.hpp:160
Definition: structTools.hpp:38