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 <aspect/aspect_provider.h>
25 #include <aspect/blackboard.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <core/threading/thread.h>
30 #include <interactive_markers/menu_handler.h>
31 #include <interfaces/NavigatorInterface.h>
32 #include <navgraph/aspect/navgraph.h>
33 #include <navgraph/navgraph.h>
34 #include <navgraph/navgraph_node.h>
35 #include <plugins/ros/aspect/ros.h>
36 #include <visualization_msgs/InteractiveMarker.h>
37 #include <visualization_msgs/InteractiveMarkerFeedback.h>
38 #include <visualization_msgs/MarkerArray.h>
39 
40 #include <memory>
41 
42 namespace interactive_markers {
43 class InteractiveMarkerServer;
44 }
45 
47  public fawkes::ClockAspect,
48  public fawkes::LoggingAspect,
51  public fawkes::ROSAspect,
53 {
54 private:
55  typedef struct
56  {
57  std::shared_ptr<interactive_markers::MenuHandler> handler;
58  interactive_markers::MenuHandler::EntryHandle ori_handle;
59  interactive_markers::MenuHandler::EntryHandle goto_handle;
60  interactive_markers::MenuHandler::EntryHandle remove_handle;
61  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> dir_connect_nodes;
62  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> undir_connect_nodes;
63  std::map<interactive_markers::MenuHandler::EntryHandle, std::string> disconnect_nodes;
64  } NodeMenu;
65 
66  typedef struct
67  {
68  interactive_markers::MenuHandler::EntryHandle add_handle;
69  interactive_markers::MenuHandler::EntryHandle save_handle;
70  interactive_markers::MenuHandler::EntryHandle stop_handle;
71  } GraphMenu;
72 
73 public:
76 
77  virtual void init();
78  virtual void loop();
79  virtual void finalize();
80 
81  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
82 protected:
83  virtual void
84  run()
85  {
86  Thread::run();
87  }
88 
89 private:
90  void process_node_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback);
91  void
92  process_node_ori_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback,
93  const NodeMenu & menu,
94  visualization_msgs::InteractiveMarker &int_marker);
95  void
96  process_graph_feedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback);
97 
98  void add_graph(fawkes::NavGraph *navgraph);
99  void add_node(const fawkes::NavGraphNode &node, fawkes::NavGraph *navgraph);
100 
101 private:
102  std::string cfg_global_frame_;
103  std::string cfg_save_filename_;
104 
105  interactive_markers::InteractiveMarkerServer *server_;
106 
107  std::map<std::string, NodeMenu> node_menus_;
108 
109  std::shared_ptr<interactive_markers::MenuHandler> graph_menu_handler_;
110  GraphMenu graph_menu_;
111 
113 };
114 
115 #endif
fawkes::NavGraphNode
Definition: navgraph_node.h:40
NavGraphInteractiveThread::NavGraphInteractiveThread
NavGraphInteractiveThread()
Constructor.
Definition: navgraph_interactive_thread.cpp:36
NavGraphInteractiveThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: navgraph_interactive_thread.h:84
NavGraphInteractiveThread
Definition: navgraph_interactive_thread.h:46
fawkes::NavGraph
Definition: navgraph.h:54
NavGraphInteractiveThread::finalize
virtual void finalize()
Finalize the thread.
Definition: navgraph_interactive_thread.cpp:343
NavGraphInteractiveThread::~NavGraphInteractiveThread
virtual ~NavGraphInteractiveThread()
Destructor.
Definition: navgraph_interactive_thread.cpp:42
fawkes::BlackBoardAspect
Definition: blackboard.h:38
fawkes::LoggingAspect
Definition: logging.h:38
fawkes::ROSAspect
Definition: ros.h:38
fawkes::NavGraphAspect
Definition: navgraph.h:41
fawkes::Thread
Definition: thread.h:45
fawkes::NavGraphAspect::navgraph
fawkes::LockPtr< NavGraph > navgraph
Definition: navgraph.h:50
NavGraphInteractiveThread::loop
virtual void loop()
Code to execute in the thread.
Definition: navgraph_interactive_thread.cpp:352
NavGraphInteractiveThread::init
virtual void init()
Initialize the thread.
Definition: navgraph_interactive_thread.cpp:319
fawkes::ConfigurableAspect
Definition: configurable.h:38
fawkes::NavigatorInterface
Definition: NavigatorInterface.h:39
fawkes::ClockAspect
Definition: clock.h:40