moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
moveit_error_code.h
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2021, PickNik Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35#pragma once
36
37#include <moveit_msgs/msg/move_it_error_codes.hpp>
38#include <string>
39
40namespace moveit
41{
42namespace core
43{
47class MoveItErrorCode : public moveit_msgs::msg::MoveItErrorCodes
48{
49public:
50 MoveItErrorCode(const int code = moveit_msgs::msg::MoveItErrorCodes::UNDEFINED, const std::string& error_message = "",
51 const std::string& error_source = "")
52 {
53 val = code;
54 message = error_message;
55 source = error_source;
56 }
57 MoveItErrorCode(const moveit_msgs::msg::MoveItErrorCodes& code)
58 {
59 val = code.val;
60 message = code.message;
61 source = code.source;
62 }
63 explicit operator bool() const
64 {
65 return val == moveit_msgs::msg::MoveItErrorCodes::SUCCESS;
66 }
67 bool operator==(const int c) const
68 {
69 return val == c;
70 }
71 bool operator!=(const int c) const
72 {
73 return val != c;
74 }
75};
76
82inline std::string errorCodeToString(const MoveItErrorCode& error_code)
83{
84 switch (error_code.val)
85 {
86 case moveit::core::MoveItErrorCode::SUCCESS:
87 return std::string("SUCCESS");
88 case moveit::core::MoveItErrorCode::UNDEFINED:
89 return std::string("UNDEFINED");
90 case moveit::core::MoveItErrorCode::FAILURE:
91 return std::string("FAILURE");
92 case moveit::core::MoveItErrorCode::PLANNING_FAILED:
93 return std::string("PLANNING_FAILED");
94 case moveit::core::MoveItErrorCode::INVALID_MOTION_PLAN:
95 return std::string("INVALID_MOTION_PLAN");
96 case moveit::core::MoveItErrorCode::MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE:
97 return std::string("MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE");
98 case moveit::core::MoveItErrorCode::CONTROL_FAILED:
99 return std::string("CONTROL_FAILED");
100 case moveit::core::MoveItErrorCode::UNABLE_TO_AQUIRE_SENSOR_DATA:
101 return std::string("UNABLE_TO_AQUIRE_SENSOR_DATA");
102 case moveit::core::MoveItErrorCode::TIMED_OUT:
103 return std::string("TIMED_OUT");
104 case moveit::core::MoveItErrorCode::PREEMPTED:
105 return std::string("PREEMPTED");
106 case moveit::core::MoveItErrorCode::START_STATE_IN_COLLISION:
107 return std::string("START_STATE_IN_COLLISION");
108 case moveit::core::MoveItErrorCode::START_STATE_VIOLATES_PATH_CONSTRAINTS:
109 return std::string("START_STATE_VIOLATES_PATH_CONSTRAINTS");
110 case moveit::core::MoveItErrorCode::START_STATE_INVALID:
111 return std::string("START_STATE_INVALID");
112 case moveit::core::MoveItErrorCode::GOAL_IN_COLLISION:
113 return std::string("GOAL_IN_COLLISION");
114 case moveit::core::MoveItErrorCode::GOAL_VIOLATES_PATH_CONSTRAINTS:
115 return std::string("GOAL_VIOLATES_PATH_CONSTRAINTS");
116 case moveit::core::MoveItErrorCode::GOAL_CONSTRAINTS_VIOLATED:
117 return std::string("GOAL_CONSTRAINTS_VIOLATED");
118 case moveit::core::MoveItErrorCode::GOAL_STATE_INVALID:
119 return std::string("GOAL_STATE_INVALID");
120 case moveit::core::MoveItErrorCode::UNRECOGNIZED_GOAL_TYPE:
121 return std::string("UNRECOGNIZED_GOAL_TYPE");
122 case moveit::core::MoveItErrorCode::INVALID_GROUP_NAME:
123 return std::string("INVALID_GROUP_NAME");
124 case moveit::core::MoveItErrorCode::INVALID_GOAL_CONSTRAINTS:
125 return std::string("INVALID_GOAL_CONSTRAINTS");
126 case moveit::core::MoveItErrorCode::INVALID_ROBOT_STATE:
127 return std::string("INVALID_ROBOT_STATE");
128 case moveit::core::MoveItErrorCode::INVALID_LINK_NAME:
129 return std::string("INVALID_LINK_NAME");
130 case moveit::core::MoveItErrorCode::INVALID_OBJECT_NAME:
131 return std::string("INVALID_OBJECT_NAME");
132 case moveit::core::MoveItErrorCode::FRAME_TRANSFORM_FAILURE:
133 return std::string("FRAME_TRANSFORM_FAILURE");
134 case moveit::core::MoveItErrorCode::COLLISION_CHECKING_UNAVAILABLE:
135 return std::string("COLLISION_CHECKING_UNAVAILABLE");
136 case moveit::core::MoveItErrorCode::ROBOT_STATE_STALE:
137 return std::string("ROBOT_STATE_STALE");
138 case moveit::core::MoveItErrorCode::SENSOR_INFO_STALE:
139 return std::string("SENSOR_INFO_STALE");
140 case moveit::core::MoveItErrorCode::COMMUNICATION_FAILURE:
141 return std::string("COMMUNICATION_FAILURE");
142 case moveit::core::MoveItErrorCode::CRASH:
143 return std::string("CRASH");
144 case moveit::core::MoveItErrorCode::ABORT:
145 return std::string("ABORT");
146 case moveit::core::MoveItErrorCode::NO_IK_SOLUTION:
147 return std::string("NO_IK_SOLUTION");
148 }
149 return std::string("Unrecognized MoveItErrorCode. This should never happen!");
150}
151
152} // namespace core
153} // namespace moveit
a wrapper around moveit_msgs::MoveItErrorCodes to make it easier to return an error code message from...
MoveItErrorCode(const int code=moveit_msgs::msg::MoveItErrorCodes::UNDEFINED, const std::string &error_message="", const std::string &error_source="")
bool operator!=(const int c) const
MoveItErrorCode(const moveit_msgs::msg::MoveItErrorCodes &code)
bool operator==(const int c) const
std::string errorCodeToString(const MoveItErrorCode &error_code)
Convenience function to translated error message into string.
Main namespace for MoveIt.
Definition exceptions.h:43