Skip to content

Commit ee70d44

Browse files
committed
Merge remote-tracking branch 'ezra/add-typescript' into ros2-actions
2 parents 7f9d34b + 5d3b36a commit ee70d44

File tree

4 files changed

+50
-25
lines changed

4 files changed

+50
-25
lines changed

build/core/Param.d.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,39 @@ declare class Param {
1818
* @callback getCallback
1919
* @param {Object} value - The value of the param from ROS.
2020
*/
21+
/**
22+
* @callback getFailedCallback
23+
* @param {string} error - The error message reported by ROS.
24+
*/
2125
/**
2226
* Fetch the value of the param.
2327
*
24-
* @param {getCallback} callback - Function with the following params:
28+
* @param {getCallback} callback - The callback function.
29+
* @param {getFailedCallback} [failedCallback] - The callback function when the service call failed.
2530
*/
26-
get(callback: (value: any) => any): void;
31+
get(callback: (value: any) => any, failedCallback?: ((error: string) => any) | undefined): void;
2732
/**
2833
* @callback setParamCallback
2934
* @param {Object} response - The response from the service request.
3035
*/
3136
/**
3237
* @callback setParamFailedCallback
33-
* @param {Object} response - The response from the service request.
38+
* @param {string} error - The error message reported by ROS.
3439
*/
3540
/**
3641
* Set the value of the param in ROS.
3742
*
3843
* @param {Object} value - The value to set param to.
3944
* @param {setParamCallback} [callback] - The callback function.
45+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
4046
*/
41-
set(value: any, callback?: ((response: any) => any) | undefined): void;
47+
set(value: any, callback?: ((response: any) => any) | undefined, failedCallback?: ((error: string) => any) | undefined): void;
4248
/**
4349
* Delete this parameter on the ROS server.
4450
*
4551
* @param {setParamCallback} callback - The callback function.
52+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
4653
*/
47-
delete(callback: (response: any) => any): void;
54+
delete(callback: (response: any) => any, failedCallback?: ((error: string) => any) | undefined): void;
4855
}
4956
import Ros = require("../core/Ros");

build/roslib.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20307,12 +20307,17 @@ var Param = /** @class */ (function () {
2030720307
* @callback getCallback
2030820308
* @param {Object} value - The value of the param from ROS.
2030920309
*/
20310+
/**
20311+
* @callback getFailedCallback
20312+
* @param {string} error - The error message reported by ROS.
20313+
*/
2031020314
/**
2031120315
* Fetch the value of the param.
2031220316
*
20313-
* @param {getCallback} callback - Function with the following params:
20317+
* @param {getCallback} callback - The callback function.
20318+
* @param {getFailedCallback} [failedCallback] - The callback function when the service call failed.
2031420319
*/
20315-
Param.prototype.get = function (callback) {
20320+
Param.prototype.get = function (callback, failedCallback) {
2031620321
var paramClient = new Service({
2031720322
ros: this.ros,
2031820323
name: '/rosapi/get_param',
@@ -20324,23 +20329,24 @@ var Param = /** @class */ (function () {
2032420329
paramClient.callService(request, function (result) {
2032520330
var value = JSON.parse(result.value);
2032620331
callback(value);
20327-
});
20332+
}, failedCallback);
2032820333
};
2032920334
/**
2033020335
* @callback setParamCallback
2033120336
* @param {Object} response - The response from the service request.
2033220337
*/
2033320338
/**
2033420339
* @callback setParamFailedCallback
20335-
* @param {Object} response - The response from the service request.
20340+
* @param {string} error - The error message reported by ROS.
2033620341
*/
2033720342
/**
2033820343
* Set the value of the param in ROS.
2033920344
*
2034020345
* @param {Object} value - The value to set param to.
2034120346
* @param {setParamCallback} [callback] - The callback function.
20347+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
2034220348
*/
20343-
Param.prototype.set = function (value, callback) {
20349+
Param.prototype.set = function (value, callback, failedCallback) {
2034420350
var paramClient = new Service({
2034520351
ros: this.ros,
2034620352
name: '/rosapi/set_param',
@@ -20350,14 +20356,15 @@ var Param = /** @class */ (function () {
2035020356
name: this.name,
2035120357
value: JSON.stringify(value)
2035220358
});
20353-
paramClient.callService(request, callback);
20359+
paramClient.callService(request, callback, failedCallback);
2035420360
};
2035520361
/**
2035620362
* Delete this parameter on the ROS server.
2035720363
*
2035820364
* @param {setParamCallback} callback - The callback function.
20365+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
2035920366
*/
20360-
Param.prototype.delete = function (callback) {
20367+
Param.prototype.delete = function (callback, failedCallback) {
2036120368
var paramClient = new Service({
2036220369
ros: this.ros,
2036320370
name: '/rosapi/delete_param',
@@ -20366,7 +20373,7 @@ var Param = /** @class */ (function () {
2036620373
var request = new ServiceRequest({
2036720374
name: this.name
2036820375
});
20369-
paramClient.callService(request, callback);
20376+
paramClient.callService(request, callback, failedCallback);
2037020377
};
2037120378
return Param;
2037220379
}());

build/roslib.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/Param.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ class Param {
2424
* @callback getCallback
2525
* @param {Object} value - The value of the param from ROS.
2626
*/
27+
/**
28+
* @callback getFailedCallback
29+
* @param {string} error - The error message reported by ROS.
30+
*/
2731
/**
2832
* Fetch the value of the param.
2933
*
30-
* @param {getCallback} callback - Function with the following params:
34+
* @param {getCallback} callback - The callback function.
35+
* @param {getFailedCallback} [failedCallback] - The callback function when the service call failed.
3136
*/
32-
get(callback) {
37+
get(callback, failedCallback) {
3338
var paramClient = new Service({
3439
ros: this.ros,
3540
name: '/rosapi/get_param',
@@ -40,26 +45,31 @@ class Param {
4045
name: this.name
4146
});
4247

43-
paramClient.callService(request, function (result) {
44-
var value = JSON.parse(result.value);
45-
callback(value);
46-
});
48+
paramClient.callService(
49+
request,
50+
function (result) {
51+
var value = JSON.parse(result.value);
52+
callback(value);
53+
},
54+
failedCallback
55+
);
4756
}
4857
/**
4958
* @callback setParamCallback
5059
* @param {Object} response - The response from the service request.
5160
*/
5261
/**
5362
* @callback setParamFailedCallback
54-
* @param {Object} response - The response from the service request.
63+
* @param {string} error - The error message reported by ROS.
5564
*/
5665
/**
5766
* Set the value of the param in ROS.
5867
*
5968
* @param {Object} value - The value to set param to.
6069
* @param {setParamCallback} [callback] - The callback function.
70+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
6171
*/
62-
set(value, callback) {
72+
set(value, callback, failedCallback) {
6373
var paramClient = new Service({
6474
ros: this.ros,
6575
name: '/rosapi/set_param',
@@ -71,14 +81,15 @@ class Param {
7181
value: JSON.stringify(value)
7282
});
7383

74-
paramClient.callService(request, callback);
84+
paramClient.callService(request, callback, failedCallback);
7585
}
7686
/**
7787
* Delete this parameter on the ROS server.
7888
*
7989
* @param {setParamCallback} callback - The callback function.
90+
* @param {setParamFailedCallback} [failedCallback] - The callback function when the service call failed.
8091
*/
81-
delete(callback) {
92+
delete(callback, failedCallback) {
8293
var paramClient = new Service({
8394
ros: this.ros,
8495
name: '/rosapi/delete_param',
@@ -89,7 +100,7 @@ class Param {
89100
name: this.name
90101
});
91102

92-
paramClient.callService(request, callback);
103+
paramClient.callService(request, callback, failedCallback);
93104
}
94105
}
95106

0 commit comments

Comments
 (0)