ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
common.c
1 // Copyright 2015 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 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "./common.h" // NOLINT
21 
22 #include <stdlib.h>
23 
24 #include "rcl/allocator.h"
25 #include "rcl/error_handling.h"
26 
28 rcl_convert_rmw_ret_to_rcl_ret(rmw_ret_t rmw_ret)
29 {
30  switch (rmw_ret) {
31  case RMW_RET_OK:
32  return RCL_RET_OK;
33  case RMW_RET_INVALID_ARGUMENT:
35  case RMW_RET_BAD_ALLOC:
36  return RCL_RET_BAD_ALLOC;
37  case RMW_RET_UNSUPPORTED:
38  return RCL_RET_UNSUPPORTED;
39  case RMW_RET_NODE_NAME_NON_EXISTENT:
41  default:
42  return RCL_RET_ERROR;
43  }
44 }
45 
47 rcl_convert_rcutils_ret_to_rcl_ret(rcutils_ret_t rcutils_ret)
48 {
49  switch (rcutils_ret) {
50  case RCUTILS_RET_OK:
51  return RCL_RET_OK;
52  case RCUTILS_RET_ERROR:
53  return RCL_RET_ERROR;
54  case RCUTILS_RET_BAD_ALLOC:
55  return RCL_RET_BAD_ALLOC;
56  case RCUTILS_RET_INVALID_ARGUMENT:
58  case RCUTILS_RET_NOT_INITIALIZED:
59  return RCL_RET_NOT_INIT;
60  case RCUTILS_RET_NOT_FOUND:
61  return RCL_RET_NOT_FOUND;
62  default:
63  return RCL_RET_ERROR;
64  }
65 }
66 
67 #ifdef __cplusplus
68 }
69 #endif
#define RCL_RET_UNSUPPORTED
Unsupported return code.
Definition: types.h:37
#define RCL_RET_NOT_FOUND
Resource not found.
Definition: types.h:55
#define RCL_RET_NOT_INIT
rcl_init() not yet called return code.
Definition: types.h:43
#define RCL_RET_NODE_NAME_NON_EXISTENT
Failed to find node name.
Definition: types.h:65
#define RCL_RET_OK
Success return code.
Definition: types.h:27
#define RCL_RET_BAD_ALLOC
Failed to allocate memory return code.
Definition: types.h:33
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
Definition: types.h:35
#define RCL_RET_ERROR
Unspecified error return code.
Definition: types.h:29
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:24