Multi-robot Playground
LocalPlannerNode.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, 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 "ros/ros.h"
47 #include "teb_local_planner/teb_local_planner_ros.h"
48 
49 /*
50  * Messages
51  */
52 #include "std_msgs/Int8MultiArray.h"
53 #include "std_msgs/Float32.h"
54 #include "multirobotsimulations/CustomPose.h"
55 #include "multirobotsimulations/MockPackage.h"
56 #include "std_msgs/Float64MultiArray.h"
57 #include "geometry_msgs/PoseArray.h"
58 
59 /*
60  *
61  */
62 #include "Common.h"
63 
65  public:
68 
69  private:
70  void CreateMarker(visualization_msgs::Marker& marker, const char* ns, const int& id, const int& seq);
71  void AssembleSparsePath(nav_msgs::Path& currentPath, nav_msgs::Path& filteredPath, const int& viaIncrement, visualization_msgs::Marker& globalPathMaker);
72  bool CheckNearPriority();
73  void ObstacleArrayCallback(costmap_converter::ObstacleArrayConstPtr msg);
74  void PoseCallback(multirobotsimulations::CustomPose::ConstPtr msg);
75  void SubgoalPathCallback(nav_msgs::Path::ConstPtr msg);
76  void RobotInCommCallback(std_msgs::Int8MultiArray::ConstPtr msg);
77  void Update();
78 
79  /*
80  * Control variables
81  */
83  int aSeq;
84  int aId;
85  int aRobots;
92  double aRate;
93  std::string aNamespace;
94  std::string aName;
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 aVelocityPublisher;
110  ros::Publisher aTebPosesPublisher;
111  ros::Publisher aViaPointsPublisher;
112 
113  /*
114  * Messages
115  */
116  geometry_msgs::Twist aTwistVelMsg;
117  geometry_msgs::PoseStamped aPrevPoseMsg;
118  geometry_msgs::PoseStamped aLastPoseMsg;
119  geometry_msgs::PoseArray aTebPosesMsg;
120  visualization_msgs::Marker aGlobalPathMsg;
121  std_msgs::Int8MultiArray aRobotsInCommMsg;
122  nav_msgs::Path aCurrentPathMsg;
123  nav_msgs::Path aFilteredPathMsg;
124  multirobotsimulations::CustomPose aPose;
125 
126  /*
127  * Helpers
128  */
129  teb_local_planner::TebConfig aTebConfig;
130  teb_local_planner::ViaPointContainer aViaPoints;
131  teb_local_planner::TebVisualizationPtr aVisual;
132  teb_local_planner::RobotFootprintModelPtr aRobotFootprint;
133  std::vector<teb_local_planner::ObstaclePtr> aObstacleArray;
134  std::shared_ptr<teb_local_planner::HomotopyClassPlanner> aPlanner;
135 };
LocalPlannerNode::PoseCallback
void PoseCallback(multirobotsimulations::CustomPose::ConstPtr msg)
LocalPlannerNode::RobotInCommCallback
void RobotInCommCallback(std_msgs::Int8MultiArray::ConstPtr msg)
LocalPlannerNode::aViaIncrement
int aViaIncrement
Definition: LocalPlannerNode.h:87
LocalPlannerNode::CreateMarker
void CreateMarker(visualization_msgs::Marker &marker, const char *ns, const int &id, const int &seq)
LocalPlannerNode::aTimers
std::vector< ros::Timer > aTimers
Definition: LocalPlannerNode.h:99
LocalPlannerNode::aFilteredPathMsg
nav_msgs::Path aFilteredPathMsg
Definition: LocalPlannerNode.h:123
LocalPlannerNode::aQueueSize
int aQueueSize
Definition: LocalPlannerNode.h:82
LocalPlannerNode::aPlanner
std::shared_ptr< teb_local_planner::HomotopyClassPlanner > aPlanner
Definition: LocalPlannerNode.h:134
LocalPlannerNode::aTebPosesPublisher
ros::Publisher aTebPosesPublisher
Definition: LocalPlannerNode.h:110
LocalPlannerNode::aVisual
teb_local_planner::TebVisualizationPtr aVisual
Definition: LocalPlannerNode.h:131
LocalPlannerNode::aRate
double aRate
Definition: LocalPlannerNode.h:92
LocalPlannerNode::CheckNearPriority
bool CheckNearPriority()
LocalPlannerNode::aReceivedComm
bool aReceivedComm
Definition: LocalPlannerNode.h:91
LocalPlannerNode::aPose
multirobotsimulations::CustomPose aPose
Definition: LocalPlannerNode.h:124
LocalPlannerNode
Definition: LocalPlannerNode.h:64
LocalPlannerNode::aUsePriorityBehavior
bool aUsePriorityBehavior
Definition: LocalPlannerNode.h:90
LocalPlannerNode::aLastPoseMsg
geometry_msgs::PoseStamped aLastPoseMsg
Definition: LocalPlannerNode.h:118
LocalPlannerNode::ObstacleArrayCallback
void ObstacleArrayCallback(costmap_converter::ObstacleArrayConstPtr msg)
LocalPlannerNode::aSeq
int aSeq
Definition: LocalPlannerNode.h:83
LocalPlannerNode::aGlobalPathMsg
visualization_msgs::Marker aGlobalPathMsg
Definition: LocalPlannerNode.h:120
LocalPlannerNode::aRobots
int aRobots
Definition: LocalPlannerNode.h:85
LocalPlannerNode::aId
int aId
Definition: LocalPlannerNode.h:84
LocalPlannerNode::aObstacleArray
std::vector< teb_local_planner::ObstaclePtr > aObstacleArray
Definition: LocalPlannerNode.h:133
LocalPlannerNode::aCurrentPathMsg
nav_msgs::Path aCurrentPathMsg
Definition: LocalPlannerNode.h:122
LocalPlannerNode::aIncrement
int aIncrement
Definition: LocalPlannerNode.h:88
LocalPlannerNode::Update
void Update()
LocalPlannerNode::aTwistVelMsg
geometry_msgs::Twist aTwistVelMsg
Definition: LocalPlannerNode.h:116
LocalPlannerNode::aSubscribers
std::vector< ros::Subscriber > aSubscribers
Definition: LocalPlannerNode.h:104
LocalPlannerNode::SubgoalPathCallback
void SubgoalPathCallback(nav_msgs::Path::ConstPtr msg)
LocalPlannerNode::aRobotsInCommMsg
std_msgs::Int8MultiArray aRobotsInCommMsg
Definition: LocalPlannerNode.h:121
Common.h
LocalPlannerNode::aControlsToShare
int aControlsToShare
Definition: LocalPlannerNode.h:89
LocalPlannerNode::aName
std::string aName
Definition: LocalPlannerNode.h:94
LocalPlannerNode::aViaPointsPublisher
ros::Publisher aViaPointsPublisher
Definition: LocalPlannerNode.h:111
LocalPlannerNode::~LocalPlannerNode
~LocalPlannerNode()
LocalPlannerNode::aTebConfig
teb_local_planner::TebConfig aTebConfig
Definition: LocalPlannerNode.h:129
LocalPlannerNode::aVelocityPublisher
ros::Publisher aVelocityPublisher
Definition: LocalPlannerNode.h:109
LocalPlannerNode::aViaPoints
teb_local_planner::ViaPointContainer aViaPoints
Definition: LocalPlannerNode.h:130
LocalPlannerNode::AssembleSparsePath
void AssembleSparsePath(nav_msgs::Path &currentPath, nav_msgs::Path &filteredPath, const int &viaIncrement, visualization_msgs::Marker &globalPathMaker)
LocalPlannerNode::LocalPlannerNode
LocalPlannerNode()
LocalPlannerNode::aPrevPoseMsg
geometry_msgs::PoseStamped aPrevPoseMsg
Definition: LocalPlannerNode.h:117
LocalPlannerNode::aRobotFootprint
teb_local_planner::RobotFootprintModelPtr aRobotFootprint
Definition: LocalPlannerNode.h:132
LocalPlannerNode::aTebPosesMsg
geometry_msgs::PoseArray aTebPosesMsg
Definition: LocalPlannerNode.h:119
LocalPlannerNode::aNamespace
std::string aNamespace
Definition: LocalPlannerNode.h:93
LocalPlannerNode::aMaxWaypoints
int aMaxWaypoints
Definition: LocalPlannerNode.h:86