rcl  master
C API providing common ROS client library functionality.
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 
15 #ifndef RCL__WAIT_H_
16 #define RCL__WAIT_H_
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <stdbool.h>
24 #include <stddef.h>
25 
26 #include "rcl/client.h"
27 #include "rcl/guard_condition.h"
28 #include "rcl/macros.h"
29 #include "rcl/service.h"
30 #include "rcl/subscription.h"
31 #include "rcl/timer.h"
32 #include "rcl/event.h"
33 #include "rcl/types.h"
34 #include "rcl/visibility_control.h"
35 
36 struct rcl_wait_set_impl_t;
37 
39 typedef struct rcl_wait_set_t
40 {
48  const rcl_timer_t ** timers;
57  const rcl_event_t ** events;
60  struct rcl_wait_set_impl_t * impl;
62 
68 
70 
123 rcl_ret_t
125  rcl_wait_set_t * wait_set,
126  size_t number_of_subscriptions,
127  size_t number_of_guard_conditions,
128  size_t number_of_timers,
129  size_t number_of_clients,
130  size_t number_of_services,
131  size_t number_of_events,
132  rcl_context_t * context,
133  rcl_allocator_t allocator);
134 
136 
162 rcl_ret_t
164 
166 
186 rcl_ret_t
187 rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * allocator);
188 
190 
217 rcl_ret_t
219  rcl_wait_set_t * wait_set,
220  const rcl_subscription_t * subscription,
221  size_t * index);
222 
224 
248 rcl_ret_t
250 
252 
290 rcl_ret_t
292  rcl_wait_set_t * wait_set,
293  size_t subscriptions_size,
294  size_t guard_conditions_size,
295  size_t timers_size,
296  size_t clients_size,
297  size_t services_size,
298  size_t events_size);
299 
301 
307 rcl_ret_t
309  rcl_wait_set_t * wait_set,
310  const rcl_guard_condition_t * guard_condition,
311  size_t * index);
312 
314 
320 rcl_ret_t
322  rcl_wait_set_t * wait_set,
323  const rcl_timer_t * timer,
324  size_t * index);
325 
327 
333 rcl_ret_t
335  rcl_wait_set_t * wait_set,
336  const rcl_client_t * client,
337  size_t * index);
338 
340 
346 rcl_ret_t
348  rcl_wait_set_t * wait_set,
349  const rcl_service_t * service,
350  size_t * index);
351 
353 
359 rcl_ret_t
361  rcl_wait_set_t * wait_set,
362  const rcl_event_t * event,
363  size_t * index);
364 
366 
459 rcl_ret_t
460 rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout);
461 
462 #ifdef __cplusplus
463 }
464 #endif
465 
466 #endif // RCL__WAIT_H_
Container for subscription&#39;s, guard condition&#39;s, etc to be waited on.
Definition: wait.h:39
const rcl_service_t ** services
Storage for service pointers.
Definition: wait.h:54
const rcl_event_t ** events
Storage for event pointers.
Definition: wait.h:57
rmw_ret_t rcl_ret_t
Definition: types.h:20
size_t size_of_clients
Definition: wait.h:52
size_t size_of_guard_conditions
Definition: wait.h:46
Structure which encapsulates a ROS QoS event handle.
Definition: event.h:49
rcl_ret_t rcl_wait_set_get_allocator(const rcl_wait_set_t *wait_set, rcl_allocator_t *allocator)
Retrieve the wait set&#39;s allocator.
size_t size_of_subscriptions
Definition: wait.h:43
size_t size_of_services
Definition: wait.h:55
const rcl_client_t ** clients
Storage for client pointers.
Definition: wait.h:51
Structure which encapsulates a ROS Client.
Definition: client.h:33
rcl_wait_set_t rcl_get_zero_initialized_wait_set(void)
Return a rcl_wait_set_t struct with members set to NULL.
const rcl_timer_t ** timers
Storage for timer pointers.
Definition: wait.h:48
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.
#define RCL_WARN_UNUSED
Ignored return values of functions with this macro will emit a warning.
Definition: macros.h:25
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.
size_t size_of_timers
Definition: wait.h:49
#define RCL_PUBLIC
Definition: visibility_control.h:48
rcl_ret_t rcl_wait_set_fini(rcl_wait_set_t *wait_set)
Finalize a rcl wait set.
struct rcl_wait_set_impl_t * impl
Implementation specific storage.
Definition: wait.h:60
Structure which encapsulates a ROS Service.
Definition: service.h:33
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.
struct rcl_wait_set_t rcl_wait_set_t
Container for subscription&#39;s, guard condition&#39;s, etc to be waited on.
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.
rcl_ret_t rcl_wait_set_clear(rcl_wait_set_t *wait_set)
Remove (sets to NULL) all entities in the wait set.
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.
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:33
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.
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.
Structure which encapsulates a ROS Timer.
Definition: timer.h:37
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.
Encapsulates the non-global state of an init/shutdown cycle.
Definition: context.h:108
size_t size_of_events
Definition: wait.h:58
Handle for a rcl guard condition.
Definition: guard_condition.h:33
const rcl_guard_condition_t ** guard_conditions
Storage for guard condition pointers.
Definition: wait.h:45
const rcl_subscription_t ** subscriptions
Storage for subscription pointers.
Definition: wait.h:42
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.