ISAAC  0.2.11
Flight software for the ISAAC project, adding functionality to the Astrobee robot, operating inside the International Space Station.
All Classes Functions Variables Pages
volumetric_mapper.h
1 /* Copyright (c) 2021, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The "ISAAC - Integrated System for Autonomous and Adaptive Caretaking
7  * platform" software is licensed under the Apache License, Version 2.0
8  * (the "License"); you may not use this file except in compliance with the
9  * License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16  * License for the specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef VOLUMETRIC_MAPPER_VOLUMETRIC_MAPPER_H_
21 #define VOLUMETRIC_MAPPER_VOLUMETRIC_MAPPER_H_
22 
23 // Standard ROS includes
24 #include <ros/ros.h>
25 
26 // TF2 support
27 #include <tf2_ros/transform_listener.h>
28 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
29 
30 // Shared project includes
31 #include <volumetric_mapper/volumetric_mapper.h>
32 
33 // Messages
34 #include <visualization_msgs/MarkerArray.h>
35 
36 // Volumetric Mapper dependencies
37 #include <gp/gp.h>
38 #include <gp/gp_utils.h>
39 #include <gp/rprop.h>
40 
41 // C++ headers
42 #include <string>
43 #include <mutex>
44 
45 
46 namespace volumetric_mapper {
47 // Volumetric Mapper Class
48 
50  public:
51  // Constructor
52  VolumetricMapper(ros::NodeHandle* nh, std::string topic, double resolution,
53  double min_intensity, double max_intensity, double transparency,
54  double offset);
56 
57  // Add new point to the mapping iterpolation
58  void AddMapData(double value, geometry_msgs::TransformStamped tf);
59  // Publishes the map into a marker vector for visualization
60  void PubMapData(double x_min, double x_max, double y_min, double y_max,
61  double z_min, double z_max);
62 
63  private:
64  // initialize Gaussian process for 3-D input using the squared exponential
65  // covariance function with additive white noise
66  libgp::GaussianProcess * gp_;
67  // libgp::GaussianProcess gp_ = libgp::GaussianProcess(3, "CovSum ( CovSEiso, CovNoise)");
68  libgp::RProp rprop_;
69  ros::Publisher publisher_;
70  visualization_msgs::MarkerArray wifi_trace_;
71  std::mutex * mtx_;
72  // Parameters
73  double resolution_;
74  double min_intensity_;
75  double max_intensity_;
76  double transparency_;
77  double offset_;
78 };
79 
80 // Trace Mapper Class
82  public:
83  // Constructor
84  TraceMapper(ros::NodeHandle* nh, std::string topic, double resolution,
85  double min_intensity, double max_intensity, double transparency);
86 
87  ~TraceMapper();
88  void AddTraceData(double value, geometry_msgs::TransformStamped tf);
89  void PubTraceData();
90 
91  private:
92  //
93  ros::Publisher pub_map_trace_;
94  visualization_msgs::MarkerArray map_trace_;
95 
96  // Parameters
97  double resolution_;
98  double min_intensity_;
99  double max_intensity_;
100  double transparency_;
101 };
102 
103 // Round value to expected resolution
104 double roundPartial(double value, double resolution) {
105  return round(value / resolution) * resolution;
106 }
107 
108 // extracted from https://github.com/OctoMap/octomap_mapping
109 std_msgs::ColorRGBA intensityMapColor(const double &height,
110  const double &alpha) {
111  std_msgs::ColorRGBA color;
112  color.a = alpha;
113  // blend over HSV-values (more colors)
114  double s = 1.0;
115  double v = 1.0;
116 
117  double height_mod = height;
118  height_mod -= floor(height_mod);
119  height_mod *= 6;
120  int i;
121  double m, n, f;
122 
123  i = floor(height_mod);
124  f = height_mod - i;
125  if (!(i & 1))
126  f = 1 - f; // if i is even
127  m = v * (1 - s);
128  n = v * (1 - s * f);
129 
130  switch (i) {
131  case 6:
132  case 0:
133  color.r = v; color.g = n; color.b = m;
134  break;
135  case 1:
136  color.r = n; color.g = v; color.b = m;
137  break;
138  case 2:
139  color.r = m; color.g = v; color.b = n;
140  break;
141  case 3:
142  color.r = m; color.g = n; color.b = v;
143  break;
144  case 4:
145  color.r = n; color.g = m; color.b = v;
146  break;
147  case 5:
148  color.r = v; color.g = m; color.b = n;
149  break;
150  default:
151  color.r = 1; color.g = 0.5; color.b = 0.5;
152  break;
153  }
154  return color;
155 }
156 } // namespace volumetric_mapper
157 #endif // VOLUMETRIC_MAPPER_VOLUMETRIC_MAPPER_H_
158 
volumetric_mapper::TraceMapper
Definition: volumetric_mapper.h:81
volumetric_mapper::VolumetricMapper
Definition: volumetric_mapper.h:49