Multi-robot Playground
LaserToWorldNode.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 #include "tf/tf.h"
49 
50 /*
51  * Messages
52  */
53 #include "sensor_msgs/LaserScan.h"
54 #include "geometry_msgs/Pose.h"
55 #include "geometry_msgs/PoseArray.h"
56 #include "nav_msgs/OccupancyGrid.h"
57 #include "nav_msgs/MapMetaData.h"
58 #include "multirobotsimulations/CustomPose.h"
59 
60 /*
61  * Helpers
62  */
63 #include "Common.h"
64 
66  public:
69 
70  private:
71  void EstimatePoseWorldCallback(multirobotsimulations::CustomPose::ConstPtr msg);
72  void OccupancyGridCallback(nav_msgs::OccupancyGrid::ConstPtr msg);
73  void LaserCapture(sensor_msgs::LaserScan::ConstPtr msg);
74  void Update();
75 
76  /*
77  * Control variables
78  */
80  bool aHasLidar;
81  bool aHasPose;
83  double aRate;
84  double aRobotYaw;
85  double aLidarError;
86  tf::Vector3 aRobotWorldPosition;
87  tf::Vector3 aLidarPosition;
88  tf::Quaternion aLidarOrientation;
89  std::string aNamespace;
90 
91  /*
92  * Routines
93  */
94  std::vector<ros::Timer> aTimers;
95 
96  /*
97  * Subscribers
98  */
99  std::vector<ros::Subscriber> aSubscribers;
100 
101  /*
102  * Advertisers
103  */
104  ros::Publisher aLidarPublisher;
105  ros::Publisher aOccLidarPublisher;
106 
107  /*
108  * Messages
109  */
110  geometry_msgs::PoseArray aWorldLidarMsg;
111  geometry_msgs::PoseArray aOccLidarMsg;
112  nav_msgs::OccupancyGrid aOccInfo;
113 
114  /*
115  * Helpers
116  */
117  std::vector<geometry_msgs::Pose> aWorldReadings;
118  std::vector<geometry_msgs::Pose> aOccReadings;
119 };
LaserToWorldNode::aQueueSize
int aQueueSize
Definition: LaserToWorldNode.h:79
LaserToWorldNode::aRobotYaw
double aRobotYaw
Definition: LaserToWorldNode.h:84
LaserToWorldNode::aHasPose
bool aHasPose
Definition: LaserToWorldNode.h:81
LaserToWorldNode::aHasLidar
bool aHasLidar
Definition: LaserToWorldNode.h:80
LaserToWorldNode::Update
void Update()
LaserToWorldNode::aLidarError
double aLidarError
Definition: LaserToWorldNode.h:85
LaserToWorldNode::aOccReadings
std::vector< geometry_msgs::Pose > aOccReadings
Definition: LaserToWorldNode.h:118
LaserToWorldNode::~LaserToWorldNode
~LaserToWorldNode()
LaserToWorldNode::aRate
double aRate
Definition: LaserToWorldNode.h:83
LaserToWorldNode::aNamespace
std::string aNamespace
Definition: LaserToWorldNode.h:89
LaserToWorldNode::LaserToWorldNode
LaserToWorldNode()
LaserToWorldNode
Definition: LaserToWorldNode.h:65
LaserToWorldNode::aWorldReadings
std::vector< geometry_msgs::Pose > aWorldReadings
Definition: LaserToWorldNode.h:117
LaserToWorldNode::aWorldLidarMsg
geometry_msgs::PoseArray aWorldLidarMsg
Definition: LaserToWorldNode.h:110
LaserToWorldNode::aOccLidarPublisher
ros::Publisher aOccLidarPublisher
Definition: LaserToWorldNode.h:105
LaserToWorldNode::aTimers
std::vector< ros::Timer > aTimers
Definition: LaserToWorldNode.h:94
LaserToWorldNode::LaserCapture
void LaserCapture(sensor_msgs::LaserScan::ConstPtr msg)
LaserToWorldNode::aOccInfo
nav_msgs::OccupancyGrid aOccInfo
Definition: LaserToWorldNode.h:112
LaserToWorldNode::aLidarPosition
tf::Vector3 aLidarPosition
Definition: LaserToWorldNode.h:87
Common.h
LaserToWorldNode::aLidarPublisher
ros::Publisher aLidarPublisher
Definition: LaserToWorldNode.h:104
LaserToWorldNode::aHasOccInfo
bool aHasOccInfo
Definition: LaserToWorldNode.h:82
LaserToWorldNode::aSubscribers
std::vector< ros::Subscriber > aSubscribers
Definition: LaserToWorldNode.h:99
LaserToWorldNode::EstimatePoseWorldCallback
void EstimatePoseWorldCallback(multirobotsimulations::CustomPose::ConstPtr msg)
LaserToWorldNode::aLidarOrientation
tf::Quaternion aLidarOrientation
Definition: LaserToWorldNode.h:88
LaserToWorldNode::aOccLidarMsg
geometry_msgs::PoseArray aOccLidarMsg
Definition: LaserToWorldNode.h:111
LaserToWorldNode::OccupancyGridCallback
void OccupancyGridCallback(nav_msgs::OccupancyGrid::ConstPtr msg)
LaserToWorldNode::aRobotWorldPosition
tf::Vector3 aRobotWorldPosition
Definition: LaserToWorldNode.h:86