Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <srs_ui_but/but_services/service_server.h>
00029
00030 namespace srs_ui_but
00031 {
00032
00033
00034 srs_ui_but::PointCloudTools * pcTools;
00035
00036 bool getClosestPoint(GetClosestPoint::Request &req, GetClosestPoint::Response &res)
00037 {
00038 ROS_INFO("Getting closest point");
00039
00040 res.closest_point_data = pcTools->getClosestPoint(req.link);
00041 res.topic = pcTools->getPointCloudTopic();
00042
00043 if (!res.closest_point_data.status)
00044 {
00045 ROS_WARN("Cannot get closest point!");
00046 return false;
00047 }
00048
00049 ROS_INFO("..... DONE");
00050 return true;
00051 }
00052
00053 bool setPointCloudTopic(SetPointCloudTopic::Request &req, SetPointCloudTopic::Response &res)
00054 {
00055 ROS_INFO("Setting point cloud topic to: %s", req.topic.c_str());
00056
00057 pcTools->setPointCloudTopic(req.topic);
00058
00059 ROS_INFO("..... DONE");
00060 return true;
00061 }
00062
00063 }
00064
00065
00066
00067
00068 int main(int argc, char **argv)
00069 {
00070
00071
00072 ros::init(argc, argv, "but_service_server");
00073
00074
00075 ros::NodeHandle n;
00076
00077
00078 srs_ui_but::pcTools = new srs_ui_but::PointCloudTools();
00079
00080
00081 ros::ServiceServer getClosestPointService = n.advertiseService(srs_ui_but::GetClosestPoint_SRV, srs_ui_but::getClosestPoint);
00082 ros::ServiceServer setPointCloudTopicService = n.advertiseService(srs_ui_but::SetPointCloudTopic_SRV, srs_ui_but::setPointCloudTopic);
00083
00084 ROS_INFO("BUT Service Server ready!");
00085
00086
00087 ros::spin();
00088
00089 return 0;
00090 }