rcl_lifecycle  master
C API providing common functionality for ROS lifecycle.
All Classes Namespaces Files Functions Variables Modules Pages
rcl_lifecycle.h
1 // Copyright 2016 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 
33 #ifndef RCL_LIFECYCLE__RCL_LIFECYCLE_H_
34 #define RCL_LIFECYCLE__RCL_LIFECYCLE_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 #include <stdbool.h>
42 
43 #include "rcl_lifecycle/data_types.h"
44 #include "rcl_lifecycle/default_state_machine.h"
45 #include "rcl_lifecycle/visibility_control.h"
46 
48 
54 RCL_LIFECYCLE_PUBLIC
56 rcl_lifecycle_get_zero_initialized_state();
57 
59 
82 RCL_LIFECYCLE_PUBLIC
83 RCL_WARN_UNUSED
84 rcl_ret_t
85 rcl_lifecycle_state_init(
86  rcl_lifecycle_state_t * state,
87  unsigned int id,
88  const char * label,
89  const rcl_allocator_t * allocator);
90 
92 
111 RCL_LIFECYCLE_PUBLIC
112 RCL_WARN_UNUSED
113 rcl_ret_t
114 rcl_lifecycle_state_fini(
115  rcl_lifecycle_state_t * state,
116  const rcl_allocator_t * allocator);
117 
119 
123 RCL_LIFECYCLE_PUBLIC
125 rcl_lifecycle_get_zero_initialized_transition();
126 
128 
157 RCL_LIFECYCLE_PUBLIC
158 RCL_WARN_UNUSED
159 rcl_ret_t
160 rcl_lifecycle_transition_init(
161  rcl_lifecycle_transition_t * transition,
162  unsigned int id,
163  const char * label,
164  rcl_lifecycle_state_t * start,
165  rcl_lifecycle_state_t * goal,
166  const rcl_allocator_t * allocator);
167 
169 
187 RCL_LIFECYCLE_PUBLIC
188 RCL_WARN_UNUSED
189 rcl_ret_t
190 rcl_lifecycle_transition_fini(
191  rcl_lifecycle_transition_t * transition,
192  const rcl_allocator_t * allocator);
193 
195 
199 RCL_LIFECYCLE_PUBLIC
201 rcl_lifecycle_get_zero_initialized_state_machine();
202 
204 
234 RCL_LIFECYCLE_PUBLIC
235 RCL_WARN_UNUSED
236 rcl_ret_t
237 rcl_lifecycle_state_machine_init(
238  rcl_lifecycle_state_machine_t * state_machine,
239  rcl_node_t * node_handle,
240  const rosidl_message_type_support_t * ts_pub_notify,
241  const rosidl_service_type_support_t * ts_srv_change_state,
242  const rosidl_service_type_support_t * ts_srv_get_state,
243  const rosidl_service_type_support_t * ts_srv_get_available_states,
244  const rosidl_service_type_support_t * ts_srv_get_available_transitions,
245  const rosidl_service_type_support_t * ts_srv_get_transition_graph,
246  bool default_states,
247  const rcl_allocator_t * allocator);
248 
250 
269 RCL_LIFECYCLE_PUBLIC
270 RCL_WARN_UNUSED
271 rcl_ret_t
272 rcl_lifecycle_state_machine_fini(
273  rcl_lifecycle_state_machine_t * state_machine,
274  rcl_node_t * node_handle,
275  const rcl_allocator_t * allocator);
276 
278 
295 RCL_LIFECYCLE_PUBLIC
296 RCL_WARN_UNUSED
297 rcl_ret_t
298 rcl_lifecycle_state_machine_is_initialized(
299  const rcl_lifecycle_state_machine_t * state_machine);
300 
302 
318 RCL_LIFECYCLE_PUBLIC
319 RCL_WARN_UNUSED
321 rcl_lifecycle_get_transition_by_id(
322  const rcl_lifecycle_state_t * state,
323  uint8_t id);
324 
326 
342 RCL_LIFECYCLE_PUBLIC
343 RCL_WARN_UNUSED
345 rcl_lifecycle_get_transition_by_label(
346  const rcl_lifecycle_state_t * state,
347  const char * label);
348 
350 
370 RCL_LIFECYCLE_PUBLIC
371 RCL_WARN_UNUSED
372 rcl_ret_t
373 rcl_lifecycle_trigger_transition_by_id(
374  rcl_lifecycle_state_machine_t * state_machine,
375  uint8_t id,
376  bool publish_notification);
377 
379 
399 RCL_LIFECYCLE_PUBLIC
400 RCL_WARN_UNUSED
401 rcl_ret_t
402 rcl_lifecycle_trigger_transition_by_label(
403  rcl_lifecycle_state_machine_t * state_machine,
404  const char * label,
405  bool publish_notification);
406 
408 
422 RCL_LIFECYCLE_PUBLIC
423 void
424 rcl_print_state_machine(const rcl_lifecycle_state_machine_t * state_machine);
425 
426 #ifdef __cplusplus
427 }
428 #endif // extern "C"
429 
430 #endif // RCL_LIFECYCLE__RCL_LIFECYCLE_H_
rcl_node_t
rcl_lifecycle_state_t
It contains the state of the lifecycle state machine.
Definition: data_types.h:30
rosidl_service_type_support_t
rcl_lifecycle_state_machine_t
It contains the state machine data.
Definition: data_types.h:90
rcl_lifecycle_transition_t
It contains the transitions of the lifecycle state machine.
Definition: data_types.h:44
rosidl_message_type_support_t