ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
event.h
Go to the documentation of this file.
1 // Copyright 2019 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__EVENT_H_
18 #define RCL__EVENT_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include <rmw/event.h>
26 
27 #include "rcl/client.h"
28 #include "rcl/event_callback.h"
29 #include "rcl/macros.h"
30 #include "rcl/publisher.h"
31 #include "rcl/service.h"
32 #include "rcl/subscription.h"
33 #include "rcl/visibility_control.h"
34 
37 {
38  RCL_PUBLISHER_OFFERED_DEADLINE_MISSED,
39  RCL_PUBLISHER_LIVELINESS_LOST,
40  RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS,
42 
45 {
46  RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
47  RCL_SUBSCRIPTION_LIVELINESS_CHANGED,
48  RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
49  RCL_SUBSCRIPTION_MESSAGE_LOST,
51 
53 typedef struct rcl_event_impl_s rcl_event_impl_t;
54 
56 typedef struct rcl_event_s
57 {
61 
63 
69 RCL_PUBLIC
70 RCL_WARN_UNUSED
73 
75 
87 RCL_PUBLIC
88 RCL_WARN_UNUSED
91  rcl_event_t * event,
92  const rcl_publisher_t * publisher,
93  const rcl_publisher_event_type_t event_type);
94 
96 
108 RCL_PUBLIC
109 RCL_WARN_UNUSED
110 rcl_ret_t
112  rcl_event_t * event,
113  const rcl_subscription_t * subscription,
114  const rcl_subscription_event_type_t event_type);
115 
116 // Take event using the event handle.
128 RCL_PUBLIC
129 RCL_WARN_UNUSED
130 rcl_ret_t
132  const rcl_event_t * event,
133  void * event_info);
134 
135 // Finalize an event.
144 RCL_PUBLIC
145 RCL_WARN_UNUSED
146 rcl_ret_t
147 rcl_event_fini(rcl_event_t * event);
148 
150 
175 RCL_PUBLIC
176 RCL_WARN_UNUSED
177 rmw_event_t *
179 
181 
198 RCL_PUBLIC
199 bool
200 rcl_event_is_valid(const rcl_event_t * event);
201 
203 
225 RCL_PUBLIC
226 RCL_WARN_UNUSED
227 rcl_ret_t
229  const rcl_event_t * event,
230  rcl_event_callback_t callback,
231  const void * user_data);
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 #endif // RCL__EVENT_H_
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_take_event(const rcl_event_t *event, void *event_info)
Definition: event.c:151
struct rcl_event_s rcl_event_t
Structure which encapsulates a ROS QoS event handle.
enum rcl_publisher_event_type_e rcl_publisher_event_type_t
Enumeration of all of the publisher events that may fire.
RCL_PUBLIC RCL_WARN_UNUSED rcl_event_t rcl_get_zero_initialized_event(void)
Return a rcl_event_t struct with members set to NULL.
Definition: event.c:39
rcl_subscription_event_type_e
Enumeration of all of the subscription events that may fire.
Definition: event.h:45
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_event_set_callback(const rcl_event_t *event, rcl_event_callback_t callback, const void *user_data)
Set the callback function for the event.
Definition: event.c:222
enum rcl_subscription_event_type_e rcl_subscription_event_type_t
Enumeration of all of the subscription events that may fire.
RCL_PUBLIC RCL_WARN_UNUSED rmw_event_t * rcl_event_get_rmw_handle(const rcl_event_t *event)
Return the rmw event handle.
Definition: event.c:198
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_subscription_event_init(rcl_event_t *event, const rcl_subscription_t *subscription, const rcl_subscription_event_type_t event_type)
Initialize an rcl_event_t with a subscription.
Definition: event.c:97
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_event_fini(rcl_event_t *event)
Definition: event.c:176
RCL_PUBLIC bool rcl_event_is_valid(const rcl_event_t *event)
Check that the event is valid.
Definition: event.c:208
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_event_init(rcl_event_t *event, const rcl_publisher_t *publisher, const rcl_publisher_event_type_t event_type)
Initialize an rcl_event_t with a publisher.
Definition: event.c:46
rcl_publisher_event_type_e
Enumeration of all of the publisher events that may fire.
Definition: event.h:37
Structure which encapsulates a ROS QoS event handle.
Definition: event.h:57
rcl_event_impl_t * impl
Pointer to the event implementation.
Definition: event.h:59
Structure which encapsulates a ROS Publisher.
Definition: publisher.h:37
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:39
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:23