Costmap.cpp
Go to the documentation of this file.
1 #include "Costmap.h"
2 
3 #include <math.h>
4 
5 #include <algorithm>
6 #include <cmath>
7 #include <cstddef>
8 #include <limits>
9 #include <optional>
10 #include <unordered_set>
11 #include <utility>
12 #include <vector>
13 
14 #include <Eigen/Core>
15 #include <Eigen/Geometry>
16 
20 
23 
24 #include <range/v3/view/zip.hpp>
25 
27 {
28 
29 
30  Costmap::Costmap(const Grid& grid,
31  const Parameters& parameters,
32  const SceneBounds& sceneBounds,
33  const std::optional<Mask>& mask,
34  const core::Pose2D& origin) :
35  grid(grid),
36  mask(mask),
37  sceneBounds(sceneBounds),
38  parameters(parameters),
39  global_T_costmap(origin)
40  {
41  validateSizes();
42  }
43 
44  void
45  Costmap::validateSizes() const
46  {
47  if (mask.has_value())
48  {
49  ARMARX_CHECK_EQUAL(grid.rows(), mask->rows());
50  ARMARX_CHECK_EQUAL(grid.cols(), mask->cols());
51  }
52  }
53 
56  {
58 
59  Eigen::Vector2f posLocal;
60  posLocal.x() =
61  sceneBounds.min.x() + index.x() * parameters.cellSize + parameters.cellSize / 2;
62  posLocal.y() =
63  sceneBounds.min.y() + index.y() * parameters.cellSize + parameters.cellSize / 2;
64 
65  return posLocal;
66  }
67 
70  {
71  const Costmap::Position costmap_P_pos = toPositionLocal(index);
72  return global_T_costmap * costmap_P_pos;
73  }
74 
75  bool
76  Costmap::isValid(const Costmap::Index& index) const noexcept
77  {
78  if (index.x() < 0 || index.y() < 0)
79  {
80  ARMARX_VERBOSE << "Index out of bounds (< 0)";
81  return false;
82  }
83 
84  if (index.x() >= grid.rows() || index.y() >= grid.cols())
85  {
86  ARMARX_VERBOSE << "Index out of bounds (>= grid size)";
87  return false;
88  }
89 
90  if (mask.has_value())
91  {
92  if (not mask.value()(index.x(), index.y()))
93  {
94  ARMARX_VERBOSE << "Index out of bounds (mask)";
95  }
96  return mask.value()(index.x(), index.y());
97  }
98 
99  return true;
100  }
101 
103  Costmap::toVertex(const Eigen::Vector2f& globalPosition) const
104  {
105  const auto localPosition = global_T_costmap.inverse() * globalPosition;
106 
107  const float vX = (localPosition.x() - parameters.cellSize / 2 - sceneBounds.min.x()) /
108  parameters.cellSize;
109  const float vY = (localPosition.y() - parameters.cellSize / 2 - sceneBounds.min.y()) /
110  parameters.cellSize;
111 
112  const int iX = std::round(vX - 0.01);
113  const int iY = std::round(vY - 0.01);
114 
115  const int iXSan = std::clamp<int>(iX, 0, grid.rows() - 1);
116  const int iYSan = std::clamp<int>(iY, 0, grid.cols() - 1);
117 
118  // FIXME accept one cell off
119 
120  // ARMARX_CHECK_GREATER(iX, 0);
121  // ARMARX_CHECK_GREATER(iY, 0);
122 
123  // ARMARX_CHECK_LESS_EQUAL(iX, grid.rows() - 1);
124  // ARMARX_CHECK_LESS_EQUAL(iY, grid.cols() - 1);
125 
126  return Vertex{.index = Index{iXSan, iYSan}, .position = globalPosition};
127  }
128 
129  const SceneBounds&
131  {
132  return sceneBounds;
133  }
134 
137  {
138  ARMARX_TRACE;
139 
140  if (mask.has_value())
141  {
142  ARMARX_CHECK_GREATER(mask->array().sum(), 0)
143  << "At least one element has to be valid. Here, all elements are masked out!";
144  }
145 
146  // index of the min element
147  Grid::Index row = 0;
148  Grid::Index col = 0;
149 
150  // value of the min element
151  float minVal = std::numeric_limits<float>::max();
152 
153  for (int r = 0; r < grid.rows(); r++)
154  {
155  for (int c = 0; c < grid.cols(); c++)
156  {
157  if (mask.has_value())
158  {
159  if (not mask.value()(r, c)) // skip invalid cells
160  {
161  continue;
162  }
163 
164  const float currentVal = grid(r, c);
165  if (currentVal < minVal)
166  {
167  minVal = currentVal;
168  row = r;
169  col = c;
170  }
171  }
172  }
173  }
174 
175  return {.value = minVal, .index = {row, col}, .position = toPositionGlobal({row, col})};
176  }
177 
178  void
179  Costmap::filter(const Filter& filter)
180  {
181  ARMARX_TRACE;
182 
183  ARMARX_CHECK(filter.matrix.rows() % 2 == 1 and filter.matrix.cols() % 2 == 1);
184 
185  if (mask.has_value())
186  {
187  ARMARX_CHECK_GREATER(mask->array().sum(), 0)
188  << "At least one element has to be valid. Here, all elements are masked out!";
189  }
190 
191  Grid newGrid(grid.rows(), grid.cols());
192  const double max = grid.maxCoeff();
193  newGrid.setConstant(max);
194  for (int r = 0; r < grid.rows(); r++)
195  {
196  for (int c = 0; c < grid.cols(); c++)
197  {
198  if (mask.has_value())
199  {
200  if (not mask.value()(r, c)) // skip invalid cells
201  {
202  continue;
203  }
204 
205  Eigen::MatrixXf valueMatrix(filter.matrix.rows(), filter.matrix.cols());
206  const int radius_r = (filter.matrix.rows() - 1) / 2;
207  const int radius_c = (filter.matrix.cols() - 1) / 2;
208  valueMatrix.setConstant(max);
209  for (int i = -radius_r; i <= radius_r; i++)
210  {
211  for (int j = -radius_c; j <= radius_c; j++)
212  {
213  const int ri = r + i;
214  const int cj = c + j;
215  if (ri > 0 and ri < grid.rows() and cj > 0 and cj < grid.cols() and
216  mask.value()(ri, cj))
217  {
218  valueMatrix(radius_r + i, radius_c + j) = grid(ri, cj);
219  }
220  }
221  }
222  const double sum = filter.matrix.sum();
223  if (sum > 0)
224  {
225  const float filteredValue =
226  (valueMatrix.cwiseProduct(filter.matrix)).sum() / sum;
227  newGrid(r, c) =
228  filter.useMinimum ? std::min(grid(r, c), filteredValue) : filteredValue;
229  }
230  }
231  }
232  }
233  grid = newGrid;
234  }
235 
236  const Costmap::Parameters&
237  Costmap::params() const noexcept
238  {
239  return parameters;
240  }
241 
242  const Costmap::Grid&
244  {
245  return grid;
246  }
247 
248  bool
250  {
251  const auto v = toVertex(p);
252  return grid(v.index.x(), v.index.y()) == 0.F;
253  }
254 
255  bool
256  Costmap::add(const Costmap& other, const float weight)
257  {
258  // ensure that both grid and mask are the same size
259  ARMARX_TRACE;
260 
261  validateSizes();
262  other.validateSizes();
263 
264  const auto startIdx = toVertex(other.sceneBounds.min);
265 
266  // merge other grid into this one => use max costs
267 
268  // It might happen that this costmap is not large enough to cover the other costmap
269  // In this case, only add the part to this costmap that is possible.
270  const int rows = std::min(other.grid.rows(), grid.rows() - startIdx.index.x());
271  const int cols = std::min(other.grid.cols(), grid.cols() - startIdx.index.y());
272 
273  ARMARX_VERBOSE << "Adding other grid to region (" << startIdx.index.x() << ", "
274  << startIdx.index.y() << "), "
275  << " (" << startIdx.index.x() + rows << ", " << startIdx.index.y() + cols
276  << ")";
277 
278  ARMARX_TRACE;
279 
280  // add the costs of the other mask to this one by a weighting factor
281  grid.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array() +=
282  weight * other.grid.block(0, 0, rows, cols).array();
283 
284  if (not mask.has_value())
285  {
286  mask = Mask(grid.rows(), grid.cols());
287  mask->setOnes();
288  }
289 
290  ARMARX_VERBOSE << "Fraction of valid cells before merge: "
291  << mask->array().cast<float>().sum() / mask->size();
292 
293  Mask otherMask(grid.rows(), grid.cols());
294  otherMask.setZero();
295  otherMask.block(startIdx.index.x(), startIdx.index.y(), rows, cols).setOnes();
296 
297  if (other.mask.has_value())
298  {
299  ARMARX_TRACE;
300 
301  // union of masks
302  ARMARX_DEBUG << "Union of masks";
303  otherMask.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array() *=
304  other.mask->block(0, 0, rows, cols).array();
305  }
306 
307  ARMARX_TRACE;
308  mask->array() *= otherMask.array();
309 
310  ARMARX_VERBOSE << "Fraction of valid cells: "
311  << mask->array().cast<float>().sum() / mask->size();
312 
313  // apply mask to grid => all invalid points will be 0
314  ARMARX_TRACE;
315  grid.array() *= mask->cast<float>().array();
316 
317  return true;
318  }
319 
320  bool
321  Costmap::add(const Costmap& other, const AddMode mode)
322  {
323  // ensure that both grid and mask are the same size
324  ARMARX_TRACE;
325  validateSizes();
326  other.validateSizes();
327 
328  const auto startIdx = toVertex(other.sceneBounds.min);
329 
330  // merge other grid into this one => use max costs
331 
332  // It might happen that this costmap is not large enough to cover the other costmap
333  // In this case, only add the part to this costmap that is possible.
334  const int rows = std::min(other.grid.rows(), grid.rows() - startIdx.index.x());
335  const int cols = std::min(other.grid.cols(), grid.cols() - startIdx.index.y());
336 
337  ARMARX_VERBOSE << "Adding other grid to region (" << startIdx.index.x() << ", "
338  << startIdx.index.y() << "), "
339  << " (" << startIdx.index.x() + rows << ", " << startIdx.index.y() + cols
340  << ")";
341 
342  ARMARX_TRACE;
343 
344  // add the costs of the other grid to this one by either min or max operator
345  switch (mode)
346  {
347  case AddMode::MIN:
348  grid.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array() =
349  other.grid.block(0, 0, rows, cols)
350  .array()
351  .cwiseMin(
352  grid.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array());
353  break;
354 
355  case AddMode::MAX:
356  grid.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array() =
357  other.grid.block(0, 0, rows, cols)
358  .array()
359  .cwiseMax(
360  grid.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array());
361  break;
362  }
363 
364 
365  if (not mask.has_value())
366  {
367  mask = Mask(grid.rows(), grid.cols());
368  mask->setOnes();
369  }
370 
371  Mask otherMask(grid.rows(), grid.cols());
372  otherMask.setZero();
373  otherMask.block(startIdx.index.x(), startIdx.index.y(), rows, cols).setOnes();
374 
375  if (other.mask.has_value())
376  {
377  ARMARX_TRACE;
378 
379  // union of masks
380  ARMARX_DEBUG << "Union of masks";
381  otherMask.block(startIdx.index.x(), startIdx.index.y(), rows, cols).array() *=
382  other.mask->block(0, 0, rows, cols).array();
383  }
384 
385  ARMARX_TRACE;
386  mask->array() *= otherMask.array();
387 
388  ARMARX_VERBOSE << "Fraction of valid cells: "
389  << mask->array().cast<float>().sum() / mask->size();
390 
391  // apply mask to grid => all invalid points will be 0
392  ARMARX_TRACE;
393  grid.array() *= mask->cast<float>().array();
394 
395  return true;
396  }
397 
398  const std::optional<Costmap::Mask>&
399  Costmap::getMask() const noexcept
400  {
401  return mask;
402  }
403 
404  std::optional<Costmap::Mask>&
406  {
407  return mask;
408  }
409 
410  std::optional<float>
412  {
413  if (not isValid(index))
414  {
415  ARMARX_IMPORTANT << "Requested index " << index << " but it is masked out!";
416  return std::nullopt;
417  }
418 
419  return grid(index.x(), index.y());
420  }
421 
422  std::optional<float>
423  Costmap::value(const Position& position) const
424  {
425  ARMARX_DEBUG << "value ...";
426 
427  const auto v = toVertex(position);
428  return value(v.index);
429  }
430 
431  void
433  {
434  ARMARX_TRACE;
435 
436  const auto [min, max] = getValidBoundingBox();
437 
438  // calculate new scene bounds based on bounding box
439  const auto newSceneBounds = SceneBounds{
440  .min = sceneBounds.min + parameters.cellSize * Eigen::Vector2f{min.cast<float>()},
441  .max = sceneBounds.min + parameters.cellSize * Eigen::Vector2f{max.cast<float>()}};
442 
443  ARMARX_VERBOSE << "Cutting grid to valid bounding box: " << min << " and " << max;
444 
445  const auto newGrid =
446  grid.block(min.x(), min.y(), max.x() - min.x() + 1, max.y() - min.y() + 1);
447  grid = newGrid;
448 
449  if (mask.has_value())
450  {
451  ARMARX_VERBOSE << "Cutting mask to valid bounding box: " << min << " and " << max;
452 
453  const auto newMask =
454  mask->block(min.x(), min.y(), max.x() - min.x() + 1, max.y() - min.y() + 1);
455  mask = newMask;
456  }
457 
458  // update scene bounds
459  sceneBounds.min = newSceneBounds.min;
460  sceneBounds.max = newSceneBounds.max;
461 
462  ARMARX_VERBOSE << "New scene bounds: " << sceneBounds.min << " and " << sceneBounds.max;
463  }
464 
465  /**
466  * @brief Merge a list of costmaps into this costmap
467  *
468  * @param costmaps list of other costmaps
469  * @param weights [weights of other costmaps..., weights of this costmap]
470  * @return this
471  */
472  Costmap
473  Costmap::mergeInto(const std::vector<Costmap>& costmaps,
474  const std::vector<float>& weights) const
475  {
476  ARMARX_CHECK_EQUAL(costmaps.size() + 1, weights.size());
477 
478  const std::vector<float> costmapWeights(weights.begin(), weights.end() - 1);
479  ARMARX_CHECK_EQUAL(costmapWeights.size(), costmaps.size());
480 
481  ARMARX_VERBOSE << "Merging into with weights " << weights;
482 
483  Costmap mergedCostmap = *this;
484 
485  ARMARX_CHECK(mergedCostmap.mask.has_value());
486 
487  for (int x = 0; x < mergedCostmap.getGrid().rows(); x++)
488  {
489  for (int y = 0; y < mergedCostmap.getGrid().cols(); y++)
490  {
491  ARMARX_TRACE;
492  const Costmap::Position position = mergedCostmap.toPositionGlobal(Index{x, y});
493 
494  // merge masks
495  for (const auto& costmap : costmaps)
496  {
497  ARMARX_TRACE;
498  mergedCostmap.mask.value()(x, y) &=
499  costmap.isValid(costmap.toVertex(position).index);
500  }
501 
502  if (mergedCostmap.isValid(Index{x, y}))
503  {
504  float newVal = 0;
505  for (const auto& [weight, costmap] :
506  ranges::views::zip(costmapWeights, costmaps))
507  {
508  const auto otherCostmapVal = costmap.value(position);
509  ARMARX_CHECK(otherCostmapVal.has_value());
510 
511  newVal += weight * otherCostmapVal.value();
512  }
513 
514  newVal += weights.back() * mergedCostmap.grid(x, y);
515  mergedCostmap.grid(x, y) = newVal;
516  }
517  else
518  {
519  mergedCostmap.grid(x, y) = 0;
520  }
521  }
522  }
523 
524  return mergedCostmap;
525  }
526 
528  Costmap::Filter::gaussian(int radius, float sigma)
529  {
530  ARMARX_CHECK(radius > 0 and sigma > 0.);
531  Filter gaussianFilter{.matrix = Eigen::MatrixXf::Zero(radius * 2 + 1, radius * 2 + 1)};
532  for (int i = -radius; i <= radius; i++)
533  {
534  for (int j = -radius; j <= radius; j++)
535  {
536  gaussianFilter.matrix(radius + i, radius + j) =
537  std::exp(-0.5 * (std::pow(i / sigma, 2.0) + std::pow(j / sigma, 2.0))) /
538  (2 * M_PI * sigma * sigma);
539  }
540  }
541  return gaussianFilter;
542  }
543 
544  std::size_t
546  {
547  if (not mask.has_value())
548  {
549  return grid.cols() * grid.rows();
550  }
551 
552  return mask->array().cast<int>().sum();
553  }
554 
556  Costmap::findClosestValidIndex(const Costmap::Index& index)
557  {
558  ARMARX_TRACE;
559 
560  if (isValid(index))
561  {
562  return index;
563  }
564 
565  const auto x = index.x();
566  const auto y = index.y();
567 
568  // Check all cells in a radius around the given index
569  for (int r = 1; r < 10; r++)
570  {
571  for (int i = -r; i <= r; i++)
572  {
573  for (int j = -r; j <= r; j++)
574  {
575  const auto idx = Costmap::Index{x + i, y + j};
576  if (isValid(idx))
577  {
578  return idx;
579  }
580  }
581  }
582  }
583 
584  ARMARX_ERROR << "No valid index found in the vicinity of " << index;
585  return index;
586  }
587 
588  std::pair<Costmap::Index, Costmap::Index>
590  {
591  if (not mask.has_value())
592  {
593  return {Index{0, 0}, Index{grid.rows() - 1, grid.cols() - 1}};
594  }
595 
596  ARMARX_VERBOSE << "Fraction of valid elements: "
597  << mask->cast<float>().sum() / mask->size();
598 
599  ARMARX_TRACE;
600 
601  Index min = Index{grid.rows(), grid.cols()};
602  Index max = Index{0, 0};
603 
604  for (int x = 0; x < grid.rows(); x++)
605  {
606  for (int y = 0; y < grid.cols(); y++)
607  {
608  if (mask.value()(x, y))
609  {
610  min.x() = std::min(min.x(), x);
611  min.y() = std::min(min.y(), y);
612  max.x() = std::max(max.x(), x);
613  max.y() = std::max(max.y(), y);
614  }
615  }
616  }
617 
618  return {min, max};
619  }
620 
621  void
623  {
624  ARMARX_TRACE;
625 
626  // Exclude all cells that are not reachable from the given position
627  // That is, they are not reachable over cells with a value > 0
628  // This is done by a simple flood fill algorithm
629 
630  const auto v = toVertex(position);
631  auto startIdx = v.index;
632 
633  // Find a valid start index
634  const auto [aabbMin, aabbMax] = getValidBoundingBox();
635  startIdx.x() = std::max(startIdx.x(), aabbMin.x());
636  startIdx.y() = std::max(startIdx.y(), aabbMin.y());
637  startIdx.x() = std::min(startIdx.x(), aabbMax.x());
638  startIdx.y() = std::min(startIdx.y(), aabbMax.y());
639 
640  startIdx = findClosestValidIndex(startIdx);
641 
642  // TODO: Good start index if the position is not valid
643 
644  // Check validity before resetting mask
645  ARMARX_INFO << "Start index: " << startIdx;
646  ARMARX_CHECK(isValid(startIdx));
647 
648  // Reset mask
649  grid.array() *= mask->cast<float>().array();
650  auto newMask = mask.value();
651  newMask.setZero();
652 
653  struct pair_hash
654  {
655  inline std::size_t
656  operator()(const std::pair<int, int>& v) const
657  {
658  return v.first * 31 + v.second;
659  }
660  };
661 
662  std::unordered_set<std::pair<int, int>, pair_hash> stack;
663  auto visited = newMask;
664  stack.emplace(startIdx.x(), startIdx.y());
665  int i = 0;
666  while (not stack.empty())
667  {
668  if (i++ > 1000)
669  {
670  ARMARX_INFO << "After 1000 iterations, current element is " << stack.begin()->first
671  << ", " << stack.begin()->second;
672  i = 0;
673  }
674  const auto it = stack.begin();
675  const auto idx = Index{it->first, it->second};
676  stack.erase(it);
677 
678  // print all elements
679  /*for (const auto& element : stack)
680  {
681  ARMARX_INFO << "Stack element: " << element.first << ", " << element.second;
682  }*/
683 
684  visited(idx.x(), idx.y()) = 1;
685 
686  //ARMARX_INFO << "Checking " << idx;
687 
688  if (not isValid(idx))
689  {
690  continue;
691  }
692 
693  if (grid(idx.x(), idx.y()) == 0.F)
694  {
695  continue;
696  }
697 
698  //ARMARX_INFO << "Including " << idx;
699 
700  newMask.array()(idx.x(), idx.y()) = 1;
701 
702  if (const std::pair<int, int> element = {idx.x() + 1, idx.y()};
703  element.first < visited.rows() && not visited(element.first, element.second))
704  {
705  stack.emplace(element);
706  }
707  if (const std::pair<int, int> element = {idx.x() - 1, idx.y()};
708  element.first > 0 && not visited(element.first, element.second))
709  {
710  stack.emplace(element);
711  }
712  if (const std::pair<int, int> element = {idx.x(), idx.y() + 1};
713  element.second < visited.cols() && not visited(element.first, element.second))
714  {
715  stack.emplace(element);
716  }
717  if (const std::pair<int, int> element = {idx.x(), idx.y() - 1};
718  element.second > 0 && not visited(element.first, element.second))
719  {
720  stack.emplace(element);
721  }
722  }
723 
724  mask.emplace(newMask);
725  }
726 
727 
728 } // namespace armarx::navigation::algorithms
armarx::navigation::algorithms::Costmap::getMask
const std::optional< Mask > & getMask() const noexcept
Definition: Costmap.cpp:399
armarx::navigation::algorithms::Costmap::cutToValidBoundingBox
void cutToValidBoundingBox()
Definition: Costmap.cpp:432
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::navigation::algorithms::Costmap::Index
Eigen::Array2i Index
Definition: Costmap.h:54
armarx::navigation::algorithms::Costmap::getMutableMask
std::optional< Costmap::Mask > & getMutableMask() noexcept
Definition: Costmap.cpp:405
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::navigation::algorithms::Costmap::AddMode::MAX
@ MAX
index
uint8_t index
Definition: EtherCATFrame.h:59
basic_types.h
armarx::navigation::algorithms::Costmap::Costmap
Costmap(const Grid &grid, const Parameters &parameters, const SceneBounds &sceneBounds, const std::optional< Mask > &mask=std::nullopt, const core::Pose2D &origin=core::Pose2D::Identity())
Definition: Costmap.cpp:30
armarx::navigation::algorithms::Costmap::getValidBoundingBox
std::pair< Index, Index > getValidBoundingBox() const
Definition: Costmap.cpp:589
ARMARX_CHECK_GREATER
#define ARMARX_CHECK_GREATER(lhs, rhs)
This macro evaluates whether lhs is greater (>) than rhs and if it turns out to be false it will thro...
Definition: ExpressionException.h:116
trace.h
armarx::navigation::algorithms::Costmap::Filter::matrix
Eigen::MatrixXf matrix
Definition: Costmap.h:41
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:297
armarx::navigation::algorithms::Costmap::Vertex::index
Index index
Definition: Costmap.h:69
armarx::navigation::algorithms
This file is part of ArmarX.
Definition: aron_conversions.cpp:25
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::navigation::algorithms::Costmap::Grid
Eigen::MatrixXf Grid
Definition: Costmap.h:56
armarx::navigation::algorithms::Costmap::Vertex
Definition: Costmap.h:67
armarx::navigation::algorithms::Costmap::Filter
Definition: Costmap.h:39
armarx::navigation::algorithms::Costmap::toPositionGlobal
Position toPositionGlobal(const Index &index) const
Definition: Costmap.cpp:69
armarx::navigation::algorithms::Costmap::Mask
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic > Mask
Definition: Costmap.h:59
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::navigation::algorithms::Costmap::excludeUnreachable
void excludeUnreachable(const Position &position)
Definition: Costmap.cpp:622
armarx::navigation::algorithms::Costmap::getLocalSceneBounds
const SceneBounds & getLocalSceneBounds() const noexcept
Definition: Costmap.cpp:130
armarx::navigation::core::Pose2D
Eigen::Isometry2f Pose2D
Definition: basic_types.h:34
Costmap.h
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::navigation::algorithms::Costmap::AddMode::MIN
@ MIN
M_PI
#define M_PI
Definition: MathTools.h:17
armarx::navigation::algorithms::Costmap::params
const Parameters & params() const noexcept
Definition: Costmap.cpp:237
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::navigation::algorithms::Costmap::Optimum
Definition: Costmap.h:104
armarx::navigation::algorithms::Costmap::toPositionLocal
Position toPositionLocal(const Index &index) const
Definition: Costmap.cpp:55
armarx::navigation::algorithms::Costmap::toVertex
Vertex toVertex(const Position &globalPosition) const
Definition: Costmap.cpp:103
armarx::navigation::algorithms::Costmap::getGrid
const Grid & getGrid() const
Definition: Costmap.cpp:243
armarx::navigation::algorithms::Costmap::Position
Eigen::Vector2f Position
Definition: Costmap.h:55
max
T max(T t1, T t2)
Definition: gdiam.h:51
armarx::navigation::algorithms::Costmap::value
std::optional< float > value(const Index &index) const
Definition: Costmap.cpp:411
armarx::navigation::algorithms::SceneBounds
Definition: types.h:29
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
armarx::navigation::algorithms::Costmap::mergeInto
Costmap mergeInto(const std::vector< Costmap > &costmaps, const std::vector< float > &weights) const
Merge a list of costmaps into this costmap.
Definition: Costmap.cpp:473
ExpressionException.h
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::navigation::algorithms::SceneBounds::min
Eigen::Vector2f min
Definition: types.h:31
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::navigation::algorithms::Costmap::filter
void filter(const Filter &filter)
Definition: Costmap.cpp:179
armarx::navigation::algorithms::Costmap::AddMode
AddMode
Definition: Costmap.h:117
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:327
armarx::navigation::algorithms::Costmap::Parameters::cellSize
float cellSize
How big each cell is in the uniform grid.
Definition: Costmap.h:30
armarx::navigation::algorithms::Costmap::Parameters
Definition: Costmap.h:24
armarx::navigation::algorithms::Costmap::optimum
Optimum optimum() const
Definition: Costmap.cpp:136
Eigen::Matrix< bool, Eigen::Dynamic, Eigen::Dynamic >
Logging.h
min
T min(T t1, T t2)
Definition: gdiam.h:44
ARMARX_CHECK_EQUAL
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
Definition: ExpressionException.h:130
armarx::navigation::algorithms::Costmap::isValid
bool isValid(const Index &index) const noexcept
checks whether the cell is masked out
Definition: Costmap.cpp:76
armarx::navigation::algorithms::Costmap::add
bool add(const Costmap &other, float weight=1.0)
Definition: Costmap.cpp:256
armarx::pair_hash
Definition: ArvizProfileManagerWidget.h:44
armarx::navigation::algorithms::Costmap::numberOfValidElements
std::size_t numberOfValidElements() const
Definition: Costmap.cpp:545
armarx::navigation::algorithms::Costmap::Filter::gaussian
static Filter gaussian(int radius=2, float sigma=1.)
Definition: Costmap.cpp:528
types.h
armarx::navigation::algorithms::SceneBounds::max
Eigen::Vector2f max
Definition: types.h:32
armarx::navigation::algorithms::Costmap::isInCollision
bool isInCollision(const Position &p) const
Definition: Costmap.cpp:249
armarx::navigation::algorithms::Costmap
Definition: Costmap.h:16