rclcpp_action  master
C++ ROS Action Client Library
types.hpp
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 RCLCPP_ACTION__TYPES_HPP_
16 #define RCLCPP_ACTION__TYPES_HPP_
17 
18 #include <rcl_action/types.h>
19 
20 #include <action_msgs/msg/goal_status.hpp>
21 #include <action_msgs/msg/goal_info.hpp>
22 
23 #include <climits>
24 #include <functional>
25 #include <string>
26 
28 
29 namespace rclcpp_action
30 {
31 
35 
39 to_string(const GoalUUID & goal_id);
40 
41 // Convert C++ GoalID to rcl_action_goal_info_t
43 void
44 convert(const GoalUUID & goal_id, rcl_action_goal_info_t * info);
45 
46 // Convert rcl_action_goal_info_t to C++ GoalID
48 void
49 convert(const rcl_action_goal_info_t & info, GoalUUID * goal_id);
50 } // namespace rclcpp_action
51 
52 namespace std
53 {
54 template<>
56 {
57  bool operator()(
58  const rclcpp_action::GoalUUID & lhs,
59  const rclcpp_action::GoalUUID & rhs) const
60  {
61  return lhs < rhs;
62  }
63 };
64 
66 template<>
68 {
69  size_t operator()(const rclcpp_action::GoalUUID & uuid) const noexcept
70  {
71  // TODO(sloretz) Use someone else's hash function and cite it
72  size_t result = 0;
73  for (size_t i = 0; i < uuid.size(); ++i) {
74  for (size_t b = 0; b < sizeof(size_t); ++b) {
75  size_t part = uuid[i];
76  part <<= CHAR_BIT * b;
77  result ^= part;
78  }
79  }
80  return result;
81  }
82 };
83 } // namespace std
84 #endif // RCLCPP_ACTION__TYPES_HPP_
rclcpp_action::to_string
RCLCPP_ACTION_PUBLIC std::string to_string(const GoalUUID &goal_id)
Convert a goal id to a human readable string.
std::string
rclcpp_action::GoalUUID
std::array< uint8_t, UUID_SIZE > GoalUUID
Definition: types.hpp:32
std::less
rclcpp_action
Definition: client.hpp:44
std::hash< rclcpp_action::GoalUUID >::operator()
size_t operator()(const rclcpp_action::GoalUUID &uuid) const noexcept
Definition: types.hpp:69
rclcpp_action::GoalStatus
action_msgs::msg::GoalStatus GoalStatus
Definition: types.hpp:33
std::less< rclcpp_action::GoalUUID >::operator()
bool operator()(const rclcpp_action::GoalUUID &lhs, const rclcpp_action::GoalUUID &rhs) const
Definition: types.hpp:57
std::array
rclcpp_action::GoalInfo
action_msgs::msg::GoalInfo GoalInfo
Definition: types.hpp:34
rclcpp_action::convert
RCLCPP_ACTION_PUBLIC void convert(const GoalUUID &goal_id, rcl_action_goal_info_t *info)
visibility_control.hpp
std
RCLCPP_ACTION_PUBLIC
#define RCLCPP_ACTION_PUBLIC
Definition: visibility_control.hpp:50
std::size_t
std::hash