Fawkes API  Fawkes Development Version
navgraph_interactive_thread.h
1 /***************************************************************************
2  * navgraph_thread.h - Graph-based global path planning
3  *
4  * Created: Tue Sep 18 15:56:35 2012
5  * Copyright 2012 Tim Niemueller [www.niemueller.de]
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #ifndef __PLUGINS_NAVGRAPH_INTERACTIVE_NAVGRAPH_INTERACTIVE_THREAD_H_
22 #define __PLUGINS_NAVGRAPH_INTERACTIVE_NAVGRAPH_INTERACTIVE_THREAD_H_
23 
24 #include <core/threading/thread.h>
25 #include <aspect/clock.h>
26 #include <aspect/configurable.h>
27 #include <aspect/logging.h>
28 #include <aspect/blackboard.h>
29 #include <aspect/aspect_provider.h>
30 #include <plugins/ros/aspect/ros.h>
31 #include <navgraph/aspect/navgraph.h>
32 
33 #include <interfaces/NavigatorInterface.h>
34 
35 #include <navgraph/navgraph.h>
36 #include <navgraph/navgraph_node.h>
37 
38 #include <visualization_msgs/MarkerArray.h>
39 #include <visualization_msgs/InteractiveMarker.h>
40 #include <visualization_msgs/InteractiveMarkerFeedback.h>
41 #include <interactive_markers/menu_handler.h>
42 
43 #include <memory>
44 
45 namespace interactive_markers {
46  class InteractiveMarkerServer;
47 }
48 
50 : public fawkes::Thread,
51  public fawkes::ClockAspect,
52  public fawkes::LoggingAspect,
55  public fawkes::ROSAspect,
57 {
58  private:
59  typedef struct {
60  std::shared_ptr<interactive_markers::MenuHandler> handler;
61  interactive_markers::MenuHandler::EntryHandle ori_handle;
62  interactive_markers::MenuHandler::EntryHandle goto_handle;
63  interactive_markers::MenuHandler::EntryHandle remove_handle;
64  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> dir_connect_nodes;
65  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> undir_connect_nodes;
66  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> disconnect_nodes;
67  } NodeMenu;
68 
69  typedef struct {
70  interactive_markers::MenuHandler::EntryHandle add_handle;
71  interactive_markers::MenuHandler::EntryHandle save_handle;
72  interactive_markers::MenuHandler::EntryHandle stop_handle;
73  } GraphMenu;
74 
75  public:
77  virtual ~NavGraphInteractiveThread();
78 
79  virtual void init();
80  virtual void loop();
81  virtual void finalize();
82 
83  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
84  protected: virtual void run() { Thread::run();}
85 
86  private:
87  void process_node_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback);
88  void process_node_ori_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback,
89  const NodeMenu &menu,
90  visualization_msgs::InteractiveMarker &int_marker);
91  void process_graph_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback);
92 
93  void add_graph(fawkes::NavGraph *navgraph);
94  void add_node(const fawkes::NavGraphNode &node, fawkes::NavGraph *navgraph);
95 
96  private:
97  std::string cfg_global_frame_;
98  std::string cfg_save_filename_;
99 
100  interactive_markers::InteractiveMarkerServer *server_;
101 
102  std::map<std::string, NodeMenu> node_menus_;
103 
104  std::shared_ptr<interactive_markers::MenuHandler> graph_menu_handler_;
105  GraphMenu graph_menu_;
106 
108 };
109 
110 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
Topological map graph.
Definition: navgraph.h:57
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Thread to perform graph-based path planning.
Topological graph node.
Definition: navgraph_node.h:38
Thread aspect to access NavGraph.
Definition: navgraph.h:37
NavigatorInterface Fawkes BlackBoard Interface.