router_node.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, <copyright holder> <email>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the <organization> nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY <copyright holder> <email> ''AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <copyright holder> <email> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef ROUTER_NODE_H
30 #define ROUTER_NODE_H
31 
32 //ROS
33 #include <ros/ros.h>
34 #include <tuw_multi_robot_msgs/RobotGoalsArray.h>
35 #include <tuw_multi_robot_msgs/RobotGoals.h>
37 #include <nav_msgs/Odometry.h>
38 #include <tuw_multi_robot_msgs/Graph.h>
39 #include <nav_msgs/Path.h>
40 #include <nav_msgs/OccupancyGrid.h>
41 #include <tuw_multi_robot_msgs/RouterStatus.h>
42 #include <dynamic_reconfigure/server.h>
43 #include <tuw_multi_robot_router/routerConfig.h>
44 
47 #include <opencv/cv.hpp>
48 
49 //TODO disable got_map if not used
50 
51 namespace multi_robot_router
52 {
54 {
55 public:
64  void publishEmpty();
68  void publish();
69 
73  void monitorExecution();
78  void updateTimeout ( const float _secs );
81 
82 private:
83  //these 3 members are for time logging
88 
90 
91  tuw_multi_robot_msgs::RouterStatus mrrp_status_;
92 
93  dynamic_reconfigure::Server<tuw_multi_robot_router::routerConfig> param_server;
94  dynamic_reconfigure::Server<tuw_multi_robot_router::routerConfig>::CallbackType call_type;
96 
97  std::vector<ros::Subscriber> subOdom_;
103 
104  std::vector<RobotInfoPtr> subscribed_robots_;
105  std::vector<RobotInfoPtr> active_robots_;
106  std::map<std::string, double> finished_robots_;
107  std::vector<std::string> missing_robots_;
109  cv::Mat distMap_;
110  Eigen::Vector2d mapOrigin_;
112  std::string route_topic_;
113  std::string odom_topic_;
114  std::string path_topic_;
115  std::string goal_topic_;
116  std::string map_topic_;
117  std::string robot_info_topic_;
118  std::string voronoi_topic_;
122  bool got_map_ = false;
123  bool got_graph_ = false;
124  std::vector<Segment> graph_;
127  int id_;
128  float topic_timeout_s_ = 10;
129  bool freshPlan_ = false;
130  std::string singleRobotName_ = "";
132 
133  void parametersCallback ( tuw_multi_robot_router::routerConfig &config, uint32_t level );
134  void odomCallback ( const ros::MessageEvent<nav_msgs::Odometry const> &_event, int _topic );
135  void graphCallback ( const tuw_multi_robot_msgs::Graph &msg );
136  void goalsCallback ( const tuw_multi_robot_msgs::RobotGoalsArray &_goals );
137  void mapCallback ( const nav_msgs::OccupancyGrid &_map );
138  void robotInfoCallback ( const tuw_multi_robot_msgs::RobotInfo &_robotInfo );
139  void goalCallback ( const geometry_msgs::PoseStamped &_goal );
140  size_t getHash ( const std::vector<signed char> &_map, const Eigen::Vector2d &_origin, const float &_resolution );
141  size_t getHash ( const std::vector<Segment> &_graph );
142  static bool sortSegments ( const Segment &i, const Segment &j )
143  {
144  return i.getSegmentId() < j.getSegmentId();
145  }
146  void unsubscribeTopic ( std::string _robot_name );
147  float getYaw ( const geometry_msgs::Quaternion &_rot );
148  float calcRadius ( const int shape, const std::vector<float> &shape_variables ) const;
149  bool preparePlanning ( std::vector<float> &_radius, std::vector<Eigen::Vector3d> &_starts, std::vector<Eigen::Vector3d> &_goals, const tuw_multi_robot_msgs::RobotGoalsArray &_ros_goals, std::vector<std::string> &robot_names );
150 };
151 } // namespace multi_robot_router
152 #endif // Router_Node_H
void goalsCallback(const tuw_multi_robot_msgs::RobotGoalsArray &_goals)
uint32_t getSegmentId() const
Definition: srr_utils.cpp:60
float getYaw(const geometry_msgs::Quaternion &_rot)
dynamic_reconfigure::Server< tuw_multi_robot_router::routerConfig > param_server
Definition: router_node.h:93
std::vector< std::string > missing_robots_
robots finished with execution time
Definition: router_node.h:107
void parametersCallback(tuw_multi_robot_router::routerConfig &config, uint32_t level)
std::vector< RobotInfoPtr > subscribed_robots_
Definition: router_node.h:104
void monitorExecution()
monitors the execution
void unsubscribeTopic(std::string _robot_name)
ros::Publisher pubPlannerStatus_
Definition: router_node.h:95
void odomCallback(const ros::MessageEvent< nav_msgs::Odometry const > &_event, int _topic)
Router_Node(ros::NodeHandle &n)
Construct a new Router_Node object.
Definition: router_node.cpp:62
ros::Subscriber subVoronoiGraph_
Definition: router_node.h:101
size_t getHash(const std::vector< signed char > &_map, const Eigen::Vector2d &_origin, const float &_resolution)
void mapCallback(const nav_msgs::OccupancyGrid &_map)
void publish()
publishes a RoutingTable
tuw_multi_robot_msgs::RouterStatus mrrp_status_
Definition: router_node.h:91
ros::Subscriber subSingleRobotGoal_
Definition: router_node.h:100
ros::NodeHandle n_
Node handler to the root node.
Definition: router_node.h:79
ros::NodeHandle n_param_
Node handler to the current node.
Definition: router_node.h:80
void robotInfoCallback(const tuw_multi_robot_msgs::RobotInfo &_robotInfo)
void graphCallback(const tuw_multi_robot_msgs::Graph &msg)
float calcRadius(const int shape, const std::vector< float > &shape_variables) const
void publishEmpty()
publishes an empty RoutingTable
std::map< std::string, double > finished_robots_
robots currently used by the planner
Definition: router_node.h:106
static bool sortSegments(const Segment &i, const Segment &j)
Definition: router_node.h:142
dynamic_reconfigure::Server< tuw_multi_robot_router::routerConfig >::CallbackType call_type
Definition: router_node.h:94
bool preparePlanning(std::vector< float > &_radius, std::vector< Eigen::Vector3d > &_starts, std::vector< Eigen::Vector3d > &_goals, const tuw_multi_robot_msgs::RobotGoalsArray &_ros_goals, std::vector< std::string > &robot_names)
std::vector< Segment > graph_
Definition: router_node.h:124
void goalCallback(const geometry_msgs::PoseStamped &_goal)
std::vector< ros::Subscriber > subOdom_
Definition: router_node.h:97
std::vector< RobotInfoPtr > active_robots_
robots avaliable
Definition: router_node.h:105
void updateTimeout(const float _secs)
used to update the nodes timeout to latch topics


tuw_multi_robot_router
Author(s): Benjamin Binder
autogenerated on Mon Jun 10 2019 15:42:49