Multi-robot Playground
Yamauchi1999Node.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 <vector>
47 #include "ros/ros.h"
48 
49 /*
50  * Messages
51  */
52 #include "nav_msgs/OccupancyGrid.h"
53 #include "std_msgs/String.h"
54 #include "multirobotsimulations/CustomPose.h"
55 #include "multirobotsimulations/Frontiers.h"
56 #include "visualization_msgs/Marker.h"
57 
58 /*
59  * Helpers
60  */
61 #include "Common.h"
62 
63 typedef enum {
66  state_idle = 11,
75 
77  public:
80 
81  private:
82  void EstimatePoseCallback(multirobotsimulations::CustomPose::ConstPtr msg);
83  void ClustersCallback(multirobotsimulations::Frontiers::ConstPtr msg);
84  void SubGoalFinishCallback(std_msgs::String::ConstPtr msg);
85  void CSpaceCallback(nav_msgs::OccupancyGrid::ConstPtr msg);
86  void SetExploringCallback(std_msgs::String::ConstPtr msg);
87  void SetBasestationCallback(std_msgs::String::ConstPtr msg);
88  void SetIdleCallback(std_msgs::String::ConstPtr msg);
89 
90  void ChangeState(const ExplorerState& newState);
91  int SelectFrontier(multirobotsimulations::Frontiers& centroids, tf::Vector3& selectFrontierWorld);
92  void CreateMarker(visualization_msgs::Marker& input, const char* ns, const int& id, const int& seq);
93  void SetGoal(const tf::Vector3& goal);
94  void Update();
95 
96  /*
97  * Control variables
98  */
100  int aRate;
101  int aRobots;
102  int aId;
103  bool aHasPose;
104  bool aHasOcc;
105  bool aDirty;
106  bool aFirst;
107  double aDeltaTime;
109  ros::Time aLastTime;
110  tf::Vector3 aWorldPos;
111  tf::Vector3 aGoalFrontier;
112  tf::Vector3 aGoalBasestation;
113  std::string aNamespace;
115 
116  /*
117  * Routines
118  */
119  std::vector<ros::Timer> aTimers;
120 
121  /*
122  * Subscribers
123  */
124  std::vector<ros::Subscriber> aSubscribers;
125 
126  /*
127  * Advertisers
128  */
129  ros::Publisher aGoalPublisher;
131 
132  /*
133  * Messages
134  */
135  multirobotsimulations::Frontiers aFrontierCentroidsMsg;
136  nav_msgs::OccupancyGrid aCSpaceMsg;
137 };
Yamauchi1999Node
Definition: Yamauchi1999Node.h:76
Yamauchi1999Node::SubGoalFinishCallback
void SubGoalFinishCallback(std_msgs::String::ConstPtr msg)
state_select_frontier
@ state_select_frontier
Definition: Yamauchi1999Node.h:64
Yamauchi1999Node::aOccPos
Vec2i aOccPos
Definition: Yamauchi1999Node.h:108
Yamauchi1999Node::aGoalFrontier
tf::Vector3 aGoalFrontier
Definition: Yamauchi1999Node.h:111
Yamauchi1999Node::aNamespace
std::string aNamespace
Definition: Yamauchi1999Node.h:113
state_exploration_finished
@ state_exploration_finished
Definition: Yamauchi1999Node.h:67
Vec2i
Definition: Common.h:59
state_back_to_base
@ state_back_to_base
Definition: Yamauchi1999Node.h:68
Yamauchi1999Node::aRate
int aRate
Definition: Yamauchi1999Node.h:100
Yamauchi1999Node::aFrontierCentroidsMsg
multirobotsimulations::Frontiers aFrontierCentroidsMsg
Definition: Yamauchi1999Node.h:135
Yamauchi1999Node::ChangeState
void ChangeState(const ExplorerState &newState)
Yamauchi1999Node::CreateMarker
void CreateMarker(visualization_msgs::Marker &input, const char *ns, const int &id, const int &seq)
Yamauchi1999Node::SetGoal
void SetGoal(const tf::Vector3 &goal)
Yamauchi1999Node::~Yamauchi1999Node
~Yamauchi1999Node()
Yamauchi1999Node::SelectFrontier
int SelectFrontier(multirobotsimulations::Frontiers &centroids, tf::Vector3 &selectFrontierWorld)
Yamauchi1999Node::aGoalPublisher
ros::Publisher aGoalPublisher
Definition: Yamauchi1999Node.h:129
Yamauchi1999Node::aCSpaceMsg
nav_msgs::OccupancyGrid aCSpaceMsg
Definition: Yamauchi1999Node.h:136
state_idle
@ state_idle
Definition: Yamauchi1999Node.h:66
ExplorerState
ExplorerState
Definition: Yamauchi1999Node.h:63
state_compute_centroids
@ state_compute_centroids
Definition: Yamauchi1999Node.h:70
state_back_to_base_finished
@ state_back_to_base_finished
Definition: Yamauchi1999Node.h:69
Yamauchi1999Node::CSpaceCallback
void CSpaceCallback(nav_msgs::OccupancyGrid::ConstPtr msg)
Yamauchi1999Node::aWorldPos
tf::Vector3 aWorldPos
Definition: Yamauchi1999Node.h:110
Yamauchi1999Node::SetExploringCallback
void SetExploringCallback(std_msgs::String::ConstPtr msg)
Yamauchi1999Node::aDeltaTime
double aDeltaTime
Definition: Yamauchi1999Node.h:107
Yamauchi1999Node::aCurrentState
ExplorerState aCurrentState
Definition: Yamauchi1999Node.h:114
state_planning
@ state_planning
Definition: Yamauchi1999Node.h:73
Yamauchi1999Node::aLastTime
ros::Time aLastTime
Definition: Yamauchi1999Node.h:109
state_waiting_centroids
@ state_waiting_centroids
Definition: Yamauchi1999Node.h:71
Yamauchi1999Node::aFirst
bool aFirst
Definition: Yamauchi1999Node.h:106
Yamauchi1999Node::aDirty
bool aDirty
Definition: Yamauchi1999Node.h:105
Yamauchi1999Node::EstimatePoseCallback
void EstimatePoseCallback(multirobotsimulations::CustomPose::ConstPtr msg)
ExplorerState
ExplorerState
Definition: Alysson2024Node.h:68
Yamauchi1999Node::aHasPose
bool aHasPose
Definition: Yamauchi1999Node.h:103
Yamauchi1999Node::SetBasestationCallback
void SetBasestationCallback(std_msgs::String::ConstPtr msg)
Yamauchi1999Node::ClustersCallback
void ClustersCallback(multirobotsimulations::Frontiers::ConstPtr msg)
Common.h
state_set_back_to_base
@ state_set_back_to_base
Definition: Yamauchi1999Node.h:72
Yamauchi1999Node::aFrontierComputePublisher
ros::Publisher aFrontierComputePublisher
Definition: Yamauchi1999Node.h:130
Yamauchi1999Node::aTimers
std::vector< ros::Timer > aTimers
Definition: Yamauchi1999Node.h:119
state_exploring
@ state_exploring
Definition: Yamauchi1999Node.h:65
Yamauchi1999Node::aHasOcc
bool aHasOcc
Definition: Yamauchi1999Node.h:104
Yamauchi1999Node::aGoalBasestation
tf::Vector3 aGoalBasestation
Definition: Yamauchi1999Node.h:112
Yamauchi1999Node::Yamauchi1999Node
Yamauchi1999Node()
Yamauchi1999Node::aId
int aId
Definition: Yamauchi1999Node.h:102
Yamauchi1999Node::aQueueSize
int aQueueSize
Definition: Yamauchi1999Node.h:99
Yamauchi1999Node::aRobots
int aRobots
Definition: Yamauchi1999Node.h:101
Yamauchi1999Node::SetIdleCallback
void SetIdleCallback(std_msgs::String::ConstPtr msg)
Yamauchi1999Node::Update
void Update()
Yamauchi1999Node::aSubscribers
std::vector< ros::Subscriber > aSubscribers
Definition: Yamauchi1999Node.h:124