Skip to content

Commit dab6bf7

Browse files
authored
Replace rcl_take_request with rcl_take_request_with_info (#1333)
This PR updates the ROS 2 service bindings to use the newer `rcl_take_request_with_info` API instead of the deprecated `rcl_take_request` API. The change involves using `rmw_service_info_t` instead of `rmw_request_id_t` to accommodate additional service metadata. - Updates `RclTakeRequest` to use `rcl_take_request_with_info` with `rmw_service_info_t` - Updates `SendResponse` to extract `request_id` from `rmw_service_info_t` structure Fix: #1330
1 parent 0c94326 commit dab6bf7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/rcl_service_bindings.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ Napi::Value RclTakeRequest(const Napi::CallbackInfo& info) {
7777

7878
rcl_service_t* service = reinterpret_cast<rcl_service_t*>(
7979
RclHandle::Unwrap(info[0].As<Napi::Object>())->ptr());
80-
rmw_request_id_t* header =
81-
reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
80+
rmw_service_info_t* header =
81+
reinterpret_cast<rmw_service_info_t*>(malloc(sizeof(rmw_service_info_t)));
8282

8383
void* taken_request = info[2].As<Napi::Buffer<char>>().Data();
84-
rcl_ret_t ret = rcl_take_request(service, header, taken_request);
84+
rcl_ret_t ret = rcl_take_request_with_info(service, header, taken_request);
8585
if (ret != RCL_RET_SERVICE_TAKE_FAILED) {
8686
auto js_obj = RclHandle::NewInstance(env, header, nullptr,
8787
[](void* ptr) { free(ptr); });
@@ -98,11 +98,12 @@ Napi::Value SendResponse(const Napi::CallbackInfo& info) {
9898
RclHandle::Unwrap(info[0].As<Napi::Object>())->ptr());
9999
void* buffer = info[1].As<Napi::Buffer<char>>().Data();
100100

101-
rmw_request_id_t* header = reinterpret_cast<rmw_request_id_t*>(
101+
rmw_service_info_t* header = reinterpret_cast<rmw_service_info_t*>(
102102
RclHandle::Unwrap(info[2].As<Napi::Object>())->ptr());
103103

104-
THROW_ERROR_IF_NOT_EQUAL(rcl_send_response(service, header, buffer),
105-
RCL_RET_OK, rcl_get_error_string().str);
104+
THROW_ERROR_IF_NOT_EQUAL(
105+
rcl_send_response(service, &(header->request_id), buffer), RCL_RET_OK,
106+
rcl_get_error_string().str);
106107

107108
return env.Undefined();
108109
}

0 commit comments

Comments
 (0)