6 msgs::ErrorStatus
operator+(
const msgs::ErrorStatus& lhs,
const msgs::ErrorStatus& rhs)
8 msgs::ErrorStatus result;
10 result.error = lhs.error | rhs.error;
11 result.error_msg = lhs.error_msg;
12 if (result.error_msg.size() && rhs.error_msg.size())
13 result.error_msg +=
"\n";
14 result.error_msg += rhs.error_msg;
16 result.warning = lhs.warning | rhs.warning;
17 result.warning_msg = lhs.warning_msg;
18 if (result.warning_msg.size() && rhs.warning_msg.size())
19 result.warning_msg +=
"\n";
20 result.warning_msg += rhs.warning_msg;
25 msgs::ErrorStatus
operator+=(msgs::ErrorStatus& lhs,
const msgs::ErrorStatus& rhs)
34 if (step_plan.steps.empty())
35 return msgs::ErrorStatus();
37 msgs::ErrorStatus status;
40 unsigned int step_index = step_plan.steps.front().step_index;
41 for (std::vector<msgs::Step>::const_iterator itr = step_plan.steps.begin(); itr != step_plan.steps.end(); itr++)
43 if (itr->header.frame_id != step_plan.header.frame_id)
44 status +=
ErrorStatusError(msgs::ErrorStatus::ERR_INCONSISTENT_STEP_PLAN,
"isConsistent",
"Frame id mismatch! Plan: " + step_plan.header.frame_id +
" vs. step: " + itr->header.frame_id);
46 if (itr->step_index != step_index++)
47 status +=
ErrorStatusWarning(msgs::ErrorStatus::WARN_INCOMPLETE_STEP_PLAN,
"isConsistent",
"Wrong step index order: Expected " + boost::lexical_cast<std::string>(step_index-1) +
" but got " + boost::lexical_cast<std::string>(itr->step_index) +
"!");
50 status +=
ErrorStatusWarning(msgs::ErrorStatus::WARN_INVALID_STEP_PLAN,
"isConsistent",
"Step " + boost::lexical_cast<std::string>(itr->step_index) +
" invalid!");
60 case msgs::ErrorStatus::NO_ERROR:
return "NO_ERROR";
61 case msgs::ErrorStatus::ERR_UNKNOWN:
return "ERR_UNKNOWN";
62 case msgs::ErrorStatus::ERR_NO_SOLUTION:
return "ERR_NO_SOLUTION";
63 case msgs::ErrorStatus::ERR_INVALID_START:
return "ERR_INVALID_START";
64 case msgs::ErrorStatus::ERR_INVALID_GOAL:
return "ERR_INVALID_GOAL";
65 case msgs::ErrorStatus::ERR_INVALID_GRID_MAP:
return "ERR_INVALID_GRID_MAP";
66 case msgs::ErrorStatus::ERR_INVALID_TERRAIN_MODEL:
return "ERR_INVALID_TERRAIN_MODEL";
67 case msgs::ErrorStatus::ERR_INVALID_STEP:
return "ERR_INVALID_STEP";
68 case msgs::ErrorStatus::ERR_INCONSISTENT_STEP_PLAN:
return "ERR_INCONSISTENT_STEP_PLAN";
69 case msgs::ErrorStatus::ERR_INVALID_PARAMETERS:
return "ERR_INVALID_PARAMETERS";
70 case msgs::ErrorStatus::ERR_NO_PLUGIN_AVAILABLE:
return "ERR_NO_PLUGIN_AVAILABLE";
71 case msgs::ErrorStatus::ERR_INCONSISTENT_REQUEST:
return "ERR_INCONSISTENT_REQUEST";
72 default:
return "ERR_UNKNOWN";
80 case msgs::ErrorStatus::NO_WARNING:
return "NO_WARNING";
81 case msgs::ErrorStatus::WARN_UNKNOWN:
return "WARN_UNKNOWN";
82 case msgs::ErrorStatus::WARN_INCOMPLETE_STEP_PLAN:
return "WARN_INCOMPLETE_STEP_PLAN";
83 case msgs::ErrorStatus::WARN_INVALID_STEP_PLAN:
return "WARN_INVALID_STEP_PLAN";
84 default:
return "WARN_UNKNOWN";
88 msgs::ErrorStatus
createErrorStatus(
const std::string& context,
unsigned int error,
const std::string& error_msg,
unsigned int warning,
const std::string& warning_msg,
bool output,
double throttle_rate)
92 if (throttle_rate > 0.0)
108 msgs::ErrorStatus status;
109 status.error = error;
110 status.error_msg = error != msgs::ErrorStatus::NO_ERROR ?
"[" +
ErrorStatusCodeToString(error) +
"][" + context +
"] " + error_msg : error_msg;
111 status.warning = warning;
112 status.warning_msg = warning != msgs::ErrorStatus::NO_WARNING ?
"[" +
WarningStatusCodeToString(warning) +
"][" + context +
"] " + warning_msg : warning_msg;
116 msgs::ErrorStatus
ErrorStatusError(
unsigned int error,
const std::string& context,
const std::string& error_msg,
bool output,
double throttle_rate)
118 return createErrorStatus(context, error, error_msg, msgs::ErrorStatus::NO_WARNING,
"", output, throttle_rate);
121 msgs::ErrorStatus
ErrorStatusWarning(
unsigned int warning,
const std::string& context,
const std::string& warning_msg,
bool output,
double throttle_rate)
123 return createErrorStatus(context, msgs::ErrorStatus::NO_ERROR,
"", warning, warning_msg, output, throttle_rate);
128 return status.error != msgs::ErrorStatus::NO_ERROR;
133 return status.warning != msgs::ErrorStatus::NO_WARNING;
136 bool isOk(
const msgs::ErrorStatus& status)
141 std::string
toString(
const msgs::ErrorStatus& error_status)
145 if (error_status.error_msg.size())
146 msg = error_status.error_msg;
148 if (error_status.warning_msg.size())
152 msg = error_status.warning_msg;
158 std::string
toString(
const msgs::FootstepExecutionStatus& execution_status)
160 if (!execution_status.status)
165 if (execution_status.status & msgs::FootstepExecutionStatus::REACHED_GOAL)
166 msg +=
"REACHED_GOAL ";
167 if (execution_status.status & msgs::FootstepExecutionStatus::WAITING_FOR_ATLAS)
168 msg +=
"WAITING_FOR_ATLAS ";
169 if (execution_status.status & msgs::FootstepExecutionStatus::EXECUTING_STEP_PLAN)
170 msg +=
"EXECUTING_STEP_PLAN ";
171 if (execution_status.status & msgs::FootstepExecutionStatus::PREMATURE_HALT)
172 msg +=
"PREMATURE_HALT ";
173 if (execution_status.status & msgs::FootstepExecutionStatus::UPDATED_STEP_PLAN)
174 msg +=
"UPDATED_STEP_PLAN ";
175 if (execution_status.status & msgs::FootstepExecutionStatus::EMERGENCY_HALT)
176 msg +=
"EMERGENCY_HALT ";
177 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_UNKNOWN)
178 msg +=
"ERR_UNKNOWN ";
179 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_EMPTY_PLAN)
180 msg +=
"ERR_EMPTY_PLAN ";
181 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_INVALID_BEHAVIOR_MODE)
182 msg +=
"ERR_INVALID_BEHAVIOR_MODE ";
183 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_INVALID_PLAN)
184 msg +=
"ERR_INVALID_PLAN ";
185 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_INVALID_INCONSISTENT_INDICES)
186 msg +=
"ERR_INVALID_INCONSISTENT_INDICES ";
187 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_INCONSISTENT_STEP_PLAN)
188 msg +=
"ERR_INCONSISTENT_STEP_PLAN ";
189 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_CONTROLLER_NOT_READY)
190 msg +=
"ERR_CONTROLLER_NOT_READY ";
191 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_FALLEN)
192 msg +=
"ERR_FALLEN ";
193 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_NON_ZERO_INITIAL_STEP)
194 msg +=
"ERR_NON_ZERO_INITIAL_STEP ";
195 if (execution_status.status & msgs::FootstepExecutionStatus::ERR_NEXT_ERROR)
196 msg +=
"ERR_NEXT_ERROR ";
#define ROS_WARN_THROTTLE(rate,...)
#define ROS_ERROR_THROTTLE(rate,...)