-
Notifications
You must be signed in to change notification settings - Fork 79
Add GetNumEntities() for action client #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,28 +126,6 @@ Napi::Value ActionSendGoalRequest(const Napi::CallbackInfo& info) { | |||||||||||
| return Napi::Number::New(env, static_cast<int32_t>(sequence_number)); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| Napi::Value ActionTakeCancelRequest(const Napi::CallbackInfo& info) { | ||||||||||||
| Napi::Env env = info.Env(); | ||||||||||||
|
|
||||||||||||
| RclHandle* action_server_handle = | ||||||||||||
| RclHandle::Unwrap(info[0].As<Napi::Object>()); | ||||||||||||
| rcl_action_server_t* action_server = | ||||||||||||
| reinterpret_cast<rcl_action_server_t*>(action_server_handle->ptr()); | ||||||||||||
| rmw_request_id_t* header = | ||||||||||||
| reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t))); | ||||||||||||
|
|
||||||||||||
| void* taken_request = info[1].As<Napi::Buffer<char>>().Data(); | ||||||||||||
| rcl_ret_t ret = | ||||||||||||
| rcl_action_take_cancel_request(action_server, header, taken_request); | ||||||||||||
| if (ret != RCL_RET_ACTION_SERVER_TAKE_FAILED) { | ||||||||||||
| auto js_obj = RclHandle::NewInstance(env, header, nullptr, | ||||||||||||
| [](void* ptr) { free(ptr); }); | ||||||||||||
| return js_obj; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return env.Undefined(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| Napi::Value ActionSendResultRequest(const Napi::CallbackInfo& info) { | ||||||||||||
| Napi::Env env = info.Env(); | ||||||||||||
|
|
||||||||||||
|
|
@@ -211,20 +189,73 @@ Napi::Value ActionTakeStatus(const Napi::CallbackInfo& info) { | |||||||||||
| return env.Undefined(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| Napi::Value GetNumEntities(const Napi::CallbackInfo& info) { | ||||||||||||
|
||||||||||||
| Napi::Env env = info.Env(); | ||||||||||||
| RclHandle* action_client_handle = | ||||||||||||
| RclHandle::Unwrap(info[0].As<Napi::Object>()); | ||||||||||||
| rcl_action_client_t* action_client = | ||||||||||||
| reinterpret_cast<rcl_action_client_t*>(action_client_handle->ptr()); | ||||||||||||
|
|
||||||||||||
| size_t num_subscriptions = 0u; | ||||||||||||
| size_t num_guard_conditions = 0u; | ||||||||||||
| size_t num_timers = 0u; | ||||||||||||
| size_t num_clients = 0u; | ||||||||||||
| size_t num_services = 0u; | ||||||||||||
|
|
||||||||||||
| rcl_ret_t ret; | ||||||||||||
| ret = rcl_action_client_wait_set_get_num_entities( | ||||||||||||
| action_client, &num_subscriptions, &num_guard_conditions, &num_timers, | ||||||||||||
| &num_clients, &num_services); | ||||||||||||
| if (RCL_RET_OK != ret) { | ||||||||||||
| rcl_reset_error(); | ||||||||||||
| std::string error_text{ | ||||||||||||
| "Failed to get number of entities for 'rcl_action_client_t'"}; | ||||||||||||
|
Comment on lines
+210
to
+212
|
||||||||||||
| rcl_reset_error(); | |
| std::string error_text{ | |
| "Failed to get number of entities for 'rcl_action_client_t'"}; | |
| std::string error_text = "Failed to get number of entities for 'rcl_action_client_t'. Error code: " + std::to_string(ret); | |
| rcl_reset_error(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider expanding the doc comment for getNumEntities() to explicitly list the returned object properties (subscriptionsNumber, guardConditionsNumber, timersNumber, clientsNumber, servicesNumber) for better clarity.