Visu.cpp
Go to the documentation of this file.
1 #include "Visu.h"
2 
3 #include <SimoxUtility/color/Color.h>
4 #include <SimoxUtility/color/KellyLUT.h>
5 
7 
9 {
10  void
12  const std::string& id,
13  const Eigen::Matrix4f& locationGlobalPose) const
14  {
15  // Add global location to layer
16  layer.add(armarx::viz::Pose(id).pose(locationGlobalPose));
17  layer.add(armarx::viz::Arrow(id + "_dir")
18  .pose(locationGlobalPose)
19  .length(110)
20  .width(7.5)
21  .color(this->settings.framedLocationArrowColor));
22  }
23 
24  void
26  const std::string& id,
27  const Eigen::Matrix4f& locationGlobalPose,
28  const Eigen::Vector3f& extends) const
29  {
30  // Add global location to layer
31  std::smatch matches;
32  if (std::regex_match(id, matches, pattern))
33  {
34  const std::string& affordance_name = matches[1];
35  unique_affordances.insert(affordance_name);
36  unsigned int index = std::distance(unique_affordances.begin(),
37  unique_affordances.find(affordance_name)) %
38  simox::color::KellyLUT::KELLY_COLORS_COLOR_BLIND.size();
39  layer.add(armarx::viz::Text(id + "_name")
40  .text(affordance_name)
41  .color(simox::color::Color::black())
42  .scale(10.0f)
43  .pose(locationGlobalPose));
44  layer.add(
46  .pose(locationGlobalPose)
47  .size(extends)
48  .color(simox::color::KellyLUT::KELLY_COLORS_COLOR_BLIND.at(index).with_alpha(
49  0.5f)));
50  }
51  else
52  {
53  layer.add(armarx::viz::Text(id + "_name").text(id).pose(locationGlobalPose));
54  layer.add(armarx::viz::Box(id)
55  .pose(locationGlobalPose)
56  .size(extends)
57  .color(this->settings.framedBoxedLocationColor));
58  }
59  }
60 
62  Visu::locationsToLayer(const std::string& layerName,
63  const std::map<std::string, FramedLocationData>& locationData) const
64  {
65  auto layer = arviz.layer(layerName);
66  for (auto& [id, data] : locationData)
67  {
68  if (data.extents.has_value())
69  {
70  addFramedBoxedLocationToLayer(layer, id, data.globalPose, data.extents.value());
71  }
72  else
73  {
74  addFramedLocationToLayer(layer, id, data.globalPose);
75  }
76  }
77  return layer;
78  }
79 
82  const std::string& layerName,
83  const std::map<std::string, Eigen::Matrix4f>& locationGlobalPoses) const
84  {
85  auto layer = arviz.layer(layerName);
86  for (auto& [id, pose] : locationGlobalPoses)
87  {
88  // Add global location to layer
89  addFramedLocationToLayer(layer, id, pose);
90  }
91  return layer;
92  }
93 
96  const std::string& layerName,
97  const std::map<std::string, std::pair<Eigen::Matrix4f, Eigen::Vector3f>>&
98  locationGlobalPosesAndExtends) const
99  {
100  auto layer = arviz.layer(layerName);
101  for (auto& [id, pair] : locationGlobalPosesAndExtends)
102  {
103  const auto& pose = pair.first;
104  const auto& extends = pair.second;
105 
106  // Add global location to layer
107  addFramedBoxedLocationToLayer(layer, id, pose, extends);
108  }
109  return layer;
110  }
111 } // namespace armarx::priorknowledge::util::location
armarx::priorknowledge::util::location::Visu::framedBoxedLocationsToLayer
viz::Layer framedBoxedLocationsToLayer(const std::string &layerName, const std::map< std::string, std::pair< Eigen::Matrix4f, Eigen::Vector3f >> &locationGlobalPosesAndExtends) const
Definition: Visu.cpp:95
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::priorknowledge::util::location::Visu::Settings::framedBoxedLocationColor
viz::Color framedBoxedLocationColor
Definition: Visu.h:60
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::priorknowledge::util::location::Visu::addFramedBoxedLocationToLayer
void addFramedBoxedLocationToLayer(viz::Layer &, const std::string &id, const Eigen::Matrix4f &locationGlobalPose, const Eigen::Vector3f &extends) const
Definition: Visu.cpp:25
armarx::viz::Arrow
Definition: Elements.h:196
armarx::priorknowledge::util::location::Visu::arviz
viz::Client & arviz
Definition: Visu.h:65
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:31
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::viz::Box
Definition: Elements.h:47
armarx::viz::Pose
Definition: Elements.h:178
armarx::viz::Text
Definition: Elements.h:183
Visu.h
armarx::priorknowledge::util::location::Visu::settings
struct armarx::priorknowledge::util::location::Visu::Settings settings
armarx::skills::gui::matches
bool matches(std::string skillName, std::vector< std::string > &searches)
Definition: SkillManagerWrapper.cpp:66
armarx::priorknowledge::util::location::Visu::Settings::framedLocationArrowColor
viz::Color framedLocationArrowColor
Definition: Visu.h:57
armarx::priorknowledge::util::location::Visu::addFramedLocationToLayer
void addFramedLocationToLayer(viz::Layer &, const std::string &id, const Eigen::Matrix4f &locationGlobalPose) const
Definition: Visu.cpp:11
distance
double distance(const Point &a, const Point &b)
Definition: point.hpp:95
armarx::priorknowledge::util::location::Visu::locationsToLayer
viz::Layer locationsToLayer(const std::string &layerName, const std::map< std::string, FramedLocationData > &locationData) const
Definition: Visu.cpp:62
Logging.h
armarx::viz::Client::layer
Layer layer(std::string const &name) const
Definition: Client.cpp:80
armarx::priorknowledge::util::location
Definition: Visu.cpp:8
armarx::viz::Layer
Definition: Layer.h:12
armarx::priorknowledge::util::location::Visu::framedLocationsToLayer
viz::Layer framedLocationsToLayer(const std::string &layerName, const std::map< std::string, Eigen::Matrix4f > &locationGlobalPoses) const
Definition: Visu.cpp:81