| 25 | } |
| 26 | |
| 27 | void cloudCallback(const sensor_msgs::PointCloud2ConstPtr& msg) { |
| 28 | auto tn = ros::Time::now(); |
| 29 | if ((tn - last_cloud_time_).toSec() < 5) { |
| 30 | return; |
| 31 | } |
| 32 | last_cloud_time_ = tn; |
| 33 | |
| 34 | pcl::PointCloud<pcl::PointXYZ> pts; |
| 35 | pcl::PointCloud<pcl::PointXYZ> pts2; |
| 36 | pcl::fromROSMsg(*msg, pts); |
| 37 | vector<Eigen::Vector3d> inf_pts(27); |
| 38 | |
| 39 | for (int i = 0; i < pts.points.size(); ++i) { |
| 40 | Eigen::Vector3d pt; |
| 41 | pt(0) = pts[i].x; |
| 42 | pt(1) = pts[i].y; |
| 43 | pt(2) = pts[i].z; |
| 44 | for (int i = 0; i < 3; ++i) |
| 45 | pt(i) = floor((pt(i) - map_origin_(i)) * 10); |
| 46 | for (int i = 0; i < 3; ++i) |
| 47 | pt(i) = (pt(i) + 0.5) * 0.1 + map_origin_(i); |
| 48 | inflatePoint(pt, 1, inf_pts); |
| 49 | for (auto pi : inf_pts) { |
| 50 | pcl::PointXYZ pj; |
| 51 | pj.x = pi(0); |
| 52 | pj.y = pi(1); |
| 53 | pj.z = pi(2); |
| 54 | pts2.points.push_back(pj); |
| 55 | } |
| 56 | } |
| 57 | pts2.width = pts2.points.size(); |
| 58 | pts2.height = 1; |
| 59 | pts2.is_dense = true; |
| 60 | pts2.header.frame_id = "world"; |
| 61 | |
| 62 | sensor_msgs::PointCloud2 cloud; |
| 63 | pcl::toROSMsg(pts2, cloud); |
| 64 | cloud_pub.publish(cloud); |
| 65 | } |
| 66 | |
| 67 | int main(int argc, char** argv) { |
| 68 | ros::init(argc, argv, "process_msg"); |
nothing calls this directly
no test coverage detected