void ConvexConnectedVoxels::cloud_cb( const sensor_msgs::PointCloud2::ConstPtr &cloud_msg) { // JSK_ROS_INFO("PROCESSING CLOUD CALLBACK"); // boost::mutex::scoped_lock lock(this->mutex_); // vital_checker_->poke(); pcl::PointCloud<PointT>::Ptr cloud (new pcl::PointCloud<PointT>); pcl::fromROSMsg(*cloud_msg, *cloud); std::vector<pcl::PointCloud<PointT>::Ptr> cloud_clusters; std::vector<pcl::PointCloud<pcl::Normal>::Ptr> normal_clusters; pcl::PointCloud<pcl::PointXYZ>::Ptr centroids( new pcl::PointCloud<pcl::PointXYZ>); this->segmentCloud( cloud, this->indices_, cloud_clusters, normal_clusters, centroids); std::vector<std::vector<int> > neigbour_idx; this->nearestNeigborSearch(centroids, neigbour_idx, 4); boost::shared_ptr<jsk_pcl_ros::RegionAdjacencyGraph> rag( new jsk_pcl_ros::RegionAdjacencyGraph); rag->generateRAG( cloud_clusters, normal_clusters, centroids, neigbour_idx, rag->RAG_EDGE_WEIGHT_CONVEX_CRITERIA); rag->splitMergeRAG(0.0); std::vector<int> labelMD; rag->getCloudClusterLabels(labelMD); std::map<int, pcl::PointIndices> _indices; this->getConvexLabelCloudIndices( cloud_clusters, cloud, labelMD, _indices); std::vector<pcl::PointIndices> all_indices; for (std::map<int, pcl::PointIndices>::iterator it = _indices.begin(); it != _indices.end(); it++) { all_indices.push_back((*it).second); } // JSK_ROS_INFO("Size: %ld", _indices.size()); jsk_recognition_msgs::ClusterPointIndices ros_indices; ros_indices.cluster_indices = pcl_conversions::convertToROSPointIndices( all_indices, cloud_msg->header); ros_indices.header = cloud_msg->header; pub_indices_.publish(ros_indices); }
void iuse::scissors(game *g, player *p, item *it, bool t) { char ch = g->inv("Chop up what?"); item* cut = &(p->i_at(ch)); if (cut->type->id == 0) { g->add_msg("You do not have that item!"); return; } if (cut->type->id == itm_rag) { g->add_msg("There's no point in cutting a rag."); return; } if (cut->type->id == itm_string_36) { p->moves -= 150; g->add_msg("You cut the string into 6 smaller pieces."); item string(g->itypes[itm_string_6], g->turn, g->nextinv); p->i_rem(ch); bool drop = false; for (int i = 0; i < 6; i++) { int iter = 0; while (p->has_item(string.invlet)) { string.invlet = g->nextinv; g->advance_nextinv(); iter++; } if (!drop && (iter == 52 || p->volume_carried() >= p->volume_capacity())) drop = true; if (drop) g->m.add_item(p->posx, p->posy, string); else p->i_add(string); } } if (!cut->made_of(COTTON)) { g->add_msg("You can only slice items made of cotton."); return; } p->moves -= 25 * cut->volume(); int count = cut->volume(); if (p->sklevel[sk_tailor] == 0) count = rng(0, count); else if (p->sklevel[sk_tailor] == 1 && count >= 2) count -= rng(0, 2); if (dice(3, 3) > p->dex_cur) count -= rng(1, 3); if (count <= 0) { g->add_msg("You clumsily cut the %s into useless ribbons.", cut->tname().c_str()); p->i_rem(ch); return; } g->add_msg("You slice the %s into %d rag%s.", cut->tname().c_str(), count, (count == 1 ? "" : "s")); item rag(g->itypes[itm_rag], g->turn, g->nextinv); p->i_rem(ch); bool drop = false; for (int i = 0; i < count; i++) { int iter = 0; while (p->has_item(rag.invlet) && iter < 52) { rag.invlet = g->nextinv; g->advance_nextinv(); iter++; } if (!drop && (iter == 52 || p->volume_carried() >= p->volume_capacity())) drop = true; if (drop) g->m.add_item(p->posx, p->posy, rag); else p->i_add(rag); } }