rcl_action  master
C API providing common functionality for ROS actions.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
types.h
Go to the documentation of this file.
1 // Copyright 2018 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_ACTION__TYPES_H_
16 #define RCL_ACTION__TYPES_H_
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
24 
25 #include "action_msgs/msg/goal_info.h"
26 #include "action_msgs/msg/goal_status.h"
27 #include "action_msgs/msg/goal_status_array.h"
28 #include "action_msgs/srv/cancel_goal.h"
29 
30 #include "rcl/allocator.h"
31 #include "rcl/macros.h"
32 #include "rcl/types.h"
33 
34 #include "rosidl_generator_c/action_type_support_struct.h"
35 
36 // rcl action specific ret codes in 2XXX
38 #define RCL_RET_ACTION_NAME_INVALID 2000
39 #define RCL_RET_ACTION_GOAL_ACCEPTED 2100
41 #define RCL_RET_ACTION_GOAL_REJECTED 2101
43 #define RCL_RET_ACTION_CLIENT_INVALID 2102
45 #define RCL_RET_ACTION_CLIENT_TAKE_FAILED 2103
47 #define RCL_RET_ACTION_SERVER_INVALID 2200
49 #define RCL_RET_ACTION_SERVER_TAKE_FAILED 2201
51 #define RCL_RET_ACTION_GOAL_HANDLE_INVALID 2300
53 #define RCL_RET_ACTION_GOAL_EVENT_INVALID 2301
55 
56 // TODO(jacobperron): Move these to a common place for UUIDs
57 #define UUID_SIZE 16
58 #define uuidcmp(uuid0, uuid1) (0 == memcmp(uuid0, uuid1, UUID_SIZE))
59 #define zerouuid (uint8_t[UUID_SIZE]) {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
60 #define uuidcmpzero(uuid) uuidcmp(uuid, (zerouuid))
61 
62 // Forward declare
64 
65 // Typedef generated messages for convenience
66 typedef action_msgs__msg__GoalInfo rcl_action_goal_info_t;
67 typedef action_msgs__msg__GoalStatus rcl_action_goal_status_t;
69 {
70  action_msgs__msg__GoalStatusArray msg;
74 typedef action_msgs__srv__CancelGoal_Request rcl_action_cancel_request_t;
76 {
77  action_msgs__srv__CancelGoal_Response msg;
81 
83 // TODO(jacobperron): Let states be defined by action_msgs/msg/goal_status.h
84 // Ideally, we could use an enum type directly from the message when the feature
85 // is available. Issue: https://github.com/ros2/rosidl/issues/260
86 typedef int8_t rcl_action_goal_state_t;
87 #define GOAL_STATE_UNKNOWN action_msgs__msg__GoalStatus__STATUS_UNKNOWN
88 #define GOAL_STATE_ACCEPTED action_msgs__msg__GoalStatus__STATUS_ACCEPTED
89 #define GOAL_STATE_EXECUTING action_msgs__msg__GoalStatus__STATUS_EXECUTING
90 #define GOAL_STATE_CANCELING action_msgs__msg__GoalStatus__STATUS_CANCELING
91 #define GOAL_STATE_SUCCEEDED action_msgs__msg__GoalStatus__STATUS_SUCCEEDED
92 #define GOAL_STATE_CANCELED action_msgs__msg__GoalStatus__STATUS_CANCELED
93 #define GOAL_STATE_ABORTED action_msgs__msg__GoalStatus__STATUS_ABORTED
94 #define GOAL_STATE_NUM_STATES 7
95 
98 {
106 
108 
114 rcl_action_goal_info_t
116 
118 
126 
128 
135 rcl_action_cancel_request_t
137 
139 
147 
149 
193 rcl_ret_t
195  rcl_action_goal_status_array_t * status_array,
196  const size_t num_status,
197  const rcl_allocator_t allocator);
198 
200 
218 rcl_ret_t
220 
222 
266 rcl_ret_t
268  rcl_action_cancel_response_t * cancel_response,
269  const size_t num_goals_canceling,
270  const rcl_allocator_t allocator);
271 
273 
291 rcl_ret_t
293 
294 #ifdef __cplusplus
295 }
296 #endif
297 
298 #endif // RCL_ACTION__TYPES_H_
rcl_allocator_t allocator
Allocator used to initialize this struct.
Definition: types.h:72
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_fini(rcl_action_goal_status_array_t *status_array)
Finalize a rcl_action_goal_status_array_t.
RCL_ACTION_PUBLIC rcl_action_cancel_response_t rcl_action_get_zero_initialized_cancel_response(void)
Return a rcl_action_cancel_response_t with members set to NULL.
RCL_ACTION_PUBLIC rcl_action_goal_info_t rcl_action_get_zero_initialized_goal_info(void)
Return a rcl_action_goal_info_t with members set to NULL.
int8_t rcl_action_goal_state_t
Goal states.
Definition: types.h:86
#define RCL_ACTION_PUBLIC
Definition: visibility_control.h:50
rmw_ret_t rcl_ret_t
Structure which encapsulates a ROS Action Server.
Definition: action_server.h:36
action_msgs__srv__CancelGoal_Response msg
Definition: types.h:77
Definition: types.h:101
action_msgs__msg__GoalStatusArray msg
Definition: types.h:70
Definition: types.h:99
Definition: types.h:103
#define RCL_WARN_UNUSED
RCL_ACTION_PUBLIC rcl_action_cancel_request_t rcl_action_get_zero_initialized_cancel_request(void)
Return a rcl_action_cancel_request_t with members set to NULL.
struct rcl_action_cancel_response_t rcl_action_cancel_response_t
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_fini(rcl_action_cancel_response_t *cancel_response)
Finalize a rcl_action_cancel_response_t.
action_msgs__msg__GoalInfo rcl_action_goal_info_t
Definition: types.h:66
RCL_ACTION_PUBLIC rcl_action_goal_status_array_t rcl_action_get_zero_initialized_goal_status_array(void)
Return a rcl_action_goal_status_array_t with members set to NULL.
rcl_allocator_t allocator
Allocator used to initialize this struct.
Definition: types.h:79
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_cancel_response_init(rcl_action_cancel_response_t *cancel_response, const size_t num_goals_canceling, const rcl_allocator_t allocator)
Initialize a rcl_action_cancel_response_t.
rcl_action_goal_event_t
Goal state transition events.
Definition: types.h:97
action_msgs__srv__CancelGoal_Request rcl_action_cancel_request_t
Definition: types.h:74
Definition: types.h:68
Definition: types.h:75
Definition: types.h:104
action_msgs__msg__GoalStatus rcl_action_goal_status_t
Definition: types.h:67
Definition: types.h:102
RCL_ACTION_PUBLIC rcl_ret_t rcl_action_goal_status_array_init(rcl_action_goal_status_array_t *status_array, const size_t num_status, const rcl_allocator_t allocator)
Initialize a rcl_action_goal_status_array_t.
struct rcl_action_goal_status_array_t rcl_action_goal_status_array_t
Definition: types.h:100