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_;
114  bool got_map_ = false;
115  bool got_graph_ = false;
116  std::vector<Segment> graph_;
119  int id_;
120  float topic_timeout_s_ = 10;
121  bool freshPlan_ = false;
123 
124  void parametersCallback ( tuw_multi_robot_router::routerConfig &config, uint32_t level );
125  void odomCallback ( const ros::MessageEvent<nav_msgs::Odometry const> &_event, int _topic );
126  void graphCallback ( const tuw_multi_robot_msgs::Graph &msg );
127  void goalsCallback ( const tuw_multi_robot_msgs::RobotGoalsArray &_goals );
128  void mapCallback ( const nav_msgs::OccupancyGrid &_map );
129  void robotInfoCallback ( const tuw_multi_robot_msgs::RobotInfo &_robotInfo );
130  void goalCallback ( const geometry_msgs::PoseStamped &_goal );
131  size_t getHash ( const std::vector<signed char> &_map, const Eigen::Vector2d &_origin, const float &_resolution );
132  size_t getHash ( const std::vector<Segment> &_graph );
133  static bool sortSegments ( const Segment &i, const Segment &j )
134  {
135  return i.getSegmentId() < j.getSegmentId();
136  }
137  void unsubscribeTopic ( std::string _robot_name );
138  float getYaw ( const geometry_msgs::Quaternion &_rot );
139  float calcRadius ( const int shape, const std::vector<float> &shape_variables ) const;
140  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 );
141 };
142 } // namespace multi_robot_router
143 #endif // Router_Node_H
void goalsCallback(const tuw_multi_robot_msgs::RobotGoalsArray &_goals)
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)
float calcRadius(const int shape, const std::vector< float > &shape_variables) const
std::vector< RobotInfoPtr > subscribed_robots_
Definition: router_node.h:104
void monitorExecution()
monitors the execution
Definition: router_node.cpp:99
void unsubscribeTopic(std::string _robot_name)
ros::Publisher pubPlannerStatus_
Definition: router_node.h:95
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)
void publishEmpty()
publishes an empty RoutingTable
uint32_t getSegmentId() const
Definition: srr_utils.cpp:60
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:133
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:116
void goalCallback(const geometry_msgs::PoseStamped &_goal)
void odomCallback(const ros::MessageEvent< nav_msgs::Odometry const > &_event, int _topic)
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 Feb 28 2022 23:57:49