rcl_lifecycle  master
C API providing common functionality for ROS lifecycle.
All Classes Namespaces Files Functions Variables Modules Pages
default_state_machine.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 
15 #ifndef RCL_LIFECYCLE__DEFAULT_STATE_MACHINE_H_
16 #define RCL_LIFECYCLE__DEFAULT_STATE_MACHINE_H_
17 
18 #include "rcl/macros.h"
19 #include "rcl/types.h"
20 
21 #include "rcl_lifecycle/data_types.h"
22 #include "rcl_lifecycle/visibility_control.h"
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 
29 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_configure_label;
30 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_cleanup_label;
31 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_activate_label;
32 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_deactivate_label;
33 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_shutdown_label;
34 
35 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_transition_success_label;
36 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_transition_failure_label;
37 RCL_LIFECYCLE_PUBLIC extern const char * rcl_lifecycle_transition_error_label;
38 
40 /*
41  * This function initializes a default state machine. It registers all: primary states,
42  * transition states, transitions and the initial state. The primary state is unconfigured.
43  *
44  * States: unknown, unconfigured, inactive, active and finalized.
45  * Transition states: configuring, cleaningup, activating, deactivating, errorprocessing
46  * and shuttingdown.
47  * Transitions:
48  * - unconfigured to configuring
49  * - unconfigured to shuttingdown
50  * - configuring to inactive
51  * - configuring to unconfigured
52  * - configuring to errorprocessing
53  * - inactive to activating
54  * - inactive to cleaningup
55  * - inactive to shuttingdown
56  * - cleaningup to unconfigured
57  * - cleaningup to inactive
58  * - cleaniningup to errorprocessing
59  * - activating to active
60  * - activating to inactive
61  * - activating to errorprocessing
62  * - active to deactivating
63  * - active to shuttingdown
64  * - deactivating to inactive
65  * - deactivating to active
66  * - deactivating to errorprocessing
67  * - shutting down to finalized
68  * - shutting down to finalized
69  * - shutting down to errorprocessing
70  * - errorprocessing to uncofigured
71  * - errorprocessing to finalized
72  * - errorprocessing to finalized
73  *
74  * <hr>
75  * Attribute | Adherence
76  * ------------------ | -------------
77  * Allocates Memory | Yes
78  * Thread-Safe | No
79  * Uses Atomics | No
80  * Lock-Free | Yes
81  *
82  * \param[inout] state_machine struct to be initialized
83  * \param[in] allocator a valid allocator used to initialized the state machine
84  * \return `RCL_RET_OK` if the state machine was initialized successfully, or
85  * \return `RCL_RET_ERROR` if an unspecified error occurs.
86  */
87 RCL_LIFECYCLE_PUBLIC
88 RCL_WARN_UNUSED
89 rcl_ret_t
90 rcl_lifecycle_init_default_state_machine(
91  rcl_lifecycle_state_machine_t * state_machine, const rcl_allocator_t * allocator);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif // RCL_LIFECYCLE__DEFAULT_STATE_MACHINE_H_
rcl_lifecycle_state_machine_t
It contains the state machine data.
Definition: data_types.h:90