rclnodejs 0.33.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/binding.gyp +17 -2
- package/lib/client.js +2 -3
- package/lib/context.js +8 -0
- package/lib/logging.js +26 -9
- package/lib/node.js +53 -0
- package/lib/publisher.js +8 -0
- package/lib/service.js +9 -2
- package/lib/subscription.js +8 -0
- package/lib/timer.js +32 -0
- package/package.json +4 -4
- package/scripts/config.js +1 -0
- package/scripts/npmjs-readme.md +3 -3
- package/src/addon.cpp +54 -53
- package/src/executor.cpp +19 -10
- package/src/{executor.hpp → executor.h} +7 -5
- package/src/handle_manager.cpp +30 -56
- package/src/{handle_manager.hpp → handle_manager.h} +8 -7
- package/src/{macros.hpp → macros.h} +7 -5
- package/src/rcl_action_client_bindings.cpp +231 -0
- package/src/{rcl_action_bindings.hpp → rcl_action_client_bindings.h} +6 -11
- package/src/rcl_action_goal_bindings.cpp +117 -0
- package/src/rcl_action_goal_bindings.h +26 -0
- package/src/rcl_action_server_bindings.cpp +470 -0
- package/src/rcl_action_server_bindings.h +26 -0
- package/src/rcl_bindings.cpp +42 -2010
- package/src/{rcl_bindings.hpp → rcl_bindings.h} +5 -25
- package/src/rcl_client_bindings.cpp +183 -0
- package/src/rcl_client_bindings.h +26 -0
- package/src/rcl_context_bindings.cpp +156 -0
- package/src/rcl_context_bindings.h +26 -0
- package/src/rcl_graph_bindings.cpp +280 -0
- package/src/rcl_graph_bindings.h +26 -0
- package/src/rcl_guard_condition_bindings.cpp +75 -0
- package/src/rcl_guard_condition_bindings.h +26 -0
- package/src/rcl_handle.cpp +41 -57
- package/src/{rcl_handle.hpp → rcl_handle.h} +18 -17
- package/src/rcl_lifecycle_bindings.cpp +135 -114
- package/src/{rcl_lifecycle_bindings.hpp → rcl_lifecycle_bindings.h} +5 -7
- package/src/rcl_logging_bindings.cpp +96 -0
- package/src/rcl_logging_bindings.h +26 -0
- package/src/rcl_names_bindings.cpp +255 -0
- package/src/rcl_names_bindings.h +26 -0
- package/src/rcl_node_bindings.cpp +447 -0
- package/src/rcl_node_bindings.h +26 -0
- package/src/rcl_publisher_bindings.cpp +141 -0
- package/src/rcl_publisher_bindings.h +26 -0
- package/src/rcl_service_bindings.cpp +185 -0
- package/src/rcl_service_bindings.h +26 -0
- package/src/rcl_subscription_bindings.cpp +335 -0
- package/src/rcl_subscription_bindings.h +26 -0
- package/src/rcl_time_point_bindings.cpp +194 -0
- package/src/rcl_time_point_bindings.h +26 -0
- package/src/rcl_timer_bindings.cpp +237 -0
- package/src/rcl_timer_bindings.h +26 -0
- package/src/rcl_utilities.cpp +166 -1
- package/src/{rcl_utilities.hpp → rcl_utilities.h} +21 -3
- package/src/shadow_node.cpp +56 -75
- package/src/{shadow_node.hpp → shadow_node.h} +18 -17
- package/types/context.d.ts +6 -0
- package/types/node.d.ts +37 -0
- package/types/publisher.d.ts +6 -0
- package/types/service.d.ts +6 -0
- package/types/subscription.d.ts +6 -0
- package/types/timer.d.ts +18 -0
- package/src/rcl_action_bindings.cpp +0 -826
|
@@ -1,826 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2020 Matt Richard. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
#include "rcl_action_bindings.hpp"
|
|
16
|
-
|
|
17
|
-
#include <rcl/error_handling.h>
|
|
18
|
-
#include <rcl/graph.h>
|
|
19
|
-
#include <rcl/rcl.h>
|
|
20
|
-
#include <rcl_action/rcl_action.h>
|
|
21
|
-
#include <rmw/error_handling.h>
|
|
22
|
-
|
|
23
|
-
#include <memory>
|
|
24
|
-
#include <string>
|
|
25
|
-
#include <vector>
|
|
26
|
-
|
|
27
|
-
#include "handle_manager.hpp"
|
|
28
|
-
#include "macros.hpp"
|
|
29
|
-
#include "rcl_handle.hpp"
|
|
30
|
-
#include "rcl_utilities.hpp"
|
|
31
|
-
|
|
32
|
-
namespace rclnodejs {
|
|
33
|
-
|
|
34
|
-
NAN_METHOD(ActionCreateClient) {
|
|
35
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
36
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
37
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
38
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
39
|
-
std::string action_name(
|
|
40
|
-
*Nan::Utf8String(info[1]->ToString(currentContent).ToLocalChecked()));
|
|
41
|
-
std::string interface_name(
|
|
42
|
-
*Nan::Utf8String(info[2]->ToString(currentContent).ToLocalChecked()));
|
|
43
|
-
std::string package_name(
|
|
44
|
-
*Nan::Utf8String(info[3]->ToString(currentContent).ToLocalChecked()));
|
|
45
|
-
|
|
46
|
-
const rosidl_action_type_support_t* ts =
|
|
47
|
-
GetActionTypeSupport(package_name, interface_name);
|
|
48
|
-
|
|
49
|
-
if (ts) {
|
|
50
|
-
rcl_action_client_options_t action_client_ops =
|
|
51
|
-
rcl_action_client_get_default_options();
|
|
52
|
-
|
|
53
|
-
auto goal_service_qos = GetQoSProfile(info[4]);
|
|
54
|
-
auto result_service_qos = GetQoSProfile(info[5]);
|
|
55
|
-
auto cancel_service_qos = GetQoSProfile(info[6]);
|
|
56
|
-
auto feedback_topic_qos = GetQoSProfile(info[7]);
|
|
57
|
-
auto status_topic_qos = GetQoSProfile(info[8]);
|
|
58
|
-
|
|
59
|
-
if (goal_service_qos) {
|
|
60
|
-
action_client_ops.goal_service_qos = *goal_service_qos;
|
|
61
|
-
}
|
|
62
|
-
if (result_service_qos) {
|
|
63
|
-
action_client_ops.result_service_qos = *result_service_qos;
|
|
64
|
-
}
|
|
65
|
-
if (cancel_service_qos) {
|
|
66
|
-
action_client_ops.cancel_service_qos = *cancel_service_qos;
|
|
67
|
-
}
|
|
68
|
-
if (feedback_topic_qos) {
|
|
69
|
-
action_client_ops.feedback_topic_qos = *feedback_topic_qos;
|
|
70
|
-
}
|
|
71
|
-
if (status_topic_qos) {
|
|
72
|
-
action_client_ops.status_topic_qos = *status_topic_qos;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
rcl_action_client_t* action_client = reinterpret_cast<rcl_action_client_t*>(
|
|
76
|
-
malloc(sizeof(rcl_action_client_t)));
|
|
77
|
-
*action_client = rcl_action_get_zero_initialized_client();
|
|
78
|
-
|
|
79
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
80
|
-
rcl_action_client_init(action_client, node, ts, action_name.c_str(),
|
|
81
|
-
&action_client_ops),
|
|
82
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
83
|
-
auto js_obj =
|
|
84
|
-
RclHandle::NewInstance(action_client, node_handle, [node](void* ptr) {
|
|
85
|
-
rcl_action_client_t* action_client =
|
|
86
|
-
reinterpret_cast<rcl_action_client_t*>(ptr);
|
|
87
|
-
rcl_ret_t ret = rcl_action_client_fini(action_client, node);
|
|
88
|
-
free(ptr);
|
|
89
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK, ret, rcl_get_error_string().str);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
info.GetReturnValue().Set(js_obj);
|
|
93
|
-
} else {
|
|
94
|
-
Nan::ThrowError(GetErrorMessageAndClear().c_str());
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
NAN_METHOD(ActionCreateServer) {
|
|
99
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
100
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
101
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
102
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
103
|
-
RclHandle* clock_handle = RclHandle::Unwrap<RclHandle>(
|
|
104
|
-
Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
105
|
-
rcl_clock_t* clock = reinterpret_cast<rcl_clock_t*>(clock_handle->ptr());
|
|
106
|
-
std::string action_name(
|
|
107
|
-
*Nan::Utf8String(info[2]->ToString(currentContent).ToLocalChecked()));
|
|
108
|
-
std::string interface_name(
|
|
109
|
-
*Nan::Utf8String(info[3]->ToString(currentContent).ToLocalChecked()));
|
|
110
|
-
std::string package_name(
|
|
111
|
-
*Nan::Utf8String(info[4]->ToString(currentContent).ToLocalChecked()));
|
|
112
|
-
int64_t result_timeout = info[10]->IntegerValue(currentContent).FromJust();
|
|
113
|
-
|
|
114
|
-
const rosidl_action_type_support_t* ts =
|
|
115
|
-
GetActionTypeSupport(package_name, interface_name);
|
|
116
|
-
|
|
117
|
-
if (ts) {
|
|
118
|
-
rcl_action_server_options_t action_server_ops =
|
|
119
|
-
rcl_action_server_get_default_options();
|
|
120
|
-
|
|
121
|
-
auto goal_service_qos = GetQoSProfile(info[5]);
|
|
122
|
-
auto result_service_qos = GetQoSProfile(info[6]);
|
|
123
|
-
auto cancel_service_qos = GetQoSProfile(info[7]);
|
|
124
|
-
auto feedback_topic_qos = GetQoSProfile(info[8]);
|
|
125
|
-
auto status_topic_qos = GetQoSProfile(info[9]);
|
|
126
|
-
|
|
127
|
-
if (goal_service_qos) {
|
|
128
|
-
action_server_ops.goal_service_qos = *goal_service_qos;
|
|
129
|
-
}
|
|
130
|
-
if (result_service_qos) {
|
|
131
|
-
action_server_ops.result_service_qos = *result_service_qos;
|
|
132
|
-
}
|
|
133
|
-
if (cancel_service_qos) {
|
|
134
|
-
action_server_ops.cancel_service_qos = *cancel_service_qos;
|
|
135
|
-
}
|
|
136
|
-
if (feedback_topic_qos) {
|
|
137
|
-
action_server_ops.feedback_topic_qos = *feedback_topic_qos;
|
|
138
|
-
}
|
|
139
|
-
if (status_topic_qos) {
|
|
140
|
-
action_server_ops.status_topic_qos = *status_topic_qos;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
action_server_ops.result_timeout.nanoseconds =
|
|
144
|
-
static_cast<rcl_duration_value_t>(RCL_S_TO_NS(result_timeout));
|
|
145
|
-
|
|
146
|
-
rcl_action_server_t* action_server = reinterpret_cast<rcl_action_server_t*>(
|
|
147
|
-
malloc(sizeof(rcl_action_server_t)));
|
|
148
|
-
*action_server = rcl_action_get_zero_initialized_server();
|
|
149
|
-
|
|
150
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
151
|
-
rcl_action_server_init(action_server, node, clock, ts,
|
|
152
|
-
action_name.c_str(), &action_server_ops),
|
|
153
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
154
|
-
auto js_obj =
|
|
155
|
-
RclHandle::NewInstance(action_server, node_handle, [node](void* ptr) {
|
|
156
|
-
rcl_action_server_t* action_server =
|
|
157
|
-
reinterpret_cast<rcl_action_server_t*>(ptr);
|
|
158
|
-
rcl_ret_t ret = rcl_action_server_fini(action_server, node);
|
|
159
|
-
free(ptr);
|
|
160
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK, ret, rcl_get_error_string().str);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
info.GetReturnValue().Set(js_obj);
|
|
164
|
-
} else {
|
|
165
|
-
Nan::ThrowError(GetErrorMessageAndClear().c_str());
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
NAN_METHOD(ActionServerIsAvailable) {
|
|
170
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
171
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
172
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
173
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
174
|
-
Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
175
|
-
rcl_action_client_t* action_client =
|
|
176
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
177
|
-
|
|
178
|
-
bool is_available;
|
|
179
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
180
|
-
RCL_RET_OK,
|
|
181
|
-
rcl_action_server_is_available(node, action_client, &is_available),
|
|
182
|
-
rcl_get_error_string().str);
|
|
183
|
-
|
|
184
|
-
v8::Local<v8::Boolean> result = Nan::New<v8::Boolean>(is_available);
|
|
185
|
-
info.GetReturnValue().Set(result);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
NAN_METHOD(ActionSendGoalRequest) {
|
|
189
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
190
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
191
|
-
rcl_action_client_t* action_client =
|
|
192
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
193
|
-
void* buffer =
|
|
194
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
195
|
-
|
|
196
|
-
int64_t sequence_number;
|
|
197
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
198
|
-
rcl_action_send_goal_request(action_client, buffer, &sequence_number),
|
|
199
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
200
|
-
|
|
201
|
-
v8::Local<v8::Integer> result =
|
|
202
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
203
|
-
info.GetReturnValue().Set(result);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
NAN_METHOD(ActionTakeGoalRequest) {
|
|
207
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
208
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
209
|
-
rcl_action_server_t* action_server =
|
|
210
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
211
|
-
rmw_request_id_t* header =
|
|
212
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
213
|
-
|
|
214
|
-
void* taken_request =
|
|
215
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
216
|
-
rcl_ret_t ret =
|
|
217
|
-
rcl_action_take_goal_request(action_server, header, taken_request);
|
|
218
|
-
if (ret != RCL_RET_ACTION_SERVER_TAKE_FAILED) {
|
|
219
|
-
auto js_obj =
|
|
220
|
-
RclHandle::NewInstance(header, nullptr, [](void* ptr) { free(ptr); });
|
|
221
|
-
info.GetReturnValue().Set(js_obj);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
NAN_METHOD(ActionSendGoalResponse) {
|
|
229
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
230
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
231
|
-
rcl_action_server_t* action_server =
|
|
232
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
233
|
-
rmw_request_id_t* header = reinterpret_cast<rmw_request_id_t*>(
|
|
234
|
-
RclHandle::Unwrap<RclHandle>(
|
|
235
|
-
Nan::To<v8::Object>(info[1]).ToLocalChecked())
|
|
236
|
-
->ptr());
|
|
237
|
-
void* buffer =
|
|
238
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked());
|
|
239
|
-
|
|
240
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
241
|
-
rcl_action_send_goal_response(action_server, header, buffer), RCL_RET_OK,
|
|
242
|
-
rcl_get_error_string().str);
|
|
243
|
-
|
|
244
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
NAN_METHOD(ActionTakeGoalResponse) {
|
|
248
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
249
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
250
|
-
rcl_action_client_t* action_client =
|
|
251
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
252
|
-
void* buffer =
|
|
253
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
254
|
-
rmw_request_id_t* header =
|
|
255
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
256
|
-
|
|
257
|
-
rcl_ret_t ret = rcl_action_take_goal_response(action_client, header, buffer);
|
|
258
|
-
int64_t sequence_number = header->sequence_number;
|
|
259
|
-
free(header);
|
|
260
|
-
|
|
261
|
-
if (ret != RCL_RET_OK && ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
262
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
263
|
-
rcl_reset_error();
|
|
264
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
269
|
-
v8::Local<v8::Integer> result =
|
|
270
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
271
|
-
info.GetReturnValue().Set(result);
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
NAN_METHOD(ActionSendCancelRequest) {
|
|
278
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
279
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
280
|
-
rcl_action_client_t* action_client =
|
|
281
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
282
|
-
void* buffer =
|
|
283
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
284
|
-
|
|
285
|
-
int64_t sequence_number;
|
|
286
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
287
|
-
rcl_action_send_cancel_request(action_client, buffer, &sequence_number),
|
|
288
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
289
|
-
|
|
290
|
-
v8::Local<v8::Integer> result =
|
|
291
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
292
|
-
info.GetReturnValue().Set(result);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
NAN_METHOD(ActionTakeCancelRequest) {
|
|
296
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
297
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
298
|
-
rcl_action_server_t* action_server =
|
|
299
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
300
|
-
rmw_request_id_t* header =
|
|
301
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
302
|
-
|
|
303
|
-
void* taken_request =
|
|
304
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
305
|
-
rcl_ret_t ret =
|
|
306
|
-
rcl_action_take_cancel_request(action_server, header, taken_request);
|
|
307
|
-
if (ret != RCL_RET_ACTION_SERVER_TAKE_FAILED) {
|
|
308
|
-
auto js_obj =
|
|
309
|
-
RclHandle::NewInstance(header, nullptr, [](void* ptr) { free(ptr); });
|
|
310
|
-
info.GetReturnValue().Set(js_obj);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
NAN_METHOD(ActionSendCancelResponse) {
|
|
318
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
319
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
320
|
-
rcl_action_server_t* action_server =
|
|
321
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
322
|
-
rmw_request_id_t* header = reinterpret_cast<rmw_request_id_t*>(
|
|
323
|
-
RclHandle::Unwrap<RclHandle>(
|
|
324
|
-
Nan::To<v8::Object>(info[1]).ToLocalChecked())
|
|
325
|
-
->ptr());
|
|
326
|
-
void* buffer =
|
|
327
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked());
|
|
328
|
-
|
|
329
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
330
|
-
rcl_action_send_cancel_response(action_server, header, buffer),
|
|
331
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
332
|
-
|
|
333
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
NAN_METHOD(ActionTakeCancelResponse) {
|
|
337
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
338
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
339
|
-
rcl_action_client_t* action_client =
|
|
340
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
341
|
-
void* buffer =
|
|
342
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
343
|
-
rmw_request_id_t* header =
|
|
344
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
345
|
-
|
|
346
|
-
rcl_ret_t ret =
|
|
347
|
-
rcl_action_take_cancel_response(action_client, header, buffer);
|
|
348
|
-
int64_t sequence_number = header->sequence_number;
|
|
349
|
-
free(header);
|
|
350
|
-
|
|
351
|
-
if (ret != RCL_RET_OK && ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
352
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
353
|
-
rcl_reset_error();
|
|
354
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
359
|
-
v8::Local<v8::Integer> result =
|
|
360
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
361
|
-
info.GetReturnValue().Set(result);
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
NAN_METHOD(ActionSendResultRequest) {
|
|
368
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
369
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
370
|
-
rcl_action_client_t* action_client =
|
|
371
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
372
|
-
void* buffer =
|
|
373
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
374
|
-
|
|
375
|
-
int64_t sequence_number;
|
|
376
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
377
|
-
rcl_action_send_result_request(action_client, buffer, &sequence_number),
|
|
378
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
379
|
-
|
|
380
|
-
v8::Local<v8::Integer> result =
|
|
381
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
382
|
-
info.GetReturnValue().Set(result);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
NAN_METHOD(ActionTakeResultRequest) {
|
|
386
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
387
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
388
|
-
rcl_action_server_t* action_server =
|
|
389
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
390
|
-
|
|
391
|
-
rmw_request_id_t* header =
|
|
392
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
393
|
-
|
|
394
|
-
void* taken_request =
|
|
395
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
396
|
-
rcl_ret_t ret =
|
|
397
|
-
rcl_action_take_result_request(action_server, header, taken_request);
|
|
398
|
-
if (ret != RCL_RET_ACTION_SERVER_TAKE_FAILED) {
|
|
399
|
-
auto js_obj =
|
|
400
|
-
RclHandle::NewInstance(header, nullptr, [](void* ptr) { free(ptr); });
|
|
401
|
-
info.GetReturnValue().Set(js_obj);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
NAN_METHOD(ActionSendResultResponse) {
|
|
409
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
410
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
411
|
-
rcl_action_server_t* action_server =
|
|
412
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
413
|
-
rmw_request_id_t* header = reinterpret_cast<rmw_request_id_t*>(
|
|
414
|
-
RclHandle::Unwrap<RclHandle>(
|
|
415
|
-
Nan::To<v8::Object>(info[1]).ToLocalChecked())
|
|
416
|
-
->ptr());
|
|
417
|
-
void* buffer =
|
|
418
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked());
|
|
419
|
-
|
|
420
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
421
|
-
rcl_action_send_result_response(action_server, header, buffer),
|
|
422
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
423
|
-
|
|
424
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
NAN_METHOD(ActionTakeResultResponse) {
|
|
428
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
429
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
430
|
-
rcl_action_client_t* action_client =
|
|
431
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
432
|
-
void* buffer =
|
|
433
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
434
|
-
rmw_request_id_t* header =
|
|
435
|
-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
|
|
436
|
-
|
|
437
|
-
rcl_ret_t ret =
|
|
438
|
-
rcl_action_take_result_response(action_client, header, buffer);
|
|
439
|
-
int64_t sequence_number = header->sequence_number;
|
|
440
|
-
free(header);
|
|
441
|
-
|
|
442
|
-
if (ret != RCL_RET_OK && ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
443
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
444
|
-
rcl_reset_error();
|
|
445
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
450
|
-
v8::Local<v8::Integer> result =
|
|
451
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(sequence_number));
|
|
452
|
-
info.GetReturnValue().Set(result);
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
NAN_METHOD(ActionAcceptNewGoal) {
|
|
459
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
460
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
461
|
-
rcl_action_server_t* action_server =
|
|
462
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
463
|
-
rcl_action_goal_info_t* buffer = reinterpret_cast<rcl_action_goal_info_t*>(
|
|
464
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked()));
|
|
465
|
-
|
|
466
|
-
rcl_action_goal_handle_t* goal_handle =
|
|
467
|
-
reinterpret_cast<rcl_action_goal_handle_t*>(
|
|
468
|
-
malloc(sizeof(rcl_action_goal_handle_t)));
|
|
469
|
-
|
|
470
|
-
*goal_handle = *rcl_action_accept_new_goal(action_server, buffer);
|
|
471
|
-
if (!goal_handle) {
|
|
472
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
473
|
-
rcl_reset_error();
|
|
474
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
auto js_obj = RclHandle::NewInstance(goal_handle, nullptr, [](void* ptr) {
|
|
479
|
-
rcl_action_goal_handle_t* goal_handle =
|
|
480
|
-
reinterpret_cast<rcl_action_goal_handle_t*>(ptr);
|
|
481
|
-
rcl_ret_t ret = rcl_action_goal_handle_fini(goal_handle);
|
|
482
|
-
free(ptr);
|
|
483
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK, ret, rcl_get_error_string().str);
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
info.GetReturnValue().Set(js_obj);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
NAN_METHOD(ActionUpdateGoalState) {
|
|
490
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
491
|
-
RclHandle* goal_handle_handle = RclHandle::Unwrap<RclHandle>(
|
|
492
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
493
|
-
rcl_action_goal_handle_t* goal_handle =
|
|
494
|
-
reinterpret_cast<rcl_action_goal_handle_t*>(goal_handle_handle->ptr());
|
|
495
|
-
rcl_action_goal_event_t event = static_cast<rcl_action_goal_event_t>(
|
|
496
|
-
info[1]->IntegerValue(currentContent).FromJust());
|
|
497
|
-
|
|
498
|
-
THROW_ERROR_IF_NOT_EQUAL(rcl_action_update_goal_state(goal_handle, event),
|
|
499
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
500
|
-
|
|
501
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
NAN_METHOD(ActionPublishStatus) {
|
|
505
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
506
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
507
|
-
rcl_action_server_t* action_server =
|
|
508
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
509
|
-
|
|
510
|
-
rcl_action_goal_status_array_t status_message =
|
|
511
|
-
rcl_action_get_zero_initialized_goal_status_array();
|
|
512
|
-
|
|
513
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
514
|
-
rcl_action_get_goal_status_array(action_server, &status_message),
|
|
515
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
516
|
-
|
|
517
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
518
|
-
rcl_action_publish_status(action_server, &status_message), RCL_RET_OK,
|
|
519
|
-
rcl_get_error_string().str);
|
|
520
|
-
|
|
521
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
NAN_METHOD(ActionTakeStatus) {
|
|
525
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
526
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
527
|
-
rcl_action_client_t* action_client =
|
|
528
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
529
|
-
void* buffer =
|
|
530
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
531
|
-
|
|
532
|
-
rcl_ret_t ret = rcl_action_take_status(action_client, buffer);
|
|
533
|
-
if (ret != RCL_RET_OK && ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
534
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
535
|
-
rcl_reset_error();
|
|
536
|
-
info.GetReturnValue().Set(Nan::False());
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
if (ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
541
|
-
info.GetReturnValue().Set(Nan::True());
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
NAN_METHOD(ActionGoalHandleIsActive) {
|
|
548
|
-
RclHandle* goal_handle_handle = RclHandle::Unwrap<RclHandle>(
|
|
549
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
550
|
-
rcl_action_goal_handle_t* goal_handle =
|
|
551
|
-
reinterpret_cast<rcl_action_goal_handle_t*>(goal_handle_handle->ptr());
|
|
552
|
-
|
|
553
|
-
bool is_active = rcl_action_goal_handle_is_active(goal_handle);
|
|
554
|
-
|
|
555
|
-
v8::Local<v8::Boolean> result = Nan::New<v8::Boolean>(is_active);
|
|
556
|
-
info.GetReturnValue().Set(result);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
NAN_METHOD(ActionNotifyGoalDone) {
|
|
560
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
561
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
562
|
-
rcl_action_server_t* action_server =
|
|
563
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
564
|
-
|
|
565
|
-
THROW_ERROR_IF_NOT_EQUAL(rcl_action_notify_goal_done(action_server),
|
|
566
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
567
|
-
|
|
568
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
NAN_METHOD(ActionGoalHandleGetStatus) {
|
|
572
|
-
RclHandle* goal_handle_handle = RclHandle::Unwrap<RclHandle>(
|
|
573
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
574
|
-
rcl_action_goal_handle_t* goal_handle =
|
|
575
|
-
reinterpret_cast<rcl_action_goal_handle_t*>(goal_handle_handle->ptr());
|
|
576
|
-
|
|
577
|
-
rcl_action_goal_state_t status;
|
|
578
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
579
|
-
rcl_action_goal_handle_get_status(goal_handle, &status), RCL_RET_OK,
|
|
580
|
-
rcl_get_error_string().str);
|
|
581
|
-
|
|
582
|
-
v8::Local<v8::Integer> result =
|
|
583
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(status));
|
|
584
|
-
info.GetReturnValue().Set(result);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
NAN_METHOD(ActionPublishFeedback) {
|
|
588
|
-
rcl_action_server_t* action_server = reinterpret_cast<rcl_action_server_t*>(
|
|
589
|
-
RclHandle::Unwrap<RclHandle>(
|
|
590
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
591
|
-
->ptr());
|
|
592
|
-
void* buffer =
|
|
593
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
594
|
-
|
|
595
|
-
THROW_ERROR_IF_NOT_EQUAL(rcl_action_publish_feedback(action_server, buffer),
|
|
596
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
597
|
-
|
|
598
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
NAN_METHOD(ActionTakeFeedback) {
|
|
602
|
-
RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
|
|
603
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
604
|
-
rcl_action_client_t* action_client =
|
|
605
|
-
reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr());
|
|
606
|
-
void* buffer =
|
|
607
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
608
|
-
|
|
609
|
-
rcl_ret_t ret = rcl_action_take_feedback(action_client, buffer);
|
|
610
|
-
if (ret != RCL_RET_OK && ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
611
|
-
Nan::ThrowError(rcl_get_error_string().str);
|
|
612
|
-
rcl_reset_error();
|
|
613
|
-
info.GetReturnValue().Set(Nan::False());
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (ret != RCL_RET_ACTION_CLIENT_TAKE_FAILED) {
|
|
618
|
-
info.GetReturnValue().Set(Nan::True());
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
NAN_METHOD(ActionProcessCancelRequest) {
|
|
625
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
626
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
627
|
-
rcl_action_server_t* action_server =
|
|
628
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
629
|
-
void* buffer =
|
|
630
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
|
|
631
|
-
rcl_action_cancel_request_t* cancel_request =
|
|
632
|
-
reinterpret_cast<rcl_action_cancel_request_t*>(buffer);
|
|
633
|
-
void* response_buffer =
|
|
634
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked());
|
|
635
|
-
action_msgs__srv__CancelGoal_Response* response =
|
|
636
|
-
reinterpret_cast<action_msgs__srv__CancelGoal_Response*>(response_buffer);
|
|
637
|
-
|
|
638
|
-
rcl_action_cancel_response_t* cancel_response_ptr =
|
|
639
|
-
reinterpret_cast<rcl_action_cancel_response_t*>(
|
|
640
|
-
malloc(sizeof(rcl_action_cancel_response_t)));
|
|
641
|
-
|
|
642
|
-
*cancel_response_ptr = rcl_action_get_zero_initialized_cancel_response();
|
|
643
|
-
|
|
644
|
-
rcl_ret_t ret = rcl_action_process_cancel_request(
|
|
645
|
-
action_server, cancel_request, cancel_response_ptr);
|
|
646
|
-
if (ret != RCL_RET_OK) {
|
|
647
|
-
// fetch the error triggered by rcl_action_process_cancel_request
|
|
648
|
-
rcutils_error_string_t cancel_error = rcl_get_error_string();
|
|
649
|
-
rcl_reset_error();
|
|
650
|
-
rcl_ret_t ret_fini = rcl_action_cancel_response_fini(cancel_response_ptr);
|
|
651
|
-
if (ret_fini != RCL_RET_OK) {
|
|
652
|
-
RCUTILS_LOG_WARN_NAMED(
|
|
653
|
-
PACKAGE_NAME,
|
|
654
|
-
"There was an error finalizing the action cancel response: %s",
|
|
655
|
-
rcl_get_error_string().str);
|
|
656
|
-
rcl_reset_error();
|
|
657
|
-
}
|
|
658
|
-
free(cancel_response_ptr);
|
|
659
|
-
Nan::ThrowError(cancel_error.str);
|
|
660
|
-
info.GetReturnValue().Set(Nan::Undefined());
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
*response = cancel_response_ptr->msg;
|
|
665
|
-
auto js_obj =
|
|
666
|
-
RclHandle::NewInstance(cancel_response_ptr, nullptr, [](void* ptr) {
|
|
667
|
-
rcl_action_cancel_response_t* cancel_response_ptr =
|
|
668
|
-
reinterpret_cast<rcl_action_cancel_response_t*>(ptr);
|
|
669
|
-
rcl_ret_t ret = rcl_action_cancel_response_fini(cancel_response_ptr);
|
|
670
|
-
free(ptr);
|
|
671
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK, ret, rcl_get_error_string().str);
|
|
672
|
-
});
|
|
673
|
-
info.GetReturnValue().Set(js_obj);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
NAN_METHOD(ActionServerGoalExists) {
|
|
677
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
678
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
679
|
-
rcl_action_server_t* action_server =
|
|
680
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
681
|
-
rcl_action_goal_info_t* buffer = reinterpret_cast<rcl_action_goal_info_t*>(
|
|
682
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked()));
|
|
683
|
-
|
|
684
|
-
bool exists = rcl_action_server_goal_exists(action_server, buffer);
|
|
685
|
-
|
|
686
|
-
v8::Local<v8::Boolean> result = Nan::New<v8::Boolean>(exists);
|
|
687
|
-
info.GetReturnValue().Set(result);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
NAN_METHOD(ActionExpireGoals) {
|
|
691
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
692
|
-
RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
|
|
693
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
694
|
-
rcl_action_server_t* action_server =
|
|
695
|
-
reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr());
|
|
696
|
-
int64_t max_num_goals = info[1]->IntegerValue(currentContent).FromJust();
|
|
697
|
-
rcl_action_goal_info_t* buffer = reinterpret_cast<rcl_action_goal_info_t*>(
|
|
698
|
-
node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked()));
|
|
699
|
-
|
|
700
|
-
size_t num_expired;
|
|
701
|
-
THROW_ERROR_IF_NOT_EQUAL(rcl_action_expire_goals(action_server, buffer,
|
|
702
|
-
max_num_goals, &num_expired),
|
|
703
|
-
RCL_RET_OK, rcl_get_error_string().str);
|
|
704
|
-
|
|
705
|
-
v8::Local<v8::Integer> result =
|
|
706
|
-
Nan::New<v8::Integer>(static_cast<int32_t>(num_expired));
|
|
707
|
-
info.GetReturnValue().Set(result);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
NAN_METHOD(ActionGetClientNamesAndTypesByNode) {
|
|
711
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
712
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
713
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
714
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
715
|
-
std::string node_name =
|
|
716
|
-
*Nan::Utf8String(info[1]->ToString(currentContent).ToLocalChecked());
|
|
717
|
-
std::string node_namespace =
|
|
718
|
-
*Nan::Utf8String(info[2]->ToString(currentContent).ToLocalChecked());
|
|
719
|
-
|
|
720
|
-
rcl_names_and_types_t names_and_types =
|
|
721
|
-
rcl_get_zero_initialized_names_and_types();
|
|
722
|
-
rcl_allocator_t allocator = rcl_get_default_allocator();
|
|
723
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
|
|
724
|
-
rcl_action_get_client_names_and_types_by_node(
|
|
725
|
-
node, &allocator, node_name.c_str(),
|
|
726
|
-
node_namespace.c_str(), &names_and_types),
|
|
727
|
-
"Failed to action client names and types.");
|
|
728
|
-
|
|
729
|
-
v8::Local<v8::Array> result_list =
|
|
730
|
-
Nan::New<v8::Array>(names_and_types.names.size);
|
|
731
|
-
ExtractNamesAndTypes(names_and_types, &result_list);
|
|
732
|
-
|
|
733
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
|
|
734
|
-
rcl_names_and_types_fini(&names_and_types),
|
|
735
|
-
"Failed to destroy names_and_types");
|
|
736
|
-
|
|
737
|
-
info.GetReturnValue().Set(result_list);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
NAN_METHOD(ActionGetServerNamesAndTypesByNode) {
|
|
741
|
-
v8::Local<v8::Context> currentContent = Nan::GetCurrentContext();
|
|
742
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
743
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
744
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
745
|
-
std::string node_name =
|
|
746
|
-
*Nan::Utf8String(info[1]->ToString(currentContent).ToLocalChecked());
|
|
747
|
-
std::string node_namespace =
|
|
748
|
-
*Nan::Utf8String(info[2]->ToString(currentContent).ToLocalChecked());
|
|
749
|
-
|
|
750
|
-
rcl_names_and_types_t names_and_types =
|
|
751
|
-
rcl_get_zero_initialized_names_and_types();
|
|
752
|
-
rcl_allocator_t allocator = rcl_get_default_allocator();
|
|
753
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
|
|
754
|
-
rcl_action_get_server_names_and_types_by_node(
|
|
755
|
-
node, &allocator, node_name.c_str(),
|
|
756
|
-
node_namespace.c_str(), &names_and_types),
|
|
757
|
-
"Failed to action server names and types");
|
|
758
|
-
|
|
759
|
-
v8::Local<v8::Array> result_list =
|
|
760
|
-
Nan::New<v8::Array>(names_and_types.names.size);
|
|
761
|
-
ExtractNamesAndTypes(names_and_types, &result_list);
|
|
762
|
-
|
|
763
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
|
|
764
|
-
rcl_names_and_types_fini(&names_and_types),
|
|
765
|
-
"Failed to destroy names_and_types");
|
|
766
|
-
|
|
767
|
-
info.GetReturnValue().Set(result_list);
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
NAN_METHOD(ActionGetNamesAndTypes) {
|
|
771
|
-
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
|
|
772
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked());
|
|
773
|
-
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
|
|
774
|
-
|
|
775
|
-
rcl_names_and_types_t names_and_types =
|
|
776
|
-
rcl_get_zero_initialized_names_and_types();
|
|
777
|
-
rcl_allocator_t allocator = rcl_get_default_allocator();
|
|
778
|
-
THROW_ERROR_IF_NOT_EQUAL(
|
|
779
|
-
RCL_RET_OK,
|
|
780
|
-
rcl_action_get_names_and_types(node, &allocator, &names_and_types),
|
|
781
|
-
"Failed to action server names and types");
|
|
782
|
-
|
|
783
|
-
v8::Local<v8::Array> result_list =
|
|
784
|
-
Nan::New<v8::Array>(names_and_types.names.size);
|
|
785
|
-
ExtractNamesAndTypes(names_and_types, &result_list);
|
|
786
|
-
|
|
787
|
-
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
|
|
788
|
-
rcl_names_and_types_fini(&names_and_types),
|
|
789
|
-
"Failed to destroy names_and_types");
|
|
790
|
-
|
|
791
|
-
info.GetReturnValue().Set(result_list);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
std::vector<BindingMethod> action_binding_methods = {
|
|
795
|
-
{"actionCreateClient", ActionCreateClient},
|
|
796
|
-
{"actionCreateServer", ActionCreateServer},
|
|
797
|
-
{"actionServerIsAvailable", ActionServerIsAvailable},
|
|
798
|
-
{"actionSendGoalRequest", ActionSendGoalRequest},
|
|
799
|
-
{"actionTakeGoalRequest", ActionTakeGoalRequest},
|
|
800
|
-
{"actionSendGoalResponse", ActionSendGoalResponse},
|
|
801
|
-
{"actionTakeGoalResponse", ActionTakeGoalResponse},
|
|
802
|
-
{"actionSendCancelRequest", ActionSendCancelRequest},
|
|
803
|
-
{"actionTakeCancelRequest", ActionTakeCancelRequest},
|
|
804
|
-
{"actionSendCancelResponse", ActionSendCancelResponse},
|
|
805
|
-
{"actionTakeCancelResponse", ActionTakeCancelResponse},
|
|
806
|
-
{"actionSendResultRequest", ActionSendResultRequest},
|
|
807
|
-
{"actionTakeResultRequest", ActionTakeResultRequest},
|
|
808
|
-
{"actionSendResultResponse", ActionSendResultResponse},
|
|
809
|
-
{"actionTakeResultResponse", ActionTakeResultResponse},
|
|
810
|
-
{"actionAcceptNewGoal", ActionAcceptNewGoal},
|
|
811
|
-
{"actionUpdateGoalState", ActionUpdateGoalState},
|
|
812
|
-
{"actionPublishStatus", ActionPublishStatus},
|
|
813
|
-
{"actionTakeStatus", ActionTakeStatus},
|
|
814
|
-
{"actionGoalHandleIsActive", ActionGoalHandleIsActive},
|
|
815
|
-
{"actionNotifyGoalDone", ActionNotifyGoalDone},
|
|
816
|
-
{"actionGoalHandleGetStatus", ActionGoalHandleGetStatus},
|
|
817
|
-
{"actionPublishFeedback", ActionPublishFeedback},
|
|
818
|
-
{"actionTakeFeedback", ActionTakeFeedback},
|
|
819
|
-
{"actionProcessCancelRequest", ActionProcessCancelRequest},
|
|
820
|
-
{"actionServerGoalExists", ActionServerGoalExists},
|
|
821
|
-
{"actionExpireGoals", ActionExpireGoals},
|
|
822
|
-
{"actionGetClientNamesAndTypesByNode", ActionGetClientNamesAndTypesByNode},
|
|
823
|
-
{"actionGetServerNamesAndTypesByNode", ActionGetServerNamesAndTypesByNode},
|
|
824
|
-
{"actionGetNamesAndTypes", ActionGetNamesAndTypes}};
|
|
825
|
-
|
|
826
|
-
} // namespace rclnodejs
|