Skip to content
Snippets Groups Projects
Commit 8b4c8220 authored by Peter Albrecht's avatar Peter Albrecht
Browse files

Implemented re-running a Skill with similar parameters

parent 1e2b9b43
No related branches found
No related tags found
No related merge requests found
...@@ -95,12 +95,17 @@ namespace armarx ...@@ -95,12 +95,17 @@ namespace armarx
currentStatus == skills::SkillStatus::Failed || currentStatus == skills::SkillStatus::Failed ||
currentStatus == skills::SkillStatus::Succeeded); currentStatus == skills::SkillStatus::Succeeded);
// TODO: re-run with similar params; remove skill entry (if finished) QAction* rerunSkillAction = new QAction("Re-run with similar params", this);
menu->addAction(stopSkillAction); menu->addAction(stopSkillAction);
menu->addAction(rerunSkillAction);
connect(stopSkillAction, connect(stopSkillAction,
&QAction::triggered, &QAction::triggered,
this, this,
&SkillManagerMonitorWidgetController::stopSkill); &SkillManagerMonitorWidgetController::stopSkill);
connect(rerunSkillAction,
&QAction::triggered,
this,
&SkillManagerMonitorWidgetController::rerunSkillWithSimilarParams);
// open menu // open menu
menu->popup(widget.treeWidgetSkillExecutions->viewport()->mapToGlobal(pos)); menu->popup(widget.treeWidgetSkillExecutions->viewport()->mapToGlobal(pos));
} }
...@@ -168,7 +173,7 @@ namespace armarx ...@@ -168,7 +173,7 @@ namespace armarx
connect(widget.pushButtonExecuteSkill, connect(widget.pushButtonExecuteSkill,
&QPushButton::clicked, &QPushButton::clicked,
this, this,
&SkillManagerMonitorWidgetController::executeSkill); &SkillManagerMonitorWidgetController::executeSelectedSkill);
connect(widget.treeWidgetSkills, connect(widget.treeWidgetSkills,
&QTreeWidget::currentItemChanged, &QTreeWidget::currentItemChanged,
...@@ -396,8 +401,10 @@ namespace armarx ...@@ -396,8 +401,10 @@ namespace armarx
auto executionId = skills::SkillExecutionID::FromIce(k); auto executionId = skills::SkillExecutionID::FromIce(k);
auto statusUpdate = skills::SkillStatusUpdate::FromIce(v); auto statusUpdate = skills::SkillStatusUpdate::FromIce(v);
// update snapshot // update maps
skillStatusUpdates.insert_or_assign(executionId, statusUpdate); skillStatusUpdates.insert_or_assign(executionId, statusUpdate);
skillExecutionParams.insert_or_assign(executionId,
statusUpdate.usedParameterization);
SkillExecutionInfoTreeWidgetItem* found = nullptr; SkillExecutionInfoTreeWidgetItem* found = nullptr;
for (int i = 0; i < widget.treeWidgetSkillExecutions->topLevelItemCount(); ++i) for (int i = 0; i < widget.treeWidgetSkillExecutions->topLevelItemCount(); ++i)
...@@ -468,31 +475,41 @@ namespace armarx ...@@ -468,31 +475,41 @@ namespace armarx
} }
void void
SkillManagerMonitorWidgetController::executeSkill() SkillManagerMonitorWidgetController::executeSelectedSkill()
{ {
if (not selectedSkill.skillId.fullySpecified()) auto data = getConfigAsAron();
{ executeSkillWithParams(selectedSkill.skillId, data);
return; }
}
void
SkillManagerMonitorWidgetController::rerunSkillWithSimilarParams()
{
skills::SkillParameterization selectedExecutionParams =
skillExecutionParams.at(selectedSkill.skillExecutionId);
executeSkillWithParams(selectedSkill.skillExecutionId.skillId,
selectedExecutionParams.parameterization);
}
void
SkillManagerMonitorWidgetController::executeSkillWithParams(skills::SkillID skillId,
aron::data::DictPtr params)
{
std::scoped_lock l(updateMutex); std::scoped_lock l(updateMutex);
auto providerId = skills::ProviderID(selectedSkill.skillId); auto providerId = skills::ProviderID(skillId);
const auto& skillDescriptions = skills.at(providerId); const auto& skillDescriptions = skills.at(providerId);
if (skillDescriptions.find(selectedSkill.skillId) == skillDescriptions.end()) if (skillDescriptions.find(skillId) == skillDescriptions.end())
{ {
return; return;
} }
auto data = getConfigAsAron();
char hostname[HOST_NAME_MAX]; char hostname[HOST_NAME_MAX];
gethostname(hostname, HOST_NAME_MAX); gethostname(hostname, HOST_NAME_MAX);
skills::SkillExecutionRequest req(selectedSkill.skillId, skills::SkillExecutionRequest req(selectedSkill.skillId,
"Skills.Manager GUI (hostname: " + std::string(hostname) + "Skills.Manager GUI (hostname: " + std::string(hostname) +
")", ")",
data); params);
ARMARX_CHECK(selectedSkill.skillId.fullySpecified()); // sanity check ARMARX_CHECK(selectedSkill.skillId.fullySpecified()); // sanity check
ARMARX_IMPORTANT << "Executing skill from GUI: " << selectedSkill.skillId << "."; ARMARX_IMPORTANT << "Executing skill from GUI: " << selectedSkill.skillId << ".";
......
...@@ -119,7 +119,7 @@ namespace armarx ...@@ -119,7 +119,7 @@ namespace armarx
void skillExecutionSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); void skillExecutionSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
void stopSkill(); void stopSkill();
void executeSkill(); void executeSelectedSkill();
void updateTimerFrequency(); void updateTimerFrequency();
void refreshSkills(); void refreshSkills();
...@@ -131,6 +131,7 @@ namespace armarx ...@@ -131,6 +131,7 @@ namespace armarx
void resetCurrentConfig(); void resetCurrentConfig();
void prepareAndRunMenu(const QPoint& pos); void prepareAndRunMenu(const QPoint& pos);
void rerunSkillWithSimilarParams();
private: private:
...@@ -151,6 +152,8 @@ namespace armarx ...@@ -151,6 +152,8 @@ namespace armarx
std::map<skills::ProviderID, std::map<skills::SkillID, skills::SkillDescription>> skills = std::map<skills::ProviderID, std::map<skills::SkillID, skills::SkillDescription>> skills =
{}; {};
std::map<skills::SkillExecutionID, skills::SkillStatusUpdate> skillStatusUpdates = {}; std::map<skills::SkillExecutionID, skills::SkillStatusUpdate> skillStatusUpdates = {};
// store copies (!) of skill descriptions
std::map<skills::SkillExecutionID, skills::SkillParameterization> skillExecutionParams = {};
// User Input // User Input
struct SelectedSkill struct SelectedSkill
...@@ -168,6 +171,8 @@ namespace armarx ...@@ -168,6 +171,8 @@ namespace armarx
} }
} selectedSkill; } selectedSkill;
void executeSkillWithParams(skills::SkillID skillId, aron::data::DictPtr params);
// Helper to get the treeWidgetItem easily // Helper to get the treeWidgetItem easily
QTreeWidgetItem* skillsArgumentsTreeWidgetItem = nullptr; QTreeWidgetItem* skillsArgumentsTreeWidgetItem = nullptr;
AronTreeWidgetControllerPtr aronTreeWidgetController = nullptr; AronTreeWidgetControllerPtr aronTreeWidgetController = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment