forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roslib.d.ts
423 lines (374 loc) · 12.6 KB
/
roslib.d.ts
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// Type definitions for roslib.js
// Project: http://wiki.ros.org/roslibjs
// Definitions by: Stefan Profanter <https://github.com/Pro/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* ----------------------------------
NOTE: This typescript definition is not yet complete. I should be extended if definitions are missing.
---------------------------------- */
declare namespace ROSLIB {
export class Ros {
/**
* Manages connection to the server and all interactions with ROS.
*
* Emits the following events:
* * 'error' - there was an error with ROS
* * 'connection' - connected to the WebSocket server
* * 'close' - disconnected to the WebSocket server
* * <topicName> - a message came from rosbridge with the given topic name
* * <serviceID> - a service response came from rosbridge with the given ID
*
* @constructor
* @param options - possible keys include:
* * url (optional) - the WebSocket URL for rosbridge (can be specified later with `connect`)
*/
constructor(options:{
url?: string
});
on(eventName:string, callback:(event:any) => void):void;
/**
* Connect to the specified WebSocket.
*
* @param url - WebSocket URL for Rosbridge
*/
connect(url:string):void;
/**
* Disconnect from the WebSocket server.
*/
close():void;
/**
* Sends an authorization request to the server.
*
* @param mac - MAC (hash) string given by the trusted source.
* @param client - IP of the client.
* @param dest - IP of the destination.
* @param rand - Random string given by the trusted source.
* @param t - Time of the authorization request.
* @param level - User level as a string given by the client.
* @param end - End time of the client's session.
*/
authenticate(mac:string, client:string, dest:string, rand:string, t:number, level:string, end:string):void;
/**
* Sends the message over the WebSocket, but queues the message up if not yet
* connected.
*/
callOnConnection(message:any):void;
/**
* Retrieves list of topics in ROS as an array.
*
* @param callback function with params:
* * topics - Array of topic names
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getTopics(callback:(topics:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves Topics in ROS as an array as specific type
*
* @param topicType topic type to find:
* @param callback function with params:
* * topics - Array of topic names
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getTopicsForType(topicType:string, callback:(topics:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves list of active service names in ROS.
*
* @param callback - function with the following params:
* * services - array of service names
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getServices(callback:(services:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves list of services in ROS as an array as specific type
*
* @param serviceType service type to find:
* @param callback function with params:
* * topics - Array of service names
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getServicesForType(serviceType:string, callback:(services:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves list of active node names in ROS.
*
* @param callback - function with the following params:
* * nodes - array of node names
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getNodes(callback:(nodes:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves list of param names from the ROS Parameter Server.
*
* @param callback function with params:
* * params - array of param names.
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getParams(callback:(params:string[]) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves a type of ROS topic.
*
* @param topic name of the topic:
* @param callback - function with params:
* * type - String of the topic type
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getTopicType(topic:string, callback:(type:string) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves a type of ROS service.
*
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getServiceType(service:string, callback:(type:string) => void, failedCallback?:(error:any)=>void):void;
/**
* Retrieves a detail of ROS message.
*
* @param callback - function with params:
* * details - Array of the message detail
* @param message - String of a topic type
* @param failedCallback - the callback function when the ros call failed (optional). Params:
* * error - the error message reported by ROS
*/
getMessageDetails(message:Message, callback:(detail:any) => void, failedCallback?:(error:any)=>void):void;
/**
* Decode a typedefs into a dictionary like `rosmsg show foo/bar`
*
* @param defs - array of type_def dictionary
*/
decodeTypeDefs(defs:any):void;
}
export class Message {
/**
* Message objects are used for publishing and subscribing to and from topics.
*
* @constructor
* @param values - object matching the fields defined in the .msg definition file
*/
constructor(values:any);
}
export class Param {
/**
* A ROS parameter.
*
* @constructor
* @param options - possible keys include:
* * ros - the ROSLIB.Ros connection handle
* * name - the param name, like max_vel_x
*/
constructor(options:{
ros: Ros,
name: string
});
/**
* Fetches the value of the param.
*
* @param callback - function with the following params:
* * value - the value of the param from ROS.
*/
get(callback:(response:any) => void):void;
/**
* Sets the value of the param in ROS.
*
* @param value - value to set param to.
* @param callback - function with params:
* * response - the response from the service request
*/
set(value:any, callback?:(response:any) => void):void;
/**
* Delete this parameter on the ROS server.
*/
delete(callback:(response:any) => void):void;
}
export class Service {
/**
* 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'
*/
constructor(data:{
ros: Ros,
name: string,
serviceType: string
});
// getter
public name:string;
// getter
public serviceType:string;
/**
* 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
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
callService(request:ServiceRequest, callback:(response:any) => void, failedCallback?:(error:any) => void):void;
/**
* Advertise this service and call the callback each time a client calls it.
*
* @param callback - function with the following params:
* * request - the service request data
* * response - the data which should be sent back to the caller
*/
advertise(callback:(request:any, response:any) => void):void;
/**
* Unadvertise a previously advertised service
*/
unadvertise():void;
}
export class ServiceRequest {
/**
* A ServiceRequest is passed into the service call.
*
* @constructor
* @param values - object matching the fields defined in the .srv definition file
*/
constructor(values?:any);
}
export class ServiceResponse {
/**
* A ServiceResponse is returned from the service call.
*
* @constructor
* @param values - object matching the fields defined in the .srv definition file
*/
constructor(values?:any);
}
export class Topic {
/**
* Publish and/or subscribe to a topic in ROS.
*
* Emits the following events:
* * 'warning' - if there are any warning during the Topic creation
* * 'message' - the message data from rosbridge
*
* @constructor
* @param options - object with following keys:
* * ros - the ROSLIB.Ros connection handle
* * name - the topic name, like /cmd_vel
* * messageType - the message type, like 'std_msgs/String'
* * compression - the type of compression to use, like 'png'
* * throttle_rate - the rate (in ms in between messages) at which to throttle the topics
* * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100)
* * latch - latch the topic when publishing
* * queue_length - the queue length at bridge side used when subscribing (defaults to 0, no queueing).
*/
constructor(options:{
ros: Ros,
name: string,
messageType: string,
compression?: string,
throttle_rate?: number,
queue_size?: number,
latch?: number,
queue_length?: number
});
// getter
public name:string;
// getter
public messageType:string;
/**
* Every time a message is published for the given topic, the callback
* will be called with the message object.
*
* @param callback - function with the following params:
* * message - the published message
*/
subscribe(callback:(message:Message) => void):void;
/**
* Unregisters as a subscriber for the topic. Unsubscribing stop remove
* all subscribe callbacks. To remove a call back, you must explicitly
* pass the callback function in.
*
* @param callback - the optional callback to unregister, if
* * provided and other listeners are registered the topic won't
* * unsubscribe, just stop emitting to the passed listener
*/
unsubscribe(callback?:() => void):void;
/**
* Registers as a publisher for the topic.
*/
advertise():void;
/**
* Unregisters as a publisher for the topic.
*/
unadvertise():void;
/**
* Publish the message.
*
* @param message - A ROSLIB.Message object.
*/
publish(message:Message):void;
}
class ActionClient {
/**
* An actionlib action client.
*
* Emits the following events:
* * 'timeout' - if a timeout occurred while sending a goal
* * 'status' - the status messages received from the action server
* * 'feedback' - the feedback messages received from the action server
* * 'result' - the result returned from the action server
*
* @constructor
* @param options - object with following keys:
* * ros - the ROSLIB.Ros connection handle
* * serverName - the action server name, like /fibonacci
* * actionName - the action message name, like 'actionlib_tutorials/FibonacciAction'
* * timeout - the timeout length when connecting to the action server
*/
constructor(options:{
ros: Ros,
serverName: string,
actionName: string,
timeout: number
});
/**
* Cancel all goals associated with this ActionClient.
*/
cancel():void;
}
class Goal {
/**
* An actionlib goal goal is associated with an action server.
*
* Emits the following events:
* * 'timeout' - if a timeout occurred while sending a goal
*
* @constructor
* @param options with following keys:
* * actionClient - the ROSLIB.ActionClient to use with this goal
* * goalMessage - The JSON object containing the goal for the action server
*/
constructor(options:{
actionClient: ActionClient,
goalMessage: any
});
/**
* Send the goal to the action server.
*
* @param timeout (optional) - a timeout length for the goal's result
*/
send(timeout?:number):void;
/**
* Cancel the current goal.
*/
cancel():void;
}
}
declare module "ROSLIB" {
export = ROSLIB;
}