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
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ACTIONLIB_CLIENT_SERVICE_CLIENT_H_
00038 #define ACTIONLIB_CLIENT_SERVICE_CLIENT_H_
00039 #include <actionlib/action_definition.h>
00040 #include <actionlib/client/simple_action_client.h>
00041
00042 namespace actionlib {
00043 class ServiceClientImp {
00044 public:
00045 ServiceClientImp(){}
00046 virtual bool call(const void* goal, std::string goal_md5sum, void* result, std::string result_md5sum) = 0;
00047 virtual bool waitForServer(const ros::Duration& timeout) = 0;
00048 virtual bool isServerConnected() = 0;
00049 virtual ~ServiceClientImp(){}
00050 };
00051
00052 class ServiceClient {
00053 public:
00054 ServiceClient(boost::shared_ptr<ServiceClientImp> client) : client_(client) {}
00055
00056 template <class Goal, class Result>
00057 bool call(const Goal& goal, Result& result);
00058
00059 bool waitForServer(const ros::Duration& timeout = ros::Duration(0,0));
00060 bool isServerConnected();
00061
00062 private:
00063 boost::shared_ptr<ServiceClientImp> client_;
00064 };
00065
00066 template <class ActionSpec>
00067 ServiceClient serviceClient(ros::NodeHandle n, std::string name);
00068
00069 template <class ActionSpec>
00070 class ServiceClientImpT : public ServiceClientImp
00071 {
00072 public:
00073 ACTION_DEFINITION(ActionSpec);
00074 typedef ClientGoalHandle<ActionSpec> GoalHandleT;
00075 typedef SimpleActionClient<ActionSpec> SimpleActionClientT;
00076
00077 ServiceClientImpT(ros::NodeHandle n, std::string name);
00078
00079 bool call(const void* goal, std::string goal_md5sum, void* result, std::string result_md5sum);
00080 bool waitForServer(const ros::Duration& timeout);
00081 bool isServerConnected();
00082
00083 private:
00084 boost::scoped_ptr<SimpleActionClientT> ac_;
00085
00086 };
00087 };
00088
00089
00090 #include <actionlib/client/service_client_imp.h>
00091 #endif