libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
Sem_PlanParts.hpp
1 #ifndef SEM_PLANPARTS_H
2 #define SEM_PLANPARTS_H
3 
4 #include <jsoncpp/json/json.h>
5 
6 #include "API/Device/robot.hpp"
7 #include "Logging/Logger.h"
8 #include "Sem_AgentType.hpp"
9 
10 
11 namespace Sem {
12 
14 {
15 public:
16  PlanningType();
17  PlanningType(std::string s);
18  virtual ~PlanningType();
19  std::string toString() const;
20  bool isDefined() const {return _value >=0;}
21 
22  friend bool operator==(PlanningType const &p1, PlanningType const &p2);
23  friend bool operator!=(PlanningType const &p1, PlanningType const &p2);
24  friend bool operator<(PlanningType const &p1, PlanningType const &p2);
25  friend bool operator>(PlanningType const &p1, PlanningType const &p2);
26 
27  static std::vector<PlanningType> currentlyDefinedPlanningTypes();
28 
29 protected:
30  static std::vector<std::string> __strs;
31 private:
32  int _value;
33 };
34 
36 {
37  MOVE3D_STATIC_LOGGER;
38 public:
39  PlanningPart();
40  PlanningPart(AgentType agent_type,PlanningType plan_type,const std::vector<int> &joint_ids,const std::vector<int> & arm_ids);
45  PlanningPart(std::vector<PlanningPart*> planning_parts);
46  virtual ~PlanningPart();
47 
48  void concat(const PlanningPart &p);
49 
50  std::vector<int> getAllJointIds() const;
51  std::vector<int> getJointsOfArmId(int armId) const;
52 
58 
59  PlanningType planType() const;
60  void setPlanType(const PlanningType &planType);
61 
68  const std::vector<int> &jointsIndices() const;
69  void setJointsIndices(const std::vector<int> &jointsIndices);
70 
71 
72  AgentType agentType() const;
73  void setAgentType(const AgentType &agentType);
74 
75  const std::vector<int> &armIds() const;
76  void setArmIds(const std::vector<int> &armIds);
77 
78  static Robot* getRobotOfType(AgentType t);
79 
80  bool operator==(PlanningPart const &other) const ;
81  bool operator!=(PlanningPart const &other) const ;
82 
83 private:
84  AgentType _agentType;
85  PlanningType _planType;
86  std::vector<int> _jointsIndices;
87  std::vector<int> _armIds;
88 };
89 
90 class PlanParts
91 {
92  MOVE3D_STATIC_LOGGER;
93 public:
94 
95  PlanParts( std::string global_json_path,bool proactive=false);
96  ~PlanParts();
97 
98  bool fetchData();
99  void clearData(AgentType t);
100  bool importJsonFile(std::string path);
101 
102  bool createFromActiveJoints(PlanningType plan_type);
103 
104  bool getJsonRoot(Json::Value &root,std::string &file_path);
105  bool readJsonAgent(AgentType t);
106  bool readJsonAgent(Json::Value &root,const std::string &file);
107  bool readJsonPlanType(AgentType agn_type,PlanningType plan_type);
108  bool parsePlanPart(AgentType agn_type, std::string const &plan_type_str, Json::Value const &joint_set_json);
109  bool parsePlanPart(AgentType agn_type, PlanningType plantype, Json::Value const &joint_set_json);
110 
111  void save();
112  void writeJson(AgentType t);
113  void appendJointsSetToJson(Json::Value &planning_parts_dict, const PlanningPart *jointsset);
114 
115  std::string getPath(AgentType t);
116 
117  void addPlanPart(AgentType agent_type, PlanningType plan_type, std::vector<int> const & joints, std::vector<int> const & arm_ids);
123  void addPlanPart(PlanningPart * jointsset);
124 
125  std::vector<PlanningPart *> getPlanningParts(AgentType agent_type, PlanningType plan_type);
126 
127  //std::vector<int> getPlanPart(HRI_AGENT_TYPE agent_type, PlanningType plan_type, bool *found=0,bool *have_other=0);
128 
129  // static std::string planningTypeToString(PlanningType t);
130  // static PlanningType stringToPlanningType(std::string const &s);
131 
135  bool proactive() const;
136  void setProactive(bool proactive);
137 
138 private:
139  //static std::map<PlanningType,std::string> _planningTypeStrings;
140 
141 private:
142  bool _proactive;
143  std::string _global_json_path;
144  std::map<AgentType, std::map<PlanningType,std::vector<PlanningPart *> > > _planParts;
145 };
146 
147 } // namespace Sem
148 
149 #endif // SEM_PLANPARTS_H
const std::vector< int > & jointsIndices() const
jointsIndices
Definition: Sem_PlanParts.cpp:636
Definition: Sem_AgentType.hpp:12
Definition: Sem_PlanParts.hpp:35
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
Definition: Sem_PlanParts.hpp:90
This file implements macros to help with the logging, in a way similar to ROS, using log4cxx...
Definition: Sem_PlanParts.hpp:13
bool proactive() const
proactive means that json data will be loaded on creation, otherwise it is read on getPlanPart() call...
Definition: Sem_PlanParts.cpp:413
static PlanningPart * createFromActiveJoints(PlanningType plan_type)
use active robot active joints to create a new joint set
Definition: Sem_PlanParts.cpp:533