world_canvas_client.hpp
Go to the documentation of this file.
00001 /*
00002  * world_canvas_client.hpp
00003  *
00004  *  Created on: Oct 13, 2014
00005  *      Author: jorge
00006  */
00007 
00008 #ifndef WORLD_CANVAS_CLIENT_HPP_
00009 #define WORLD_CANVAS_CLIENT_HPP_
00010 
00011 #include <ros/ros.h>
00012 
00013 namespace wcf
00014 {
00015 
00019 class WorldCanvasClient
00020 {
00021 protected:
00022   ros::NodeHandle nh;
00023   std::string srv_namespace;
00024 
00025 
00031   WorldCanvasClient(const std::string& srv_namespace = "")
00032   {
00033     this->srv_namespace = srv_namespace;
00034     if (this->srv_namespace.size() == 0 || this->srv_namespace.back() != '/')
00035       this->srv_namespace.push_back('/');
00036   }
00037 
00046   template <typename T>
00047   ros::ServiceClient getServiceHandle(const std::string& service_name, double timeout = 5.0)
00048   {
00049     ros::NodeHandle nh;
00050     ros::ServiceClient client = nh.serviceClient<T>(srv_namespace + service_name);
00051     ROS_INFO("Waiting for '%s' service...", service_name.c_str());
00052     if (client.waitForExistence(ros::Duration(timeout)) == false)
00053     {
00054       ROS_ERROR("'%s' service not available after %.2f s", service_name.c_str(), timeout);
00055       throw ros::Exception(service_name + " service not available");
00056     }
00057 
00058     return client;
00059   }
00060 
00061 };
00062 
00063 } // namespace wcf
00064 
00065 #endif /* WORLD_CANVAS_CLIENT_HPP_ */


world_canvas_client_cpp
Author(s): Jorge Santos
autogenerated on Thu Jun 6 2019 18:32:38