rcl  master
C API providing common ROS client library functionality.
timer.h
1 // Copyright 2015 Open Source Robotics Foundation, Inc.
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 #ifndef RCL__TIMER_H_
16 #define RCL__TIMER_H_
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <stdbool.h>
24 
25 #include "rcl/allocator.h"
26 #include "rcl/context.h"
27 #include "rcl/guard_condition.h"
28 #include "rcl/macros.h"
29 #include "rcl/time.h"
30 #include "rcl/types.h"
31 #include "rmw/rmw.h"
32 
33 struct rcl_clock_t;
34 struct rcl_timer_impl_t;
35 
37 typedef struct rcl_timer_t
38 {
40  struct rcl_timer_impl_t * impl;
41 } rcl_timer_t;
42 
44 
56 typedef void (* rcl_timer_callback_t)(rcl_timer_t *, int64_t);
57 
59 RCL_PUBLIC
60 RCL_WARN_UNUSED
62 rcl_get_zero_initialized_timer(void);
63 
65 
150 RCL_PUBLIC
151 RCL_WARN_UNUSED
152 rcl_ret_t
153 rcl_timer_init(
154  rcl_timer_t * timer,
155  rcl_clock_t * clock,
156  rcl_context_t * context,
157  int64_t period,
158  const rcl_timer_callback_t callback,
159  rcl_allocator_t allocator);
160 
162 
187 RCL_PUBLIC
188 RCL_WARN_UNUSED
189 rcl_ret_t
190 rcl_timer_fini(rcl_timer_t * timer);
191 
193 
231 RCL_PUBLIC
232 RCL_WARN_UNUSED
233 rcl_ret_t
234 rcl_timer_call(rcl_timer_t * timer);
235 
237 
257 RCL_PUBLIC
258 RCL_WARN_UNUSED
259 rcl_ret_t
260 rcl_timer_clock(rcl_timer_t * timer, rcl_clock_t ** clock);
261 
263 
287 RCL_PUBLIC
288 RCL_WARN_UNUSED
289 rcl_ret_t
290 rcl_timer_is_ready(const rcl_timer_t * timer, bool * is_ready);
291 
293 
322 RCL_PUBLIC
323 RCL_WARN_UNUSED
324 rcl_ret_t
325 rcl_timer_get_time_until_next_call(const rcl_timer_t * timer, int64_t * time_until_next_call);
326 
328 
354 RCL_PUBLIC
355 RCL_WARN_UNUSED
356 rcl_ret_t
357 rcl_timer_get_time_since_last_call(const rcl_timer_t * timer, int64_t * time_since_last_call);
358 
360 
380 RCL_PUBLIC
381 RCL_WARN_UNUSED
382 rcl_ret_t
383 rcl_timer_get_period(const rcl_timer_t * timer, int64_t * period);
384 
386 
410 RCL_PUBLIC
411 RCL_WARN_UNUSED
412 rcl_ret_t
413 rcl_timer_exchange_period(const rcl_timer_t * timer, int64_t new_period, int64_t * old_period);
414 
416 
433 RCL_PUBLIC
434 RCL_WARN_UNUSED
435 rcl_timer_callback_t
436 rcl_timer_get_callback(const rcl_timer_t * timer);
437 
439 
460 RCL_PUBLIC
461 RCL_WARN_UNUSED
462 rcl_timer_callback_t
463 rcl_timer_exchange_callback(rcl_timer_t * timer, const rcl_timer_callback_t new_callback);
464 
466 
488 RCL_PUBLIC
489 RCL_WARN_UNUSED
490 rcl_ret_t
491 rcl_timer_cancel(rcl_timer_t * timer);
492 
494 
516 RCL_PUBLIC
517 RCL_WARN_UNUSED
518 rcl_ret_t
519 rcl_timer_is_canceled(const rcl_timer_t * timer, bool * is_canceled);
520 
522 
542 RCL_PUBLIC
543 RCL_WARN_UNUSED
544 rcl_ret_t
545 rcl_timer_reset(rcl_timer_t * timer);
546 
548 
566 RCL_PUBLIC
567 RCL_WARN_UNUSED
568 const rcl_allocator_t *
569 rcl_timer_get_allocator(const rcl_timer_t * timer);
570 
572 
585 RCL_PUBLIC
586 RCL_WARN_UNUSED
588 rcl_timer_get_guard_condition(const rcl_timer_t * timer);
589 
590 #ifdef __cplusplus
591 }
592 #endif
593 
594 #endif // RCL__TIMER_H_
rcl_timer_t
Structure which encapsulates a ROS Timer.
Definition: timer.h:37
rcl_timer_t::impl
struct rcl_timer_impl_t * impl
Private implementation pointer.
Definition: timer.h:40
rmw.h
rcl_guard_condition_t
Handle for a rcl guard condition.
Definition: guard_condition.h:33
rcl_clock_t
Encapsulation of a time source.
Definition: time.h:131
rcutils_allocator_t
rcl_context_t
Encapsulates the non-global state of an init/shutdown cycle.
Definition: context.h:108