Skip to content

Commit

Permalink
fixes lifecycle statemachine api changes #781 (#783)
Browse files Browse the repository at this point in the history
fixes lifecycle statemachine init() and fini() api changes

fix #781
  • Loading branch information
wayneparrott committed Mar 29, 2021
1 parent 8490c2f commit ac59274
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/rcl_lifecycle_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ NAN_METHOD(CreateLifecycleStateMachine) {
RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
Nan::To<v8::Object>(info[0]).ToLocalChecked());
rcl_node_t* node = reinterpret_cast<rcl_node_t*>(node_handle->ptr());
const rcl_node_options_t* node_options =
reinterpret_cast<const rcl_node_options_t*>(rcl_node_get_options(node));

rcl_lifecycle_state_machine_t* state_machine =
reinterpret_cast<rcl_lifecycle_state_machine_t*>(
Expand All @@ -75,18 +73,21 @@ NAN_METHOD(CreateLifecycleStateMachine) {
const rosidl_service_type_support_t* gtg =
GetServiceTypeSupport("lifecycle_msgs", "GetAvailableTransitions");

rcl_lifecycle_state_machine_options_t options =
rcl_lifecycle_get_default_state_machine_options();

THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK,
rcl_lifecycle_state_machine_init(
state_machine, node, pn, cs, gs, gas, gat, gtg,
true, &node_options->allocator),
state_machine, node,
pn, cs, gs, gas, gat, gtg,
&options),
rcl_get_error_string().str);

auto js_obj = RclHandle::NewInstance(
state_machine, node_handle, [node, node_options](void* ptr) {
state_machine, node_handle, [node](void* ptr) {
rcl_lifecycle_state_machine_t* state_machine =
reinterpret_cast<rcl_lifecycle_state_machine_t*>(ptr);
rcl_ret_t ret = rcl_lifecycle_state_machine_fini(
state_machine, node, &node_options->allocator);
rcl_ret_t ret = rcl_lifecycle_state_machine_fini(state_machine, node);
free(ptr);
THROW_ERROR_IF_NOT_EQUAL(RCL_RET_OK, ret, rcl_get_error_string().str);
});
Expand Down

0 comments on commit ac59274

Please sign in to comment.