forked from RobotWebTools/roslibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathService.js.html
98 lines (76 loc) · 3.58 KB
/
Service.js.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: core/Service.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: core/Service.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* @author Brandon Alexander - [email protected]
*/
/**
* A ROS service client.
*
* @constructor
* @params options - possible keys include:
* * ros - the ROSLIB.Ros connection handle
* * name - the service name, like /add_two_ints
* * serviceType - the service type, like 'rospy_tutorials/AddTwoInts'
*/
ROSLIB.Service = function(options) {
options = options || {};
this.ros = options.ros;
this.name = options.name;
this.serviceType = options.serviceType;
};
/**
* Calls the service. Returns the service response in the callback.
*
* @param request - the ROSLIB.ServiceRequest to send
* @param callback - function with params:
* * response - the response from the service request
*/
ROSLIB.Service.prototype.callService = function(request, callback) {
this.ros.idCounter++;
var serviceCallId = 'call_service:' + this.name + ':' + this.ros.idCounter;
this.ros.once(serviceCallId, function(data) {
var response = new ROSLIB.ServiceResponse(data);
callback(response);
});
var requestValues = [];
Object.keys(request).forEach(function(name) {
requestValues.push(request[name]);
});
var call = {
op : 'call_service',
id : serviceCallId,
service : this.name,
args : requestValues
};
this.ros.callOnConnection(call);
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="ROSLIB.ActionClient.html">ActionClient</a></li><li><a href="ROSLIB.Goal.html">Goal</a></li><li><a href="ROSLIB.Message.html">Message</a></li><li><a href="ROSLIB.Param.html">Param</a></li><li><a href="ROSLIB.Pose.html">Pose</a></li><li><a href="ROSLIB.Quaternion.html">Quaternion</a></li><li><a href="ROSLIB.Ros.html">Ros</a></li><li><a href="ROSLIB.Service.html">Service</a></li><li><a href="ROSLIB.ServiceRequest.html">ServiceRequest</a></li><li><a href="ROSLIB.ServiceResponse.html">ServiceResponse</a></li><li><a href="ROSLIB.TFClient.html">TFClient</a></li><li><a href="ROSLIB.Topic.html">Topic</a></li><li><a href="ROSLIB.Transform.html">Transform</a></li><li><a href="ROSLIB.UrdfBox.html">UrdfBox</a></li><li><a href="ROSLIB.UrdfColor.html">UrdfColor</a></li><li><a href="ROSLIB.UrdfCylinder.html">UrdfCylinder</a></li><li><a href="ROSLIB.UrdfLink.html">UrdfLink</a></li><li><a href="ROSLIB.UrdfMaterial.html">UrdfMaterial</a></li><li><a href="ROSLIB.UrdfMesh.html">UrdfMesh</a></li><li><a href="ROSLIB.UrdfModel.html">UrdfModel</a></li><li><a href="ROSLIB.UrdfSphere.html">UrdfSphere</a></li><li><a href="ROSLIB.UrdfVisual.html">UrdfVisual</a></li><li><a href="ROSLIB.Vector3.html">Vector3</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ROSLIB">ROSLIB</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Tue May 07 2013 12:08:51 GMT-0400 (EDT)
</footer>
<script> prettyPrint(); </script>
</body>
</html>