ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
ROS 2 C++ Client Library with ROS Client Library
wait.h
Go to the documentation of this file.
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 
16 
17 #ifndef RCL__WAIT_H_
18 #define RCL__WAIT_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include <stdbool.h>
26 #include <stddef.h>
27 #include <stdint.h>
28 
29 #include "rcl/allocator.h"
30 #include "rcl/client.h"
31 #include "rcl/guard_condition.h"
32 #include "rcl/macros.h"
33 #include "rcl/service.h"
34 #include "rcl/subscription.h"
35 #include "rcl/timer.h"
36 #include "rcl/event.h"
37 #include "rcl/types.h"
38 #include "rcl/visibility_control.h"
39 
41 
43 typedef struct rcl_wait_set_s
44 {
54  const rcl_timer_t ** timers;
66  const rcl_event_t ** events;
72 
74 RCL_PUBLIC
75 RCL_WARN_UNUSED
78 
80 
133 RCL_PUBLIC
134 RCL_WARN_UNUSED
135 rcl_ret_t
137  rcl_wait_set_t * wait_set,
138  size_t number_of_subscriptions,
139  size_t number_of_guard_conditions,
140  size_t number_of_timers,
141  size_t number_of_clients,
142  size_t number_of_services,
143  size_t number_of_events,
144  rcl_context_t * context,
145  rcl_allocator_t allocator);
146 
148 
173 RCL_PUBLIC
174 RCL_WARN_UNUSED
175 rcl_ret_t
177 
179 
198 RCL_PUBLIC
199 RCL_WARN_UNUSED
200 rcl_ret_t
201 rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * allocator);
202 
204 
229 RCL_PUBLIC
230 RCL_WARN_UNUSED
231 rcl_ret_t
233  rcl_wait_set_t * wait_set,
234  const rcl_subscription_t * subscription,
235  size_t * index);
236 
238 
260 RCL_PUBLIC
261 RCL_WARN_UNUSED
262 rcl_ret_t
264 
266 
303 RCL_PUBLIC
304 RCL_WARN_UNUSED
305 rcl_ret_t
307  rcl_wait_set_t * wait_set,
308  size_t subscriptions_size,
309  size_t guard_conditions_size,
310  size_t timers_size,
311  size_t clients_size,
312  size_t services_size,
313  size_t events_size);
314 
316 
320 RCL_PUBLIC
321 RCL_WARN_UNUSED
322 rcl_ret_t
324  rcl_wait_set_t * wait_set,
325  const rcl_guard_condition_t * guard_condition,
326  size_t * index);
327 
329 
333 RCL_PUBLIC
334 RCL_WARN_UNUSED
335 rcl_ret_t
337  rcl_wait_set_t * wait_set,
338  const rcl_timer_t * timer,
339  size_t * index);
340 
342 
346 RCL_PUBLIC
347 RCL_WARN_UNUSED
348 rcl_ret_t
350  rcl_wait_set_t * wait_set,
351  const rcl_client_t * client,
352  size_t * index);
353 
355 
359 RCL_PUBLIC
360 RCL_WARN_UNUSED
361 rcl_ret_t
363  rcl_wait_set_t * wait_set,
364  const rcl_service_t * service,
365  size_t * index);
366 
368 
372 RCL_PUBLIC
373 RCL_WARN_UNUSED
374 rcl_ret_t
376  rcl_wait_set_t * wait_set,
377  const rcl_event_t * event,
378  size_t * index);
379 
381 
473 RCL_PUBLIC
474 RCL_WARN_UNUSED
475 rcl_ret_t
476 rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout);
477 
479 
497 RCL_PUBLIC
498 bool
499 rcl_wait_set_is_valid(const rcl_wait_set_t * wait_set);
500 
501 #ifdef __cplusplus
502 }
503 #endif
504 
505 #endif // RCL__WAIT_H_
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:31
Structure which encapsulates a ROS Client.
Definition: client.h:47
Encapsulates the non-global state of an init/shutdown cycle.
Definition: context.h:117
Structure which encapsulates a ROS QoS event handle.
Definition: event.h:64
Handle for a rcl guard condition.
Structure which encapsulates a ROS Service.
Definition: service.h:46
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:48
Structure which encapsulates a ROS Timer.
Definition: timer.h:42
Container for subscription's, guard condition's, etc to be waited on.
Definition: wait.h:44
const rcl_event_t ** events
Storage for event pointers.
Definition: wait.h:66
const rcl_timer_t ** timers
Storage for timer pointers.
Definition: wait.h:54
size_t size_of_timers
Number of timers.
Definition: wait.h:56
size_t size_of_events
Number of events.
Definition: wait.h:68
size_t size_of_subscriptions
Number of subscriptions.
Definition: wait.h:48
const rcl_service_t ** services
Storage for service pointers.
Definition: wait.h:62
const rcl_client_t ** clients
Storage for client pointers.
Definition: wait.h:58
const rcl_subscription_t ** subscriptions
Storage for subscription pointers.
Definition: wait.h:46
size_t size_of_guard_conditions
Number of guard_conditions.
Definition: wait.h:52
rcl_wait_set_impl_t * impl
Implementation specific storage.
Definition: wait.h:70
size_t size_of_clients
Number of clients.
Definition: wait.h:60
const rcl_guard_condition_t ** guard_conditions
Storage for guard condition pointers.
Definition: wait.h:50
size_t size_of_services
Number of services.
Definition: wait.h:64
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:25
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_subscription(rcl_wait_set_t *wait_set, const rcl_subscription_t *subscription, size_t *index)
Store a pointer to the given subscription in the next empty spot in the set.
Definition: wait.c:337
RCL_PUBLIC bool rcl_wait_set_is_valid(const rcl_wait_set_t *wait_set)
Return true if the wait set is valid, else false.
Definition: wait.c:80
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_service(rcl_wait_set_t *wait_set, const rcl_service_t *service, size_t *index)
Store a pointer to the service in the next empty spot in the set.
Definition: wait.c:518
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_init(rcl_wait_set_t *wait_set, size_t number_of_subscriptions, size_t number_of_guard_conditions, size_t number_of_timers, size_t number_of_clients, size_t number_of_services, size_t number_of_events, rcl_context_t *context, rcl_allocator_t allocator)
Initialize a rcl wait set with space for items to be waited on.
Definition: wait.c:86
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_clear(rcl_wait_set_t *wait_set)
Remove (sets to NULL) all entities in the wait set.
Definition: wait.c:353
struct rcl_wait_set_s rcl_wait_set_t
Container for subscription's, guard condition's, etc to be waited on.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_timer(rcl_wait_set_t *wait_set, const rcl_timer_t *timer, size_t *index)
Store a pointer to the timer in the next empty spot in the set.
Definition: wait.c:487
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_client(rcl_wait_set_t *wait_set, const rcl_client_t *client, size_t *index)
Store a pointer to the client in the next empty spot in the set.
Definition: wait.c:507
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_fini(rcl_wait_set_t *wait_set)
Finalize a rcl wait set.
Definition: wait.c:175
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait(rcl_wait_set_t *wait_set, int64_t timeout)
Block until the wait set is ready or until the timeout has been exceeded.
Definition: wait.c:541
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_resize(rcl_wait_set_t *wait_set, size_t subscriptions_size, size_t guard_conditions_size, size_t timers_size, size_t clients_size, size_t services_size, size_t events_size)
Reallocate space for entities in the wait set.
Definition: wait.c:395
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_get_allocator(const rcl_wait_set_t *wait_set, rcl_allocator_t *allocator)
Retrieve the wait set's allocator.
Definition: wait.c:201
RCL_PUBLIC RCL_WARN_UNUSED rcl_wait_set_t rcl_get_zero_initialized_wait_set(void)
Return a rcl_wait_set_t struct with members set to NULL.
Definition: wait.c:72
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_event(rcl_wait_set_t *wait_set, const rcl_event_t *event, size_t *index)
Store a pointer to the event in the next empty spot in the set.
Definition: wait.c:529
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_set_add_guard_condition(rcl_wait_set_t *wait_set, const rcl_guard_condition_t *guard_condition, size_t *index)
Store a pointer to the guard condition in the next empty spot in the set.
Definition: wait.c:473