Skip to content
Snippets Groups Projects
Commit 1f984a2e authored by Tommy Persson's avatar Tommy Persson
Browse files

start_execution method added

parent e250e6c2
No related branches found
No related tags found
No related merge requests found
...@@ -34,54 +34,12 @@ void MissionObject::set_title(std::string str) { ...@@ -34,54 +34,12 @@ void MissionObject::set_title(std::string str) {
title = str; title = str;
} }
bool MissionObject::delegation(bool display_flag, bool exectree_flag) { bool MissionObject::start_execution (bool display_flag) {
//
// Display tree
//
std::string ns = ros::names::clean (ros::this_node::getNamespace()); std::string ns = ros::names::clean (ros::this_node::getNamespace());
display_tree (ns, title + " - before delegation", root_id); display_tree (ns, title + " - execution", root_id);
std::string fail_reason;
std::string cid = delegation_process_until_proposal();
if (cid != "") {
ROS_INFO ("WE HAVE A PROPOSAL");
} else {
ROS_ERROR("missionobject::could not get a proposal");
return false;
}
if (!delegation_process_approved_part(cid, fail_reason)) {
ROS_ERROR("Failed in approved part: %s", fail_reason.c_str());
return false;
}
display_tree (ns, title + " - after delegation", root_id);
//
// Save the dot file
//
#if 0
std::string dotstr = get_tst_string(ns, rootid,
lrs_srvs_tst::TSTGetTreeString::Request::FORMAT_DOT);
std::ofstream dotout("/tmp/terra_house_scan_example.dot");
dotout << dotstr << std::endl;
#endif
if (!exectree_flag) {
return true;
}
//
// Start execution
//
ROS_INFO("DELEGATION FINISHED - STARTING EXECUTION PHASE");
if (!distribute_tree(ns, root_id)) { if (!distribute_tree(ns, root_id)) {
ROS_ERROR("Failed to distribute tree"); ROS_ERROR("Failed to distribute tree");
return false; return false;
...@@ -146,6 +104,58 @@ bool MissionObject::delegation(bool display_flag, bool exectree_flag) { ...@@ -146,6 +104,58 @@ bool MissionObject::delegation(bool display_flag, bool exectree_flag) {
return true; return true;
} }
bool MissionObject::delegation(bool display_flag, bool exectree_flag) {
//
// Display tree
//
std::string ns = ros::names::clean (ros::this_node::getNamespace());
display_tree (ns, title + " - before delegation", root_id);
std::string fail_reason;
std::string cid = delegation_process_until_proposal();
if (cid != "") {
ROS_INFO ("WE HAVE A PROPOSAL");
} else {
ROS_ERROR("missionobject::could not get a proposal");
return false;
}
if (!delegation_process_approved_part(cid, fail_reason)) {
ROS_ERROR("Failed in approved part: %s", fail_reason.c_str());
return false;
}
display_tree (ns, title + " - after delegation", root_id);
//
// Save the dot file
//
#if 0
std::string dotstr = get_tst_string(ns, rootid,
lrs_srvs_tst::TSTGetTreeString::Request::FORMAT_DOT);
std::ofstream dotout("/tmp/terra_house_scan_example.dot");
dotout << dotstr << std::endl;
#endif
if (!exectree_flag) {
return true;
}
//
// Start execution
//
ROS_INFO("DELEGATION FINISHED - STARTING EXECUTION PHASE");
return start_execution (false);
}
std::string MissionObject::delegation_process_until_proposal() { std::string MissionObject::delegation_process_until_proposal() {
......
...@@ -22,6 +22,7 @@ public: ...@@ -22,6 +22,7 @@ public:
~MissionObject(); ~MissionObject();
bool delegation(bool display_flag, bool exectree_flag); bool delegation(bool display_flag, bool exectree_flag);
bool start_execution (bool display_flag);
std::string delegation_process_until_proposal(); std::string delegation_process_until_proposal();
bool delegation_process_approved_part(std::string cid, std::string & fail_reason); bool delegation_process_approved_part(std::string cid, std::string & fail_reason);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment