30 ISM::RecognitionResultPtr result;
31 for(std::size_t i = 0; i < results.size(); i++){
38 ROS_ERROR(
"Recognition Result doesn't contain result of pattern %s.\nSkipping visualization.",
pattern_name_.c_str());
48 ISM::VotingSpacePtr matching_voting_space_ptr = voting_space.second;
49 std::map<ISM::ObjectPtr, std::vector<ISM::PosePtr>> voter_to_poses_map =
getSortedVotedPoses(matching_voting_space_ptr);
50 std::vector<ISM::PosePtr> poses_ptr;
51 for(
auto iter: voter_to_poses_map){
52 poses_ptr.insert(poses_ptr.end(), iter.second.begin(), iter.second.end());
67 Marker ret_marker =
VizHelperRVIZ::createMarkerWithoutTypeAndPose(
base_frame_,
"result_votes_overlay", 0,
line_scale_, 0, 0,
VizHelperRVIZ::createColorRGBA(0.0, 0.0, 0.0, 1.0),
marker_lifetime_);
68 ret_marker.type = Marker::LINE_LIST;
70 for (ISM::SummarizedVotedPosePtr& summarized_vote : result->summarizedVotes)
99 std::map<std::tuple<double, double, double>,
int> bin_to_votecount_map;
102 std::tuple<int, int, int, int, int, int> grid_bb {INT_MAX, INT_MAX, INT_MAX, -INT_MAX, -INT_MAX, -INT_MAX};
106 ISM::XIndexToYIndex grid = voting_space_ptr->voteGrid;
108 for(ISM::XIndexToYIndex::iterator x_iter = grid.begin(); x_iter!=grid.end(); ++x_iter){
109 for(ISM::YIndexToZIndex::iterator y_iter = x_iter->second.begin(); y_iter!=x_iter->second.end(); ++y_iter){
110 for(ISM::ZIndexToVotingBinPtr::iterator z_iter = y_iter->second.begin(); z_iter!=y_iter->second.end(); ++z_iter){
111 for(ISM::TypeToInnerMap::iterator type_iter = z_iter->second->votes.begin(); type_iter != z_iter->second->votes.end(); ++type_iter){
112 for(ISM::IdToVoteMap::iterator map_iter = type_iter->second.begin(); map_iter !=type_iter->second.end(); ++map_iter){
117 std::get<0>(grid_bb) = std::min(x_iter->first, (
int)std::get<0>(grid_bb));
118 std::get<1>(grid_bb) = std::min(y_iter->first, (
int)std::get<1>(grid_bb));
119 std::get<2>(grid_bb) = std::min(z_iter->first, (
int)std::get<2>(grid_bb));
122 std::get<3>(grid_bb) = std::max(x_iter->first, std::get<3>(grid_bb));
123 std::get<4>(grid_bb) = std::max(y_iter->first, std::get<4>(grid_bb));
124 std::get<5>(grid_bb) = std::max(z_iter->first, std::get<5>(grid_bb));
127 if(bin_to_votecount_map.find(std::make_tuple(x, y, z)) == bin_to_votecount_map.end()){
128 bin_to_votecount_map.insert(std::make_pair(std::make_tuple(x, y, z), 0));
130 bin_to_votecount_map[std::make_tuple(x,y,z)] += map_iter->second.size();
137 int max_count = (int)-INFINITY;
138 int min_count = (int)INFINITY;
141 for(std::map<std::tuple<double, double, double>,
int>::iterator iter=bin_to_votecount_map.begin(); iter!=bin_to_votecount_map.end(); ++iter) {
142 if(iter->second > max_count){
143 max_count = iter->second;
145 if(iter->second < min_count){
146 min_count = iter->second;
151 for(std::map<std::tuple<double, double, double>,
int>::iterator iter = bin_to_votecount_map.begin(); iter!=bin_to_votecount_map.end(); ++iter) {
158 temp_marker.type = Marker::CUBE;
159 temp_marker.action = Marker::ADD;
160 temp_marker.pose.position =
VizHelperRVIZ::createPoint(std::get<0>(iter->first), std::get<1>(iter->first), std::get<2>(iter->first));
161 ret_markers.markers.push_back(temp_marker);
176 std::string voter_namespace;
178 std::map<std::string, std::vector< std::pair<ISM::PointPtr, std::vector<ISM::PosePtr> > > > united_votes_of_voter;
180 for(
auto iter: voter_to_poses_map)
182 if(united_votes_of_voter.find(iter.first->type) == united_votes_of_voter.end()){
183 std::vector< std::pair<ISM::PointPtr, std::vector<ISM::PosePtr> > > temp_vector;
184 united_votes_of_voter[iter.first->type] = temp_vector;
186 united_votes_of_voter[iter.first->type].push_back(std::make_pair(iter.first->pose->point, iter.second));
191 for(
auto iter: united_votes_of_voter)
193 voter_namespace =
"votes_of_" + iter.first;
199 ret_markers.markers.insert(ret_markers.markers.end(), temp_arrow_markers.markers.begin(), temp_arrow_markers.markers.end());
201 for(
size_t j = 0; j < iter.second.size(); j++){
204 temp_voter_marker.color.a = 1.0;
205 ret_markers.markers.push_back(temp_voter_marker);
217 ret_marker.type = Marker::LINE_LIST;
232 for(
double y = y_min;
y < y_max + epsilon;
y +=
bin_size_){
233 for(
double z = z_min;
z < z_max + epsilon;
z +=
bin_size_){
238 for(
double x = x_min;
x < x_max + epsilon;
x +=
bin_size_){
239 for(
double z = z_min;
z < z_max + epsilon;
z +=
bin_size_){
245 for(
double x = x_min;
x < x_max + epsilon;
x +=
bin_size_){
246 for(
double y = y_min;
y < y_max + epsilon;
y +=
bin_size_){
258 std::map<ISM::ObjectPtr, std::vector<ISM::PosePtr>> voter_to_poses_map;
259 ISM::XIndexToYIndex grid = voting_space_ptr->voteGrid;
261 for(ISM::XIndexToYIndex::iterator x_iter = grid.begin(); x_iter!=grid.end(); ++x_iter){
262 for(ISM::YIndexToZIndex::iterator y_iter = x_iter->second.begin(); y_iter != x_iter->second.end(); ++y_iter){
263 for(ISM::ZIndexToVotingBinPtr::iterator z_iter = y_iter->second.begin(); z_iter != y_iter->second.end(); ++z_iter){
264 for(ISM::TypeToInnerMap::iterator type_iter = z_iter->second->votes.begin(); type_iter != z_iter->second->votes.end(); ++type_iter){
265 for(ISM::IdToVoteMap::iterator map_iter = type_iter->second.begin(); map_iter != type_iter->second.end(); ++map_iter){
266 for(ISM::VotedPosePtrs::iterator vote_iter = map_iter->second.begin(); vote_iter != map_iter->second.end(); ++vote_iter){
268 if(voter_to_poses_map.find((*vote_iter)->source) != voter_to_poses_map.end()){
269 voter_to_poses_map[(*vote_iter)->source].push_back((*vote_iter)->pose);
271 std::vector<ISM::PosePtr> temp_vec;
272 voter_to_poses_map.insert(std::make_pair((*vote_iter)->source, temp_vec));
273 voter_to_poses_map[(*vote_iter)->source].push_back((*vote_iter)->pose);
281 return voter_to_poses_map;
288 for(ISM::RecognitionResultPtr subPattern : result->subPatterns) {
290 if(temp_recognition_result_ptr != NULL){
291 return temp_recognition_result_ptr;
static Marker createCylinderMarker(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, int id, float radius, float height, ColorRGBA color, double markerLifetime)
void publishCollectedMarkers()
static ColorRGBA hsvToRGBA(double hue, double saturation, double value)
visualization_msgs::Marker Marker
static geometry_msgs::Point pointToPointMsg(ISM::PointPtr point)
TFSIMD_FORCE_INLINE const tfScalar & y() const
visualization_msgs::Marker generateGridMarker(std::tuple< int, int, int, int, int, int > grid_bb)
double confidence_sphere_opacity_
static Marker createSphereMarker(ISM::PointPtr point, std::string baseFrame, std::string markerNamespace, int id, float radius, ColorRGBA color, double markerLifetime)
static MarkerArray createCoordinateArrow(std::vector< std::pair< ISM::PointPtr, std::vector< ISM::PosePtr > > > poses_vec, std::string baseFrame, std::string markerNamespace, float arrowScale, float axisScale, ColorRGBA color, double markerLifetime)
std::string pattern_name_
visualization_msgs::Marker generateResultVoteOverlay(ISM::RecognitionResultPtr result)
std::map< ISM::ObjectPtr, std::vector< ISM::PosePtr > > getSortedVotedPoses(ISM::VotingSpacePtr voting_space_ptr)
static ColorRGBA createColorRGBA(float red, float green, float blue, float alpha)
ISM::RecognitionResultPtr getRecognitionResultPtrOfPattern(ISM::RecognitionResultPtr result)
double object_marker_opacity_
std_msgs::ColorRGBA ColorRGBA
TFSIMD_FORCE_INLINE const tfScalar & x() const
visualization_msgs::MarkerArray generateVoteMarker(std::map< ISM::ObjectPtr, std::vector< ISM::PosePtr >> voter_to_poses_map)
visualization_msgs::MarkerArray MarkerArray
static geometry_msgs::Point createPoint(double x, double y, double z)
TFSIMD_FORCE_INLINE const tfScalar & z() const
void addMarker(visualization_msgs::Marker marker)
visualization_msgs::MarkerArray generateRefMarker(ISM::RecognitionResultPtr result, std::vector< ISM::PosePtr > voted_poses)
void addVisualization(const ISM::PatternNameAndVotingSpaceTuple &voting_space, std::vector< ISM::RecognitionResultPtr > results)
static Marker createMarkerWithoutTypeAndPose(std::string baseFrame, std::string markerNamespace, int id, float xScale, float yScale, float zScale, ColorRGBA color, double markerLifetime)
visualization_msgs::MarkerArray generateBinAndGridMarker(ISM::VotingSpacePtr voting_space_ptr)
static Marker createLineArrow(ISM::PointPtr fromPoint, std::vector< ISM::PosePtr > toPoses, std::string baseFrame, std::string markerNamespace, int &id, float arrowScale, ColorRGBA color, double markerLifetime)
static ColorRGBA confidenceToColor(double confidence)
double object_marker_scale_