-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathros_service.h
More file actions
59 lines (48 loc) · 2.09 KB
/
ros_service.h
File metadata and controls
59 lines (48 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <list>
#include "rapidjson/document.h"
#include "ros_bridge.h"
#include "types.h"
#include "messages/rosbridge_advertise_service_msg.h"
#include "messages/rosbridge_call_service_msg.h"
#include "messages/rosbridge_unadvertise_service_msg.h"
using json = rapidjson::Document;
namespace rosbridge2cpp{
class ROSService {
public:
// TODO: Implement setter of other options
ROSService (ROSBridge &ros, std::string service_name, std::string service_type) :
ros_(ros), service_name_(service_name), service_type_(service_type){
}
// Advertise a service and define the request handling callback
// The given callback will handle all service requests.
//
// The callback will get the CallService packet from the server and
// a reference to a ServiceResponse packet, that can be filled as desired.
//
// This method will only be used when using rapidjson, since we need to use
// the allocator of rapidjson to avoid copy operations.
void Advertise(FunVrROSCallServiceMsgrROSServiceResponseMsgrAllocator callback);
void Advertise(FunVrROSCallServiceMsgrROSServiceResponseMsg callback);
// Unadvertise an advertised service
// Will do nothing if no service has been advertised before in this instance
void Unadvertise();
// TODO failedCallback parameter
// Call a ROS-Service
// The given callback variable will be called when the service reply
// has been received by ROSBridge. It will passed the received data to the callback.
// The whole content of the "request" parameter will be send as the "args"
// argument of the Service Request
void CallService(rapidjson::Value &request, FunVrROSServiceResponseMsg callback);
void CallService(bson_t *request, FunVrROSServiceResponseMsg callback);
std::string GenerateServiceCallID();
std::string ServiceName(){
return service_name_;
}
private:
ROSBridge &ros_;
std::string service_name_;
std::string service_type_;
bool is_advertised_ = false;
};
}