Go to the documentation of this file.00001 #include <ros/ros.h>
00002 #include <sensor_msgs/PointCloud.h>
00003
00004 #include <pcl/ros/conversions.h>
00005 #include <pcl/point_cloud.h>
00006 #include <pcl/point_types.h>
00007 #include "icr/compute_icr.h"
00008 #include <string>
00009
00010 using std::string;
00011
00012 ros::Publisher pub;
00013
00014 int main (int argc, char** argv)
00015 {
00016
00017 ros::init (argc, argv, "my_icr_pcl_test");
00018 ros::NodeHandle nh;
00019
00020
00021 uint16_t myints[] = {1838, 4526, 4362, 1083, 793};
00022 uint16_t myints2[] = {138, 452, 436, 108, 793};
00023 uint16_t myints3[] = {1000, 4000, 2000, 1083, 93};
00024 std::vector<uint16_t>
00025 tmpPts(myints, myints + sizeof(myints) / sizeof(uint16_t) );
00026
00027
00028 compute_icr_srv.request.centerpoint_ids = tmpPts;
00029 std::vector<uint8_t> tmp_used(5,1);
00030 compute_icr_srv.request.used = tmp_used;
00031
00032 if (clientComputeICR.call(compute_icr_srv)) {
00033 ROS_INFO("Response: %ld", (long int)compute_icr_srv.response.success);
00034 }
00035
00036
00037 pub = nh.advertise<sensor_msgs::PointCloud> ("output", 1);
00038 sensor_msgs::PointCloud output_cloud;
00039 plc::PointCloud<plc::PointXYZ>::Ptr cloud(new plc::PointCloud<plc::PointXYZRGB>() );
00040
00041
00042
00043
00044
00045
00046
00047 ros::Rate loop_rate(1);
00048 while (ros::ok())
00049 {
00050
00051 if (clientComputeICR.call(compute_icr_srv)
00052 && compute_icr_srv.response.success == true)
00053 {
00054 icr2pc(compute_icr_srv.response, cloud);
00055 pub.publish(cloud);
00056 ros::spinOnce();
00057 }
00058 loop_rate.sleep();
00059 }
00060 }
00061
00062
00063 bool icr2pc(icr::compute_icr::Response &res_in, plc::PointCloud<plc::PointXYZ>::Ptr cloud) {
00064 ROS_INFO("converting ICR to PointCloud message");
00065
00066 for (uint j=0; j<res.stx.size();++j) {
00067
00068 for(uint i=res.stx[j]; i<res.stx[j]+res.len[j] ;++i) {
00069
00070 plc::PointXYZ pt;
00071 pt.x = rand();
00072 pt.y = rand();
00073 pt.z = rand();
00074
00075 cloud.points->push_back(pt);
00076 }
00077 cout << endl;
00078 }
00079
00080 cloud.width = cloud.points.size();
00081 cloud.height = 1;
00082
00083 return true;
00084 }