ROS 2 rclcpp + rcl - kilted  kilted
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,
41  RCL_PUBLISHER_INCOMPATIBLE_TYPE,
42  RCL_PUBLISHER_MATCHED,
44 
47 {
48  RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
49  RCL_SUBSCRIPTION_LIVELINESS_CHANGED,
50  RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
51  RCL_SUBSCRIPTION_MESSAGE_LOST,
52  RCL_SUBSCRIPTION_INCOMPATIBLE_TYPE,
53  RCL_SUBSCRIPTION_MATCHED,
55 
57 typedef struct rcl_event_impl_s rcl_event_impl_t;
58 
60 typedef struct rcl_event_s
61 {
65 
67 
73 RCL_PUBLIC
74 RCL_WARN_UNUSED
77 
79 
91 RCL_PUBLIC
92 RCL_WARN_UNUSED
95  rcl_event_t * event,
96  const rcl_publisher_t * publisher,
97  const rcl_publisher_event_type_t event_type);
98 
100 
112 RCL_PUBLIC
113 RCL_WARN_UNUSED
114 rcl_ret_t
116  rcl_event_t * event,
117  const rcl_subscription_t * subscription,
118  const rcl_subscription_event_type_t event_type);
119 
120 // Take event using the event handle.
132 RCL_PUBLIC
133 RCL_WARN_UNUSED
134 rcl_ret_t
136  const rcl_event_t * event,
137  void * event_info);
138 
139 // Finalize an event.
148 RCL_PUBLIC
149 RCL_WARN_UNUSED
150 rcl_ret_t
151 rcl_event_fini(rcl_event_t * event);
152 
154 
179 RCL_PUBLIC
180 RCL_WARN_UNUSED
181 rmw_event_t *
183 
185 
202 RCL_PUBLIC
203 bool
204 rcl_event_is_valid(const rcl_event_t * event);
205 
207 
229 RCL_PUBLIC
230 RCL_WARN_UNUSED
231 rcl_ret_t
233  const rcl_event_t * event,
234  rcl_event_callback_t callback,
235  const void * user_data);
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 #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:164
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:47
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:235
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:211
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:104
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_event_fini(rcl_event_t *event)
Definition: event.c:189
RCL_PUBLIC bool rcl_event_is_valid(const rcl_event_t *event)
Check that the event is valid.
Definition: event.c:221
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:47
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:61
rcl_event_impl_t * impl
Pointer to the event implementation.
Definition: event.h:63
Structure which encapsulates a ROS Publisher.
Definition: publisher.h:37
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:40
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:24