old_result_visualizer_rviz.cpp
Go to the documentation of this file.
1 
17 //Header include
19 
20 //Ilcas includes
22 #include <ISM/utility/GeometryHelper.hpp>
23 
24 //foreigen includes
25 #include <Eigen/StdVector>
26 
27 namespace VIZ
28 {
30 {
31 }
32 void OLD_ResultVisualizerRVIZ::addVisualization(const ISM::RecognitionResultPtr recognition_result,
33  std::string name_space_prefix)
34 {
35  visualization_msgs::MarkerArray current_marker_array = getMarkersFromResult(recognition_result,
36  0,
37  name_space_prefix);
38  addMarker(current_marker_array);
40 }
41 
43  int depth,
44  std::string name_space_prefix)
45 {
48 
49  if (result->referencePose == nullptr)
50  {
51  return retMarkers;
52  }
53 
54  std::string markerNamespace = name_space_prefix + prefix + "ism_" + result->patternName;
55 
56  /* create marker for reference-pose */
57  auto refPose = result->referencePose;
58  int id = 0;
59  std_msgs::ColorRGBA refColor = (depth == 0) ? VizHelperRVIZ::createColorRGBA(0.0, 0.0, 1.0, 1.0)
60  : VizHelperRVIZ::createColorRGBA(0.0, 1.0, 0.0, 1.0);
61 
62  auto refMarker = VizHelperRVIZ::createSphereMarker(getAdjustedPosition(refPose, depth),
63  this->baseFrame, markerNamespace + "_ref",
64  id, 0.025, refColor, this->markerLifetime);
65 
66  retMarkers.markers.push_back(refMarker);
67 
68  /* create marker to show the point of ascension in the ISM-tree */
69  if(depth > 0)
70  {
71  std_msgs::ColorRGBA ascArrowColor = VizHelperRVIZ::createColorRGBA(0.0, 0.0, 1.0, 1.0);
72  auto ascArrowMarker = VizHelperRVIZ::createArrowMarkerToPoint(getAdjustedPosition(refPose, depth),
73  getAdjustedPosition(refPose, depth - 1), this->baseFrame,
74  markerNamespace + "_point_of_ascension_arrow", id++, 0.024, 0.04,
75  0.04, ascArrowColor, this->markerLifetime);
76  retMarkers.markers.push_back(ascArrowMarker);
77  }
78 
79 
80  /* create marker(arrow) from object positions(sphere) to the corresponding reference position(sphere) */
81  std_msgs::ColorRGBA confidenceColor = VizHelperRVIZ::confidenceToColor(result->confidence);
82  for (ISM::ObjectPtr& obj : result->recognizedSet->objects)
83  {
84  auto arrowToRefMarker = VizHelperRVIZ::createArrowMarkerToPoint(getAdjustedPosition(obj->pose, depth),
85  getAdjustedPosition(refPose, depth),
86  this->baseFrame, markerNamespace + "_to_ref_arrow",
87  id++, 0.015, 0.025, 0.04, confidenceColor, this->markerLifetime);
88  retMarkers.markers.push_back(arrowToRefMarker);
89  }
90 
91  /* retrieve markers for the sub results, one step deeper in the ISM-tree */
92  for (ISM::RecognitionResultPtr& subPattern : result->subPatterns)
93  {
94  visualization_msgs::MarkerArray subMarkers = OLD_ResultVisualizerRVIZ::getMarkersFromResult(subPattern, depth + 1, name_space_prefix);
95  for (auto tempMarker : subMarkers.markers)
96  {
97  retMarkers.markers.push_back(tempMarker);
98  }
99  }
100  return retMarkers;
101 }
102 
103 ISM::PointPtr OLD_ResultVisualizerRVIZ::getAdjustedPosition(ISM::PosePtr pose, int depth)
104 {
105  Eigen::Quaternion<double> rotation = ISM::GeometryHelper::quatToEigenQuat(pose->quat);
106  rotation.normalize();
107  Eigen::Vector3d translation(0.0, (-depth * 0.10), 0.0);
108  Eigen::Vector3d offset = rotation._transformVector(translation);
109  return ISM::PointPtr(new ISM::Point(pose->point->eigen.x() + offset[0],
110  pose->point->eigen.y() + offset[1],
111  pose->point->eigen.z() + offset[2]));
112 
113 }
114 }
115 
116 
static Marker createSphereMarker(ISM::PointPtr point, std::string baseFrame, std::string markerNamespace, int id, float radius, ColorRGBA color, double markerLifetime)
ISM::PointPtr getAdjustedPosition(ISM::PosePtr pose, int depth)
static ColorRGBA createColorRGBA(float red, float green, float blue, float alpha)
visualization_msgs::MarkerArray getMarkersFromResult(const ISM::RecognitionResultPtr result, int depth, std::string name_space_prefix="")
std_msgs::ColorRGBA ColorRGBA
void addVisualization(const ISM::RecognitionResultPtr recognition_result, std::string name_space_prefix="")
visualization_msgs::MarkerArray MarkerArray
static Marker createArrowMarkerToPoint(ISM::PointPtr fromPoint, ISM::PointPtr to, std::string baseFrame, std::string markerNamespace, int id, float xScale, float yScale, float zScale, ColorRGBA color, double markerLifetime)
void addMarker(visualization_msgs::Marker marker)
static ColorRGBA confidenceToColor(double confidence)


asr_ism_visualizations
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Meißner Pascal, Reckling Reno, Stöckle Patrick, Trautmann Jeremias
autogenerated on Fri Nov 8 2019 03:28:47