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
42namespace interactive_markers {
43class InteractiveMarkerServer;
44}
45
51 public fawkes::ROSAspect,
53{
54private:
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
73public:
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() */
82protected:
83 virtual void
85 {
86 Thread::run();
87 }
88
89private:
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
101private:
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
Thread to perform graph-based path planning.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual ~NavGraphInteractiveThread()
Destructor.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize the thread.
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:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Thread aspect to access NavGraph.
Definition: navgraph.h:36
fawkes::LockPtr< NavGraph > navgraph
NavGraph instance shared in framework.
Definition: navgraph.h:44
Topological graph node.
Definition: navgraph_node.h:36
Topological map graph.
Definition: navgraph.h:50
NavigatorInterface Fawkes BlackBoard Interface.
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
Thread class encapsulation of pthreads.
Definition: thread.h:46