19 #include <Eigen/Geometry> 28 publisher = n.
advertise<visualization_msgs::MarkerArray>(
"/recognizer_prediction_psm/visualization_marker_array", 1);
39 mFoundBuffer.push_back(std::make_pair(point.x(), point.y()));
60 geometry_msgs::Pose pose = p.pose;
61 mUnfoundBuffer.push_back(std::make_pair(pose.position.x, pose.position.y));
66 geometry_msgs::Pose pose = p.pose;
67 mFoundBuffer.push_back(std::make_pair(pose.position.x, pose.position.y));
84 const std::string target_frame,
const int id)
86 float scale_hyp = 0.1f;
87 float scale_found = 0.2f;
89 visualization_msgs::Marker sample3dList;
90 sample3dList.header.frame_id = target_frame;
92 sample3dList.ns =
"hypothesis";
93 sample3dList.action = visualization_msgs::Marker::ADD;
94 sample3dList.type = visualization_msgs::Marker::SPHERE_LIST;
98 sample3dList.scale.x = scale_hyp;
99 sample3dList.scale.y = scale_hyp;
100 sample3dList.scale.z = scale_hyp;
101 sample3dList.color.r = 1;
102 sample3dList.color.g = 0;
103 sample3dList.color.b = 0;
104 sample3dList.color.a = 1.0;
108 sample3dList.points.push_back(hyp.pose.position);
111 visualization_msgs::Marker found3dList;
112 found3dList.header.frame_id = target_frame;
114 found3dList.ns =
"observed_objects";
115 found3dList.action = visualization_msgs::Marker::ADD;
116 found3dList.type = visualization_msgs::Marker::CUBE_LIST;
118 found3dList.id =
id + 1;
120 found3dList.scale.x = scale_found;
121 found3dList.scale.y = scale_found;
122 found3dList.scale.z = scale_found;
123 found3dList.color.r = 0;
124 found3dList.color.g = 0;
125 found3dList.color.b = 1;
126 found3dList.color.a = 1.0;
130 found3dList.points.push_back(p.pose.position);
147 const std::string& pXLabel,
const std::string& pYLabel,
148 const std::pair<float, float>& pXRange,
const std::pair<float, float>& pYRange,
149 const std::pair<float, float>& pDelta) {
175 *(
mGnuplotHandler) <<
"set xrange [" << pXRange.second <<
":" << pXRange.first <<
"]\n";
176 *(
mGnuplotHandler) <<
"set yrange [" << pYRange.first <<
":" << pYRange.second <<
"]\n";
183 *(
mGnuplotHandler) <<
"set xtics " << pXRange.first <<
"," << pDelta.first * 4 <<
"," << pXRange.second <<
"rotate\n";
184 *(
mGnuplotHandler) <<
"set ytics " << pYRange.first <<
"," << pDelta.second * 4 <<
"," << pYRange.second <<
"\n";
187 *(
mGnuplotHandler) <<
"set x2tics " << pXRange.first <<
"," << pDelta.first <<
"," << pXRange.second <<
" scale 0\n";
188 *(
mGnuplotHandler) <<
"set y2tics " << pYRange.first <<
"," << pDelta.second <<
"," << pYRange.second <<
" scale 0\n";
205 throw std::runtime_error(
"Cannot show non-existing gnuplot visualization.");
216 *(
mGnuplotHandler) <<
", '-' with points ls 2 title \"Object Hypotheses\"";
239 std::vector<AttributedPoint> found_poses)
295 std::string object_path =
"";
297 if(p.objectType.compare(
"PlateDeep") == 0)
298 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/PlateDeep/object.dae";
299 else if(p.objectType.compare(
"Cup") == 0)
300 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/Cup/object.dae";
301 else if(p.objectType.compare(
"Smacks") == 0)
302 object_path =
"package://asr_object_database/rsc/databases/textured_objects/Smacks/Smacks.dae";
303 else if(p.objectType.compare((
"VitalisSchoko")) == 0)
304 object_path =
"package://asr_object_database/rsc/databases/textured_objects/VitalisSchoko/VitalisSchoko.dae";
305 else if(p.objectType.compare(
"CeylonTea") == 0)
306 object_path =
"package://asr_object_database/rsc/databases/textured_objects/CeylonTea/CeylonTea.dae";
307 else if(p.objectType.compare(
"Marker_1") == 0)
308 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/SpoonBig/object_rotated.dae";
310 visualization_msgs::Marker marker;
311 marker.header.frame_id =
"/map";
312 marker.type = visualization_msgs::Marker::MESH_RESOURCE;
313 marker.mesh_resource = object_path;
314 marker.mesh_use_embedded_materials =
true;
315 marker.action = marker.ADD;
318 marker.ns = p.objectType;
319 marker.scale.x = 0.001;
320 marker.scale.y = 0.001;
321 marker.scale.z = 0.001;
322 marker.pose.orientation.w = p.pose.orientation.w;
323 marker.pose.orientation.x = p.pose.orientation.x;
324 marker.pose.orientation.y = p.pose.orientation.y;
325 marker.pose.orientation.z = p.pose.orientation.z;
326 marker.pose.position.x = p.pose.position.x;
327 marker.pose.position.y = p.pose.position.y;
328 marker.pose.position.z = p.pose.position.z;
336 std::string object_path =
"";
338 if(p.objectType.compare(
"PlateDeep") == 0)
339 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/PlateDeep/object.dae";
340 else if(p.objectType.compare(
"Cup") == 0)
341 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/Cup/object.dae";
342 else if(p.objectType.compare(
"Smacks") == 0)
343 object_path =
"package://asr_object_database/rsc/databases/textured_objects/Smacks/Smacks.dae";
344 else if(p.objectType.compare((
"VitalisSchoko")) == 0)
345 object_path =
"package://asr_object_database/rsc/databases/textured_objects/VitalisSchoko/VitalisSchoko.dae";
346 else if(p.objectType.compare(
"CeylonTea") == 0)
347 object_path =
"package://asr_object_database/rsc/databases/textured_objects/CeylonTea/CeylonTea.dae";
348 else if(p.objectType.compare(
"Marker_1") == 0)
349 object_path =
"package://asr_object_database/rsc/databases/segmentable_objects/SpoonBig/object_rotated.dae";
351 visualization_msgs::Marker marker;
352 marker.header.frame_id =
"/map";
353 marker.type = visualization_msgs::Marker::MESH_RESOURCE;
354 marker.mesh_resource = object_path;
355 marker.mesh_use_embedded_materials =
true;
356 marker.action = marker.ADD;
359 marker.ns = p.objectType;
360 marker.scale.x = 0.001;
361 marker.scale.y = 0.001;
362 marker.scale.z = 0.001;
363 marker.pose.orientation.w = p.pose.orientation.w;
364 marker.pose.orientation.x = p.pose.orientation.x;
365 marker.pose.orientation.y = p.pose.orientation.y;
366 marker.pose.orientation.z = p.pose.orientation.z;
367 marker.pose.position.x = p.pose.position.x;
368 marker.pose.position.y = p.pose.position.y;
369 marker.pose.position.z = p.pose.position.z;
asrVisualizer(int max_number_of_published_vis_msgs=100)
void publish(const boost::shared_ptr< M > &message) const
std::vector< std::pair< double, double > > mUnfoundBuffer
void addPointToFoundBuffer(float x, float y)
void addPointToUnfoundBuffer(Eigen::Vector2f point)
void generateMarkerArray(std::vector< AttributedPoint > hypotheses, std::vector< AttributedPoint > found_poses)
asrVisualizer::generateMarkerArray generates a MarkerArray for RViz visualization ...
ros::Publisher hypothesis3dPublisher
visualization_msgs::MarkerArray markerArray
void addAttributedPoints(std::vector< AttributedPoint > hypotheses, std::vector< AttributedPoint > found_poses)
void publishRVizMarker(std::vector< AttributedPoint > hypotheses, std::vector< AttributedPoint > found_poses, const std::string target_frame="/map", const int id=1)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void initAnimatedPlot(const std::string &pPlotTitle, const std::string &pXLabel, const std::string &pYLabel, const std::pair< float, float > &pXRange, const std::pair< float, float > &pYRange, const std::pair< float, float > &pDelta)
bool getParam(const std::string &key, std::string &s) const
std::vector< std::pair< double, double > > mFoundBuffer
void publishMarkerArray()
asrVisualizer::publishMarkerArray publishs the MarkerArray
boost::shared_ptr< Gnuplot > mGnuplotHandler