56 TaskOutcomeDebugger::run()
60 ARMARX_INFO <<
" commit <taskName> <taskType> <outcome> [errorMessage]";
61 ARMARX_INFO <<
" taskType: GRASPING_FAMILIAR, GRASPING_KNOWN, MANIPULATION,";
62 ARMARX_INFO <<
" VERBALIZATION, DETECTION, NAVIGATION, SPEAKING,";
64 ARMARX_INFO <<
" outcome: SUCCESS, FAILURE, ABORTED, SUSPENDED, UNKNOWN";
65 ARMARX_INFO <<
" Example: commit grasp_cup GRASPING_FAMILIAR SUCCESS";
66 ARMARX_INFO <<
" Example: commit grasp_cup GRASPING_KNOWN FAILURE gripper_timeout";
68 ARMARX_INFO <<
" read_type <taskType> - read outcomes by task type";
69 ARMARX_INFO <<
" read_failures - read only failures";
75 if (command ==
"commit")
79 else if (command ==
"read")
83 else if (command ==
"read_type")
87 else if (command ==
"read_failures")
89 readFailuresCommand();
91 else if (command ==
"exit")
104 TaskOutcomeDebugger::commitCommand()
107 std::string restOfLine;
108 std::getline(std::cin, restOfLine);
110 std::istringstream iss(restOfLine);
111 std::string taskName, taskTypeStr, outcomeStr;
113 iss >> taskName >> taskTypeStr >> outcomeStr;
115 if (taskName.empty() || taskTypeStr.empty() || outcomeStr.empty())
118 <<
"Usage: commit <taskName> <taskType> <outcome> [errorMessage]";
122 auto taskType = parseTaskType(taskTypeStr);
123 auto outcomeType = parseOutcomeType(outcomeStr);
126 simox::alg::to_upper(outcomeStr) !=
"UNKNOWN")
128 ARMARX_WARNING <<
"Unknown outcome type: " << outcomeStr <<
". Using UNKNOWN.";
132 simox::alg::to_upper(taskTypeStr) !=
"UNKNOWN")
134 ARMARX_WARNING <<
"Unknown task type: " << taskTypeStr <<
". Using UNKNOWN.";
138 std::optional<std::string> errorMsg;
139 std::string remaining;
140 if (std::getline(iss >> std::ws, remaining) && !remaining.empty())
142 errorMsg = remaining;
145 commitOutcome(taskName, taskType, outcomeType, errorMsg);
149 TaskOutcomeDebugger::readAllCommand()
151 armem::task_outcome::client::TaskOutcomeReader::Query query = {
153 .taskTypeFilter = std::nullopt,
154 .outcomeFilter = std::nullopt,
158 auto result = reader.query(query);
162 ARMARX_WARNING <<
"Failed to read task outcomes: " << result.errorMessage;
166 if (result.outcomes.empty())
168 ARMARX_INFO <<
"No task outcomes found in memory.";
172 ARMARX_INFO <<
"Task outcomes in memory (" << result.outcomes.size() <<
" total):";
173 printOutcomes(result.outcomes);
177 TaskOutcomeDebugger::readByTypeCommand()
179 std::string taskTypeStr;
180 std::cin >> taskTypeStr;
182 if (taskTypeStr.empty())
188 auto taskType = parseTaskType(taskTypeStr);
193 if (outcomes.empty())
196 << taskTypeToString(taskType) <<
"'.";
200 ARMARX_INFO <<
"Task outcomes of type '" << taskTypeToString(taskType) <<
"' ("
201 << outcomes.size() <<
" total):";
202 printOutcomes(outcomes);
206 TaskOutcomeDebugger::readFailuresCommand()
210 if (outcomes.empty())
216 ARMARX_INFO <<
"Failures in memory (" << outcomes.size() <<
" total):";
217 printOutcomes(outcomes);
221 TaskOutcomeDebugger::commitOutcome(
222 const std::string& taskName,
225 const std::optional<std::string>& errorMessage)
227 armem::task_outcome::TaskOutcome outcome;
231 outcome.
agent =
"ARMAR-7";
245 armem::task_outcome::FailureInfo fi;
254 {
"approach_direction",
"left"},
255 {
"gripper",
"right_hand"}};
257 {
"attempt_number",
"3"},
258 {
"planner",
"grasp_planner_v2"}};
263 std::vector<std::string>{
"cup_01",
"plate_02",
"bowl_03"};
269 std::vector<std::string>{
"cup_01"};
272 ARMARX_INFO <<
"Committing task outcome: taskName='" << taskName
273 <<
"' taskType=" << taskTypeToString(taskType)
274 <<
" outcome=" << outcomeTypeToString(outcomeType)
275 <<
" agent='" << outcome.
agent <<
"'"
277 << (errorMessage.has_value()
278 ?
" error='" + errorMessage.value() +
"'"
286 ARMARX_INFO <<
"Successfully committed task outcome.";
295 TaskOutcomeDebugger::printOutcomes(
296 const std::vector<armem::task_outcome::TaskOutcome>& outcomes)
298 for (
const auto& outcome : outcomes)
319 << failureTypeToString(outcome.
failureInfo->failureType);
320 if (outcome.
failureInfo->specialFailureDescription.has_value())
323 << outcome.
failureInfo->specialFailureDescription.value();
388 TaskOutcomeDebugger::parseOutcomeType(
const std::string&
str)
390 std::string upper = simox::alg::to_upper(
str);
392 if (upper ==
"SUCCESS")
394 if (upper ==
"FAILURE")
396 if (upper ==
"ABORTED")
398 if (upper ==
"SUSPENDED")
405 TaskOutcomeDebugger::parseTaskType(
const std::string&
str)
407 std::string upper = simox::alg::to_upper(
str);
409 if (upper ==
"GRASPING_FAMILIAR")
411 if (upper ==
"GRASPING_KNOWN")
413 if (upper ==
"MANIPULATION")
415 if (upper ==
"VERBALIZATION")
417 if (upper ==
"DETECTION")
419 if (upper ==
"NAVIGATION")
421 if (upper ==
"SPEAKING")
423 if (upper ==
"SPECIAL")
454 return "GRASPING_FAMILIAR";
456 return "GRASPING_KNOWN";
458 return "MANIPULATION";
460 return "VERBALIZATION";
476 TaskOutcomeDebugger::failureTypeToString(
const armem::task_outcome::FailureType& type)
478 std::vector<std::string> active;
481 active.push_back(
"Planning: NoTrajectoryFound");
483 active.push_back(
"Planning: NoGraspFound");
485 active.push_back(
"Planning: Special");
488 active.push_back(
"Knowledge/Perception: ObjectNotDetected");
490 active.push_back(
"Knowledge/Perception: CameraNotWorking");
492 active.push_back(
"Knowledge/Retrieval: TechnicalFailure");
494 active.push_back(
"Knowledge/Retrieval: KnowledgeNotInMemory");
497 active.push_back(
"Execution: RobotNotMoving");
499 active.push_back(
"Execution: HandNotClosing");
501 active.push_back(
"Execution: GraspingFailureDetected");
504 active.push_back(
"Interaction: NoHumanForHandover");
506 active.push_back(
"Interaction: DesiredObjectNotAtLocation");
508 active.push_back(
"Interaction: CommunicationFailure");
511 active.push_back(
"Interruption: UserStopped");
522 for (
size_t i = 0; i < active.size(); ++i)
540 return "TaskOutcomeDebugger";
std::optional< std::string > naturalLanguageDescription
std::map< std::string, std::string > parameters
std::map< std::string, std::string > additional