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 
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 
28 #include "rcl/client.h"
29 #include "rcl/guard_condition.h"
30 #include "rcl/macros.h"
31 #include "rcl/service.h"
32 #include "rcl/subscription.h"
33 #include "rcl/timer.h"
34 #include "rcl/event.h"
35 #include "rcl/types.h"
36 #include "rcl/visibility_control.h"
37 
38 struct rcl_wait_set_impl_t;
39 
41 typedef struct rcl_wait_set_t
42 {
52  const rcl_timer_t ** timers;
64  const rcl_event_t ** events;
68  struct rcl_wait_set_impl_t * impl;
70 
72 RCL_PUBLIC
73 RCL_WARN_UNUSED
76 
78 
131 RCL_PUBLIC
132 RCL_WARN_UNUSED
133 rcl_ret_t
135  rcl_wait_set_t * wait_set,
136  size_t number_of_subscriptions,
137  size_t number_of_guard_conditions,
138  size_t number_of_timers,
139  size_t number_of_clients,
140  size_t number_of_services,
141  size_t number_of_events,
142  rcl_context_t * context,
143  rcl_allocator_t allocator);
144 
146 
171 RCL_PUBLIC
172 RCL_WARN_UNUSED
173 rcl_ret_t
175 
177 
196 RCL_PUBLIC
197 RCL_WARN_UNUSED
198 rcl_ret_t
199 rcl_wait_set_get_allocator(const rcl_wait_set_t * wait_set, rcl_allocator_t * allocator);
200 
202 
227 RCL_PUBLIC
228 RCL_WARN_UNUSED
229 rcl_ret_t
231  rcl_wait_set_t * wait_set,
232  const rcl_subscription_t * subscription,
233  size_t * index);
234 
236 
258 RCL_PUBLIC
259 RCL_WARN_UNUSED
260 rcl_ret_t
262 
264 
301 RCL_PUBLIC
302 RCL_WARN_UNUSED
303 rcl_ret_t
305  rcl_wait_set_t * wait_set,
306  size_t subscriptions_size,
307  size_t guard_conditions_size,
308  size_t timers_size,
309  size_t clients_size,
310  size_t services_size,
311  size_t events_size);
312 
314 
318 RCL_PUBLIC
319 RCL_WARN_UNUSED
320 rcl_ret_t
322  rcl_wait_set_t * wait_set,
323  const rcl_guard_condition_t * guard_condition,
324  size_t * index);
325 
327 
331 RCL_PUBLIC
332 RCL_WARN_UNUSED
333 rcl_ret_t
335  rcl_wait_set_t * wait_set,
336  const rcl_timer_t * timer,
337  size_t * index);
338 
340 
344 RCL_PUBLIC
345 RCL_WARN_UNUSED
346 rcl_ret_t
348  rcl_wait_set_t * wait_set,
349  const rcl_client_t * client,
350  size_t * index);
351 
353 
357 RCL_PUBLIC
358 RCL_WARN_UNUSED
359 rcl_ret_t
361  rcl_wait_set_t * wait_set,
362  const rcl_service_t * service,
363  size_t * index);
364 
366 
370 RCL_PUBLIC
371 RCL_WARN_UNUSED
372 rcl_ret_t
374  rcl_wait_set_t * wait_set,
375  const rcl_event_t * event,
376  size_t * index);
377 
379 
470 RCL_PUBLIC
471 RCL_WARN_UNUSED
472 rcl_ret_t
473 rcl_wait(rcl_wait_set_t * wait_set, int64_t timeout);
474 
476 
494 RCL_PUBLIC
495 bool
496 rcl_wait_set_is_valid(const rcl_wait_set_t * wait_set);
497 
498 #ifdef __cplusplus
499 }
500 #endif
501 
502 #endif // RCL__WAIT_H_
rcl_wait_set_t::size_of_timers
size_t size_of_timers
Number of timers.
Definition: wait.h:54
rcl_timer_t
Structure which encapsulates a ROS Timer.
Definition: timer.h:39
rcl_wait_set_get_allocator
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.
types.h
rcl_ret_t
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:23
service.h
rcl_client_t
Structure which encapsulates a ROS Client.
Definition: client.h:35
rcl_wait_set_t::size_of_guard_conditions
size_t size_of_guard_conditions
Number of guard_conditions.
Definition: wait.h:50
rcl_wait_set_t
struct rcl_wait_set_t rcl_wait_set_t
Container for subscription's, guard condition's, etc to be waited on.
rcl_wait_set_add_timer
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.
rcl_wait_set_t::events
const rcl_event_t ** events
Storage for event pointers.
Definition: wait.h:64
rcl_wait_set_add_guard_condition
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.
rcl_guard_condition_t
Handle for a rcl guard condition.
Definition: guard_condition.h:35
rcl_wait_set_is_valid
bool rcl_wait_set_is_valid(const rcl_wait_set_t *wait_set)
Return true if the wait set is valid, else false.
rcl_wait_set_t::timers
const rcl_timer_t ** timers
Storage for timer pointers.
Definition: wait.h:52
subscription.h
rcl_wait_set_resize
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.
rcl_wait_set_fini
rcl_ret_t rcl_wait_set_fini(rcl_wait_set_t *wait_set)
Finalize a rcl wait set.
rcl_wait_set_t::size_of_subscriptions
size_t size_of_subscriptions
Number of subscriptions.
Definition: wait.h:46
rcl_wait_set_t::services
const rcl_service_t ** services
Storage for service pointers.
Definition: wait.h:60
rcl_wait_set_clear
rcl_ret_t rcl_wait_set_clear(rcl_wait_set_t *wait_set)
Remove (sets to NULL) all entities in the wait set.
rcl_wait_set_t::guard_conditions
const rcl_guard_condition_t ** guard_conditions
Storage for guard condition pointers.
Definition: wait.h:48
guard_condition.h
rcl_wait_set_t::subscriptions
const rcl_subscription_t ** subscriptions
Storage for subscription pointers.
Definition: wait.h:44
timer.h
rcl_wait_set_t
Container for subscription's, guard condition's, etc to be waited on.
Definition: wait.h:41
rcl_wait_set_t::size_of_clients
size_t size_of_clients
Number of clients.
Definition: wait.h:58
event.h
rcl_wait_set_add_event
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.
rcl_get_zero_initialized_wait_set
rcl_wait_set_t rcl_get_zero_initialized_wait_set(void)
Return a rcl_wait_set_t struct with members set to NULL.
rcl_wait_set_t::impl
struct rcl_wait_set_impl_t * impl
Implementation specific storage.
Definition: wait.h:68
rcl_wait_set_add_client
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.
rcutils_allocator_t
rcl_wait_set_t::clients
const rcl_client_t ** clients
Storage for client pointers.
Definition: wait.h:56
rcl_subscription_t
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:37
rcl_context_t
Encapsulates the non-global state of an init/shutdown cycle.
Definition: context.h:113
rcl_event_t
Structure which encapsulates a ROS QoS event handle.
Definition: event.h:56
rcl_service_t
Structure which encapsulates a ROS Service.
Definition: service.h:35
rcl_wait_set_add_service
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_wait_set_t::size_of_events
size_t size_of_events
Number of events.
Definition: wait.h:66
rcl_wait
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_wait_set_add_subscription
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.
client.h
rcl_wait_set_init
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.
rcl_wait_set_t::size_of_services
size_t size_of_services
Number of services.
Definition: wait.h:62