12 #include <gtest/gtest.h> 36 map[
"layer"].setConstant(1.0);
37 map.at(
"layer",
Index(0,0)) = -1.0;
42 map.getPosition(
Index(9, 9), pos);
77 map[
"layer"].setConstant(1.0);
79 map.at(
"layer",
Index(3,4)) = 2.0;
80 map.at(
"layer",
Index(3,5)) = 2.0;
81 map.at(
"layer",
Index(3,6)) = 2.0;
82 map.at(
"layer",
Index(4,4)) = 2.0;
83 map.at(
"layer",
Index(4,5)) = 2.0;
84 map.at(
"layer",
Index(4,6)) = 2.0;
85 map.at(
"layer",
Index(5,4)) = 2.0;
86 map.at(
"layer",
Index(5,5)) = 2.0;
87 map.at(
"layer",
Index(5,6)) = 2.0;
88 map.at(
"layer",
Index(6,4)) = 2.0;
89 map.at(
"layer",
Index(6,5)) = 2.0;
90 map.at(
"layer",
Index(6,6)) = 2.0;
91 map.at(
"layer",
Index(7,4)) = 2.0;
92 map.at(
"layer",
Index(7,5)) = 2.0;
93 map.at(
"layer",
Index(7,6)) = 2.0;
99 map.getPosition(
Index(5, 5), pos);
120 map.getPosition(
Index(5, 2), pos);
146 map[
"layer"].setConstant(1.0);
148 map.at(
"layer",
Index(3,4)) = 2.0;
149 map.at(
"layer",
Index(3,5)) = 2.0;
150 map.at(
"layer",
Index(3,6)) = 2.0;
151 map.at(
"layer",
Index(4,4)) = 2.0;
152 map.at(
"layer",
Index(4,5)) = 2.0;
153 map.at(
"layer",
Index(4,6)) = 2.0;
154 map.at(
"layer",
Index(5,4)) = 2.0;
155 map.at(
"layer",
Index(5,5)) = 2.0;
156 map.at(
"layer",
Index(5,6)) = 2.0;
157 map.at(
"layer",
Index(6,4)) = 2.0;
158 map.at(
"layer",
Index(6,5)) = 2.0;
159 map.at(
"layer",
Index(6,6)) = 2.0;
160 map.at(
"layer",
Index(7,4)) = 2.0;
161 map.at(
"layer",
Index(7,5)) = 2.0;
162 map.at(
"layer",
Index(7,6)) = 2.0;
169 map.getPosition(
Index(5, 6), pos);
171 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
172 EXPECT_NEAR(gradient.y(), -1, 0.0001);
173 EXPECT_NEAR(gradient.z(), 0.5, 0.0001);
175 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
176 EXPECT_NEAR(gradient.y(), -1, 0.0001);
177 EXPECT_NEAR(gradient.z(), 0.5, 0.0001);
179 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
180 EXPECT_NEAR(gradient.y(), -1.5, 0.0001);
181 EXPECT_NEAR(gradient.z(), 1, 0.0001);
183 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
184 EXPECT_NEAR(gradient.y(), -1.5, 0.0001);
185 EXPECT_NEAR(gradient.z(), 1.0, 0.0001);
187 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
188 EXPECT_NEAR(gradient.y(), -1.5, 0.0001);
189 EXPECT_NEAR(gradient.z(), 1.0, 0.0001);
190 map.getPosition(
Index(2, 2), pos);
192 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
193 EXPECT_NEAR(gradient.y(), 1, 0.0001);
194 EXPECT_NEAR(gradient.z(), 0.5, 0.0001);
196 EXPECT_NEAR(gradient.x(), 0.207107, 0.0001);
197 EXPECT_NEAR(gradient.y(), 1.5, 0.0001);
198 EXPECT_NEAR(gradient.z(), 1, 0.0001);
200 EXPECT_NEAR(gradient.x(), 0.207107, 0.0001);
201 EXPECT_NEAR(gradient.y(), 1.5, 0.0001);
202 EXPECT_NEAR(gradient.z(), 1, 0.0001);
203 map.getPosition(
Index(12, 22), pos);
205 EXPECT_NEAR(gradient.x(), 0.0, 0.0001);
206 EXPECT_NEAR(gradient.y(), 1.0, 0.0001);
207 EXPECT_NEAR(gradient.z(), 0.5, 0.0001);
214 map[
"layer"].setConstant(1.0);
216 map.at(
"layer",
Index(3,3)) = 2.0;
217 map.at(
"layer",
Index(3,4)) = 2.0;
218 map.at(
"layer",
Index(3,5)) = 2.0;
219 map.at(
"layer",
Index(3,6)) = 2.0;
220 map.at(
"layer",
Index(3,7)) = 2.0;
221 map.at(
"layer",
Index(4,3)) = 2.0;
222 map.at(
"layer",
Index(4,4)) = 2.0;
223 map.at(
"layer",
Index(4,5)) = 2.0;
224 map.at(
"layer",
Index(4,6)) = 2.0;
225 map.at(
"layer",
Index(4,7)) = 2.0;
226 map.at(
"layer",
Index(5,3)) = 2.0;
227 map.at(
"layer",
Index(5,4)) = 2.0;
228 map.at(
"layer",
Index(5,5)) = 2.0;
229 map.at(
"layer",
Index(5,6)) = 2.0;
230 map.at(
"layer",
Index(5,7)) = 2.0;
231 map.at(
"layer",
Index(6,3)) = 2.0;
232 map.at(
"layer",
Index(6,4)) = 2.0;
233 map.at(
"layer",
Index(6,5)) = 2.0;
234 map.at(
"layer",
Index(6,6)) = 2.0;
235 map.at(
"layer",
Index(6,7)) = 2.0;
236 map.at(
"layer",
Index(7,3)) = 2.0;
237 map.at(
"layer",
Index(7,4)) = 2.0;
238 map.at(
"layer",
Index(7,5)) = 2.0;
239 map.at(
"layer",
Index(7,6)) = 2.0;
240 map.at(
"layer",
Index(7,7)) = 2.0;
246 map.getPosition(
Index(5, 5), pos);
267 map.getPosition(
Index(5, 10), pos);
285 map.getPosition(
Index(5, 0), pos);
287 map.getPosition(
Index(5, 1), pos);
289 map.getPosition(
Index(5, 2), pos);
291 map.getPosition(
Index(5, 3), pos);
293 map.getPosition(
Index(5, 4), pos);
295 map.getPosition(
Index(5, 5), pos);
297 map.getPosition(
Index(5, 6), pos);
299 map.getPosition(
Index(5, 7), pos);
301 map.getPosition(
Index(5, 8), pos);
303 map.getPosition(
Index(5, 9), pos);
void setGeometry(const Length &length, const double resolution, const Position &position=Position::Zero())
TEST(SignedDistanceField, EmptyMap)
Eigen::Vector3d Position3
double getInterpolatedDistanceAt(const Position3 &position) const
void calculateSignedDistanceField(const GridMap &gridMap, const std::string &layer, const double heightClearance)
Vector3 getDistanceGradientAt(const Position3 &position) const
double getDistanceAt(const Position3 &position) const