| 204 | } |
| 205 | |
| 206 | Error computeInterpolationError(const AnalyticalFunctions &groundTruth, |
| 207 | const grid_map::GridMap &map) |
| 208 | { |
| 209 | const double r = map.getResolution(); |
| 210 | const double dimX = map.getLength().x() / 2.0 - 3.0 * r; |
| 211 | const double dimY = map.getLength().y() / 2.0 - 3.0 * r; |
| 212 | |
| 213 | unsigned int count = 0; |
| 214 | Error error; |
| 215 | const int nRow = map.getSize().x(); |
| 216 | const int nCol = map.getSize().y(); |
| 217 | for (grid_map::GridMapIterator iterator(map); !iterator.isPastEnd(); ++iterator) { |
| 218 | const auto row = (*iterator).x(); |
| 219 | const auto col = (*iterator).y(); |
| 220 | const bool skipEvaluation = row < 2 || col < 2 || col > (nCol - 3) || row > (nRow - 3); |
| 221 | if (skipEvaluation) { |
| 222 | continue; |
| 223 | } |
| 224 | grid_map::Position pos; |
| 225 | map.getPosition(*iterator, pos); |
| 226 | const double f = map.at(demoLayer, *iterator); |
| 227 | const double f_ = groundTruth.f_(pos.x(), pos.y()); |
| 228 | const double e = std::fabs(f - f_); |
| 229 | error.meanSquare_ += e * e; |
| 230 | error.meanAbs_ += e; |
| 231 | ++count; |
| 232 | if (e > error.max_) { |
| 233 | error.max_ = e; |
| 234 | } |
| 235 | } |
| 236 | error.meanSquare_ /= count; |
| 237 | error.meanAbs_ /= count; |
| 238 | return error; |
| 239 | |
| 240 | } |
| 241 | |
| 242 | InterpolationDemo::InterpolationDemo(ros::NodeHandle *nh) |
| 243 | { |
no test coverage detected