rcl_action  master
C API providing common functionality for ROS actions.
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 
97 // Description variables in types.c should be changed if enum values change
98 extern const char * goal_state_descriptions[];
99 extern const char * goal_event_descriptions[];
100 
103 {
111 
115 rcl_action_goal_info_t
117 
119 
127 
129 
136 rcl_action_cancel_request_t
138 
140 
148 
150 
194 rcl_ret_t
196  rcl_action_goal_status_array_t * status_array,
197  const size_t num_status,
198  const rcl_allocator_t allocator);
199 
201 
219 rcl_ret_t
221 
223 
267 rcl_ret_t
269  rcl_action_cancel_response_t * cancel_response,
270  const size_t num_goals_canceling,
271  const rcl_allocator_t allocator);
272 
274 
292 rcl_ret_t
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #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 zero values.
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
const char * goal_state_descriptions[]
User friendly error messages for invalid trasntions.
const char * goal_event_descriptions[]
Structure which encapsulates a ROS Action Server.
Definition: action_server.h:36
action_msgs__srv__CancelGoal_Response msg
Definition: types.h:77
action_msgs__msg__GoalStatusArray msg
Definition: types.h:70
Definition: types.h:104
#define RCL_WARN_UNUSED
Definition: types.h:106
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:102
Definition: types.h:108
Definition: types.h:105
Definition: types.h:107
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:109
action_msgs__msg__GoalStatus rcl_action_goal_status_t
Definition: types.h:67
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