ObjectModelVisualizerRVIZ.cpp
Go to the documentation of this file.
1 
17 //Header includes
19 
20 //Ilcas includes
22 #include <ISM/recognizer/VotingSpace.hpp>
23 #include <ISM/utility/Util.hpp>
24 #include <ISM/utility/GeometryHelper.hpp>
25 
26 namespace VIZ
27 {
28 
29 
30 
31 void ObjectModelVisualizerRVIZ::drawObjectModels(const std::vector<ISM::ObjectPtr>& objects, const std::map<ISM::ObjectPtr, double>& objects_to_hue_map)
32 {
34  vizObjects = ObjectModelVisualizerRVIZ::getMarkersFromObjects(objects, objects_to_hue_map);
35  addMarker(vizObjects);
37 }
38 
39 visualization_msgs::MarkerArray ObjectModelVisualizerRVIZ::getMarkersFromObjects(const std::vector<ISM::ObjectPtr> objects, const std::map<ISM::ObjectPtr, double>& objects_to_hue_map)
40 {
42 
43  std::string markerNamespace = this->prefix + "Object_Mesh_";
44  int id = 0;
45 
46  for(const ISM::ObjectPtr& object : objects)
47  {
48  std::string tempPath;
49  tempPath = object->ressourcePath.string();
50  if( !tempPath.empty() )
51  {
52  visualization_msgs::Marker tempObjectMarker;
53  tempObjectMarker = VizHelperRVIZ::createMeshMarker(object->pose, this->baseFrame, markerNamespace + object->type + object->observedId, 0,
54  VizHelperRVIZ::getColorOfObject(object), this->markerLifetime,
55  tempPath);
56 
57  // predefined highlighting exists?
58  std::map<ISM::ObjectPtr, double>::const_iterator it = objects_to_hue_map.find(object);
59  if (it != objects_to_hue_map.end())
60  {
61  tempObjectMarker.color = VizHelperRVIZ::hsvToRGBA(it->second, 1.0, 1.0);
62  tempObjectMarker.color.a = 0.5;
63  }
64 
65 
66  retMarkers.markers.push_back(tempObjectMarker);
67  } else
68  {
70  tempMarkers = VizHelperRVIZ::createCoordinateMarker(object->pose, this->baseFrame, markerNamespace + object->type + object->observedId + "_FRAME" ,
71  id, 0.05, 0.002, this->markerLifetime);
72 
73 
74  retMarkers.markers.insert(retMarkers.markers.end(), tempMarkers.markers.begin(), tempMarkers.markers.end());
75  retMarkers.markers.insert(retMarkers.markers.end(), tempMarkers.markers.begin(), tempMarkers.markers.end());
76  id += tempMarkers.markers.size();
77  }
78  //Visualize Orientation-Axis(X-Axis)
79  visualization_msgs::Marker axisMarker = VIZ::VizHelperRVIZ::createMarkerWithoutTypeAndPose(baseFrame, markerNamespace + object->type + object->observedId + "_xAXIS", id++, 0.1, 0.01, 0.01, VIZ::VizHelperRVIZ::createColorRGBA(1, 0, 0, 1), markerLifetime);
80  axisMarker.type = visualization_msgs::Marker::ARROW;
81  Eigen::Quaterniond transformed_X_Axis = Eigen::AngleAxisd(0.0, Eigen::Vector3d::UnitX()) * ISM::GeometryHelper::quatToEigenQuat(object->pose->quat);
82  axisMarker.pose.orientation = VizHelperRVIZ::quatToQuaternionMsg(ISM::GeometryHelper::eigenQuatToQuat(transformed_X_Axis));
83  axisMarker.pose.position = VizHelperRVIZ::pointToPointMsg(object->pose->point);
84  axisMarker.action = visualization_msgs::Marker::ADD;
85  retMarkers.markers.push_back(axisMarker);
86  }
87 
88  return retMarkers;
89 }
90 }
static ColorRGBA hsvToRGBA(double hue, double saturation, double value)
static MarkerArray createCoordinateMarker(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, int id, float length, float radius, double markerLifetime)
static ColorRGBA getColorOfObject(const ISM::Object &object)
void drawObjectModels(const std::vector< ISM::ObjectPtr > &objects, const std::map< ISM::ObjectPtr, double > &objects_to_hue_map=std::map< ISM::ObjectPtr, double >())
visualization_msgs::Marker Marker
static geometry_msgs::Point pointToPointMsg(ISM::PointPtr point)
static geometry_msgs::Quaternion quatToQuaternionMsg(ISM::QuaternionPtr quat)
static ColorRGBA createColorRGBA(float red, float green, float blue, float alpha)
visualization_msgs::MarkerArray MarkerArray
void addMarker(visualization_msgs::Marker marker)
static Marker createMeshMarker(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, int id, ColorRGBA color, double markerLifetime, std::string resourcePath)
static Marker createMarkerWithoutTypeAndPose(std::string baseFrame, std::string markerNamespace, int id, float xScale, float yScale, float zScale, ColorRGBA color, double markerLifetime)
visualization_msgs::MarkerArray getMarkersFromObjects(const std::vector< ISM::ObjectPtr > objects, const std::map< ISM::ObjectPtr, double > &objects_to_hue_map)


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