Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef PNCONTROLLER_HPP_
00035 #define PNCONTROLLER_HPP_
00036 #include <navcon_msgs/RegisterController.h>
00037
00038 #include <boost/config.hpp>
00039 #include <boost/graph/adjacency_list.hpp>
00040
00041 #include <Eigen/Dense>
00042
00043 #include <string>
00044 #include <map>
00045 #include <set>
00046
00047 namespace labust
00048 {
00049 namespace control
00050 {
00068 class PNController
00069 {
00070 struct PlaceInfo
00071 {
00072 PlaceInfo():
00073 place_num(-1),
00074 enable_t(-1),
00075 disable_t(-1){};
00076
00077 int place_num,
00078 enable_t,
00079 disable_t;
00080 };
00081
00082 public:
00086 PNController();
00087
00091 void addToGraph(const navcon_msgs::RegisterControllerRequest& info);
00095 void get_firing(const std::string& name);
00099 void get_firing_r(const std::string& name);
00103 void reachability();
00107 void getDotDesc(std::string& desc);
00108
00109 private:
00113 bool firing_rec(int des_place,
00114 std::set<int>& skip_transitions,
00115 std::set<int>& visited_places);
00116
00120 int pnum, tnum;
00124 Eigen::MatrixXi Dm,Dp,I;
00125
00126
00127
00128 Eigen::VectorXi marking;
00132 std::map<int, std::string> placeMap, transitionMap;
00136 std::map<std::string, PlaceInfo> nameMap;
00140 std::vector<int> firing_seq;
00141
00142
00143 struct VertexProperty
00144 {
00145 Eigen::VectorXi marking;
00146 };
00147
00148 struct EdgeProperty
00149 {
00150 typedef boost::edge_property_tag kind;
00151 EdgeProperty():
00152 t_num(-1),
00153 weight(1){};
00154 EdgeProperty(int t_num):
00155 t_num(t_num),
00156 weight(1){};
00157
00158 int t_num;
00159 int weight;
00160 };
00161
00162 typedef boost::adjacency_list<boost::vecS, boost::vecS,
00163 boost::directedS, VertexProperty,
00164 boost::property<boost::edge_name_t, int> > GraphType;
00165
00166 struct pn_writer
00167 {
00168 pn_writer(GraphType& graph):graph(graph){}
00169 template <class Vertex>
00170 void operator()(std::ostream &out, const Vertex& e) const
00171 {
00172 out << "[label= \"(";
00173 for(int i=0; i<graph[e].marking.size();++i)
00174 {
00175 out<<graph[e].marking[i]<<",";
00176 }
00177 out<< ")\"]";
00178 }
00179 GraphType& graph;
00180 };
00181
00182 template<class PropertyMap, class NameMap>
00183 struct edge_writer {
00184 edge_writer(PropertyMap edge_map, NameMap map):
00185 edge_map(edge_map),
00186 map(map){};
00187 template <class Edge>
00188 void operator()(std::ostream &out, const Edge& e) const
00189 {
00190 out << "[label=\"" << map.at(edge_map[e]) << "\"]";
00191 }
00192 PropertyMap edge_map;
00193 NameMap map;
00194 };
00195
00196 template<class PropertyMap, class NameMap>
00197 edge_writer<PropertyMap, NameMap> make_edge_writer(PropertyMap pmap, NameMap map)
00198 {
00199 return edge_writer<PropertyMap, NameMap>(pmap,map);
00200 }
00201
00202 GraphType rgraph;
00203
00204 std::vector<Eigen::VectorXi> all_markings;
00205 std::vector<GraphType::vertex_descriptor> all_idx;
00206 };
00207 }
00208 }
00209
00210
00211 #endif