Skip to content

Commit 0041ebf

Browse files
committed
Leverage rcl_timer_init prior to iron (#990)
1 parent 68b1200 commit 0041ebf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/rcl_bindings.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,19 @@ NAN_METHOD(CreateTimer) {
325325
reinterpret_cast<rcl_timer_t*>(malloc(sizeof(rcl_timer_t)));
326326
*timer = rcl_get_zero_initialized_timer();
327327

328+
#if ROS_VERSION > 2205 // After humble.
328329
THROW_ERROR_IF_NOT_EQUAL(
329330
RCL_RET_OK,
330331
rcl_timer_init2(timer, clock, context, RCL_MS_TO_NS(period_ms), nullptr,
331332
rcl_get_default_allocator(), /*autostart=*/true),
332333
rcl_get_error_string().str);
334+
#else
335+
THROW_ERROR_IF_NOT_EQUAL(
336+
RCL_RET_OK,
337+
rcl_timer_init(timer, clock, context, RCL_MS_TO_NS(period_ms), nullptr,
338+
rcl_get_default_allocator()),
339+
rcl_get_error_string().str);
340+
#endif
333341

334342
auto js_obj = RclHandle::NewInstance(timer, clock_handle, [](void* ptr) {
335343
rcl_timer_t* timer = reinterpret_cast<rcl_timer_t*>(ptr);

0 commit comments

Comments
 (0)