Multi-robot Playground
MapStitchingNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Alysson Ribeiro da Silva
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  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. All advertising materials mentioning features or use of this software must
16  * display the following acknowledgement:
17  * This product includes software developed by Alysson Ribeiro da Silva.
18  *
19  * 4. Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * 5. The source and the binary form, and any modifications made to them
24  * may not be used for the purpose of training or improving machine learning
25  * algorithms, including but not limited to artificial intelligence, natural
26  * language processing, or data mining. This condition applies to any derivatives,
27  * modifications, or updates based on the Software code. Any usage of the source
28  * or the binary form in an AI-training dataset is considered a breach of
29  * this License.
30  *
31  * THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR
32  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
34  * EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42 
43 /*
44  * Ros and system
45  */
46 #include <string.h>
47 #include <iostream>
48 #include <signal.h>
49 #include <vector>
50 #include "ros/ros.h"
51 #include "ros/package.h"
52 
53 /*
54  * Messages
55  */
56 #include "geometry_msgs/Pose.h"
57 #include "nav_msgs/OccupancyGrid.h"
58 #include "geometry_msgs/PoseArray.h"
59 #include "multirobotsimulations/CustomPose.h"
60 #include "multirobotsimulations/MockPackage.h"
61 #include "std_msgs/Float64MultiArray.h"
62 #include "std_msgs/Int8MultiArray.h"
63 #include "visualization_msgs/Marker.h"
64 #include "visualization_msgs/MarkerArray.h"
65 
66 /*
67  * Helpers
68  */
69 #include "Common.h"
70 
72  public:
75 
76  private:
77  void CommunicationsCallback(std_msgs::Int8MultiArray::ConstPtr msg);
78  void RelativeStartingPosesCallback(geometry_msgs::PoseArray::ConstPtr msg);
79  void OccCallback(nav_msgs::OccupancyGrid::ConstPtr msg);
80  void Fusemaps(nav_msgs::OccupancyGrid& occ,
81  nav_msgs::OccupancyGrid& other,
82  geometry_msgs::Pose& relative,
83  const bool& replace);
84  void Update();
85 
86  /*
87  * Control variables
88  */
90  int aId;
91  int aRobots;
92  bool aDirty;
93  double aRate;
94  std::string aNamespace;
95 
96  /*
97  * Routines
98  */
99  std::vector<ros::Timer> aTimers;
100 
101  /*
102  * Subscribers
103  */
104  std::vector<ros::Subscriber> aSubscribers;
105 
106  /*
107  * Advertisers
108  */
109  ros::Publisher aFusionPublisher;
110 
111  /*
112  * Messages
113  */
114  nav_msgs::OccupancyGrid aFusionMsg;
115  std_msgs::Int8MultiArray aRobotsInCommMsg;
116  geometry_msgs::PoseArray aRobotsRelativePosesMsg;
117 
118  /*
119  * Helpers
120  */
121  std::vector<nav_msgs::OccupancyGrid> aRobotsOcc;
122  std::vector<bool> aReceivedOccs;
124 };
MapStitchingNode::aTimers
std::vector< ros::Timer > aTimers
Definition: MapStitchingNode.h:99
MapStitchingNode::aDirty
bool aDirty
Definition: MapStitchingNode.h:92
MapStitchingNode::aFusionMsg
nav_msgs::OccupancyGrid aFusionMsg
Definition: MapStitchingNode.h:114
MapStitchingNode::aRobotsOcc
std::vector< nav_msgs::OccupancyGrid > aRobotsOcc
Definition: MapStitchingNode.h:121
MapStitchingNode::aSubscribers
std::vector< ros::Subscriber > aSubscribers
Definition: MapStitchingNode.h:104
MapStitchingNode::aNamespace
std::string aNamespace
Definition: MapStitchingNode.h:94
MapStitchingNode::aRate
double aRate
Definition: MapStitchingNode.h:93
MapStitchingNode::~MapStitchingNode
~MapStitchingNode()
MapStitchingNode::aReceivedOccs
std::vector< bool > aReceivedOccs
Definition: MapStitchingNode.h:122
MapStitchingNode::aQueueSize
int aQueueSize
Definition: MapStitchingNode.h:89
MapStitchingNode::aRobotsInCommMsg
std_msgs::Int8MultiArray aRobotsInCommMsg
Definition: MapStitchingNode.h:115
MapStitchingNode::aFusionPublisher
ros::Publisher aFusionPublisher
Definition: MapStitchingNode.h:109
MapStitchingNode::MapStitchingNode
MapStitchingNode()
Common.h
MapStitchingNode::aId
int aId
Definition: MapStitchingNode.h:90
MapStitchingNode
Definition: MapStitchingNode.h:71
MapStitchingNode::Update
void Update()
MapStitchingNode::aRobotsRelativePosesMsg
geometry_msgs::PoseArray aRobotsRelativePosesMsg
Definition: MapStitchingNode.h:116
MapStitchingNode::CommunicationsCallback
void CommunicationsCallback(std_msgs::Int8MultiArray::ConstPtr msg)
MapStitchingNode::OccCallback
void OccCallback(nav_msgs::OccupancyGrid::ConstPtr msg)
MapStitchingNode::RelativeStartingPosesCallback
void RelativeStartingPosesCallback(geometry_msgs::PoseArray::ConstPtr msg)
MapStitchingNode::aRobots
int aRobots
Definition: MapStitchingNode.h:91
MapStitchingNode::aReceivedRelativePoses
bool aReceivedRelativePoses
Definition: MapStitchingNode.h:123
MapStitchingNode::Fusemaps
void Fusemaps(nav_msgs::OccupancyGrid &occ, nav_msgs::OccupancyGrid &other, geometry_msgs::Pose &relative, const bool &replace)