11#include <SimoxUtility/color/cmaps/colormaps.h>
17#include <RobotAPI/interface/ArViz/Elements.h>
32 const std::optional<algorithms::Costmap::Mask>& mask,
36 const std::string& name,
39 const auto cmap = simox::color::cmaps::viridis();
40 const float vmax = grid.array().maxCoeff();
42 const auto asColor = [&cmap, &vmax](
const float distance,
43 const bool isValid) -> viz::data::Color
45 const auto color = cmap.at(
distance, 0.F, vmax);
48 const Ice::Byte alpha = isValid &&
distance >= 0 ? color.a : 0;
49 return {alpha, color.r, color.g, color.b};
52 const std::int64_t cols = grid.cols();
53 const std::int64_t rows = grid.rows();
55 auto mesh = viz::Mesh(name);
57 std::vector<std::vector<Eigen::Vector3f>> vertices;
58 std::vector<std::vector<viz::data::Color>> colors;
60 for (
int r = 0; r < rows; r++)
62 auto& verticesRow = vertices.emplace_back(cols);
63 auto& colorsRow = colors.emplace_back(cols);
65 for (
int c = 0;
c < cols;
c++)
69 const bool isValid = mask.has_value() ? mask.value()(r,
c) : true;
70 colorsRow.at(
c) = asColor(grid(r,
c), isValid);
74 mesh.grid2D(vertices, colors);
75 mesh.position({0, 0, zOffset});
84 const std::string& name,
101 origin.translation().z() += zOffset;
103 const Eigen::Translation3f origin_T_costmap{
104 costmap.getLocalSceneBounds().min.x(),
costmap.getLocalSceneBounds().min.y(), 0.F};
106 origin *= origin_T_costmap;
110 e.resolution(
costmap.params().cellSize);
119 std::vector<viz::Layer>& layers,
120 const std::string& name,
124 for (
int i = 0; i <
costmap.params().orientations; ++i)
126 std::stringstream ori_name;
127 ori_name << name <<
"_" << i;
132 zOffset + 0.01F * i);
This file is part of ArmarX.
This file is part of ArmarX.
void visualize(const algorithms::Costmap &costmap, viz::Layer &layer, const std::string &name, const float zOffset)
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
double distance(const Point &a, const Point &b)
void add(ElementT const &element)