Fawkes API  Fawkes Development Version
visualization_thread.h
1 
2 /***************************************************************************
3  * visualization_thread.h - Visualization for pathplan via rviz
4  *
5  * Created: Fri Nov 11 21:17:24 2011
6  * Copyright 2011-2012 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef __PLUGINS_VISPATHPLAN_VISPATHPLAN_THREAD_H_
23 #define __PLUGINS_VISPATHPLAN_VISPATHPLAN_THREAD_H_
24 
25 #include <core/threading/thread.h>
26 #include <core/threading/mutex.h>
27 #include <core/utils/lockptr.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <plugins/ros/aspect/ros.h>
31 #include <navgraph/navgraph.h>
32 #include <navgraph/navgraph_path.h>
33 
34 #include <ros/publisher.h>
35 #include <visualization_msgs/MarkerArray.h>
36 
37 
39 : public fawkes::Thread,
41  public fawkes::LoggingAspect,
42  public fawkes::ROSAspect,
44 {
45  public:
47 
48  virtual void init();
49  virtual void loop();
50  virtual void finalize();
51 
54 
56  void set_current_edge(std::string from, std::string to);
57  void reset_plan();
58 
59  virtual void graph_changed() throw();
60 
61  private:
62  void publish();
63  void add_circle_markers(visualization_msgs::MarkerArray &m, size_t &id_num,
64  float center_x, float center_y, float radius, unsigned int arc_length,
65  float r, float g, float b, float alpha, float line_width = 0.03);
66  float edge_cost_factor(
67  std::list<std::tuple<std::string, std::string, std::string, float>> &costs,
68  const std::string &from, const std::string &to, std::string &constraint_name);
69 
70  private:
71  size_t last_id_num_;
72  size_t constraints_last_id_num_;
73  ros::Publisher vispub_;
74 
75  float cfg_cost_scale_max_;
76 
78  std::string plan_to_;
79  std::string plan_from_;
80 
83 
84  std::string cfg_global_frame_;
85 };
86 
87 
88 #endif
virtual void finalize()
Finalize the thread.
Thread aspect to get access to a ROS node handle.
Definition: ros.h:39
void set_graph(fawkes::LockPtr< fawkes::NavGraph > &graph)
Set the graph.
void set_traversal(fawkes::NavGraphPath::Traversal &traversal)
Set current path.
virtual void graph_changed()
Function called if the graph has been changed.
Send Marker messages to rviz to show navgraph info.
Thread class encapsulation of pthreads.
Definition: thread.h:42
void set_current_edge(std::string from, std::string to)
Set the currently executed edge of the plan.
Thread aspect to log output.
Definition: logging.h:35
Sub-class representing a navgraph path traversal.
Definition: navgraph_path.h:41
virtual void init()
Initialize the thread.
Thread aspect to access configuration data.
Definition: configurable.h:35
void set_constraint_repo(fawkes::LockPtr< fawkes::NavGraphConstraintRepo > &crepo)
Set the constraint repo.
void reset_plan()
Reset the current plan.
Topological graph change listener.
Definition: navgraph.h:175
virtual void loop()
Code to execute in the thread.