set_point_map.cpp
Go to the documentation of this file.
00001 
00060 //##################
00061 //#### includes ####
00062 
00063 // ROS includes
00064 #include <ros/ros.h>
00065 #include <actionlib/client/simple_action_client.h>
00066 #include <actionlib/client/terminal_state.h>
00067 
00068 // ROS message includes
00069 #include <cob_3d_mapping_msgs/SetPointMap.h>
00070 
00071 // PCL includes
00072 #include <pcl/io/pcd_io.h>
00073 #include <pcl/point_types.h>
00074 #include <pcl/conversions.h>
00075 #include <pcl_conversions/pcl_conversions.h>
00076 
00077 
00078 int main (int argc, char **argv)
00079 {
00080   if(argc<1) {
00081     ROS_ERROR("Please specify path to map file\nrosrun cob_env_model set_point_map myfile.pcd");
00082     return -1;
00083   }
00084   ros::init(argc, argv, "set_point_map");
00085 
00086   ros::NodeHandle nh;
00087 
00088   ROS_INFO("Waiting for service server to start.");
00089   // wait for the server to start
00090   ros::service::waitForService("/point_map/set_map"); //will wait for infinite time
00091 
00092   ROS_INFO("Server started, sending map.");
00093 
00094   //create message
00095   cob_3d_mapping_msgs::SetPointMapRequest req;
00096 
00097   pcl::PointCloud<pcl::PointXYZRGB> map;
00098   if(pcl::io::loadPCDFile(argv[1], map)!=0) {
00099     ROS_ERROR("Couldn't open pcd file. Sorry.");
00100     return -1;
00101   }
00102 
00103   pcl::PCLPointCloud2 map2;
00104   pcl::toPCLPointCloud2(map, map2);
00105   sensor_msgs::PointCloud2 cloud_msg;
00106   pcl_conversions::fromPCL(map2, cloud_msg);
00107   //pcl::toROSMsg(map,req.map);
00108   req.map.header.frame_id ="/map";
00109   cob_3d_mapping_msgs::SetPointMapResponse resp;
00110 
00111   if (ros::service::call("/point_map/set_map", req,resp))
00112   {
00113     ROS_INFO("Service call finished.");
00114   }
00115   else
00116     ROS_INFO("[set point map]: Service call failed.");
00117 
00118   return 0;
00119 }
00120 


cob_3d_mapping_point_map
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:02:48