From e9d236bdd40c767c004de1cc4071ccff27344966 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Mon, 6 Nov 2023 21:27:42 -0600 Subject: [PATCH] Replace input_indexing and output_indexing with indexing --- tesseract_task_composer/README.rst | 15 +- .../config/task_composer_plugins.yaml | 60 ++--- ...ask_composer_plugins_no_trajopt_ifopt.yaml | 60 ++--- .../planning/src/nodes/raster_motion_task.cpp | 140 +++++------ .../src/nodes/raster_only_motion_task.cpp | 103 ++++---- .../tesseract_task_composer_planning_unit.cpp | 230 ++++-------------- 6 files changed, 199 insertions(+), 409 deletions(-) diff --git a/tesseract_task_composer/README.rst b/tesseract_task_composer/README.rst index 648b7e9f29..a2680a49e4 100644 --- a/tesseract_task_composer/README.rst +++ b/tesseract_task_composer/README.rst @@ -375,22 +375,19 @@ Raster Motion Task config: remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianPipeline config: remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespacePipeline config: remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] Raster Only Motion Task ^^^^^^^^^^^^^^^^^^^^^^^ @@ -408,15 +405,13 @@ Raster Only Motion Task config: remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespacePipeline config: remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] Check Input Task diff --git a/tesseract_task_composer/config/task_composer_plugins.yaml b/tesseract_task_composer/config/task_composer_plugins.yaml index 6489807f3e..aa4b8a2fa0 100644 --- a/tesseract_task_composer/config/task_composer_plugins.yaml +++ b/tesseract_task_composer/config/task_composer_plugins.yaml @@ -673,24 +673,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -751,24 +748,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -829,16 +823,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -899,16 +891,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -976,24 +966,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -1063,24 +1050,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -1150,16 +1134,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -1229,16 +1211,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] diff --git a/tesseract_task_composer/config/task_composer_plugins_no_trajopt_ifopt.yaml b/tesseract_task_composer/config/task_composer_plugins_no_trajopt_ifopt.yaml index 7751b0ad84..97cd7b7a69 100644 --- a/tesseract_task_composer/config/task_composer_plugins_no_trajopt_ifopt.yaml +++ b/tesseract_task_composer/config/task_composer_plugins_no_trajopt_ifopt.yaml @@ -604,24 +604,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -682,24 +679,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -760,16 +754,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -830,16 +822,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, RasterMotionTask] @@ -907,24 +897,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -994,24 +981,21 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] raster: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -1081,16 +1065,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: FreespaceTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] @@ -1160,16 +1142,14 @@ task_composer_plugins: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] transition: task: CartesianTask config: abort_terminal: 0 remapping: input_data: output_data - input_indexing: [output_data] - output_indexing: [output_data] + indexing: [output_data] edges: - source: SimpleMotionPlannerTask destinations: [ErrorTask, DescartesMotionPlannerTask] diff --git a/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp b/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp index 1baefdb4e4..675eaeed77 100644 --- a/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp +++ b/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp @@ -44,8 +44,7 @@ tesseract_planning::RasterMotionTask::TaskFactoryResults createTask(const std::string& name, const std::string& task_name, const std::map& remapping, - const std::vector& input_indexing, - const std::vector& output_indexing, + const std::vector& indexing, const tesseract_planning::TaskComposerPluginFactory& plugin_factory, std::size_t index) { @@ -58,34 +57,20 @@ createTask(const std::string& name, tf_results.node->renameOutputKeys(remapping); } - if (!input_indexing.empty()) + if (!indexing.empty()) { - std::map input_renaming; - for (const auto& x : input_indexing) + std::map renaming; + for (const auto& x : indexing) { std::string name = task_name; name.append("_"); name.append(x); name.append(std::to_string(index)); - input_renaming[x] = name; + renaming[x] = name; } - tf_results.node->renameInputKeys(input_renaming); - } - - if (!output_indexing.empty()) - { - std::map output_renaming; - for (const auto& x : output_indexing) - { - std::string name = task_name; - name.append("_"); - name.append(x); - name.append(std::to_string(index)); - output_renaming[x] = name; - } - - tf_results.node->renameOutputKeys(output_renaming); + tf_results.node->renameInputKeys(renaming); + tf_results.node->renameOutputKeys(renaming); } tf_results.input_key = tf_results.node->getInputKeys().front(); @@ -136,8 +121,7 @@ RasterMotionTask::RasterMotionTask(std::string name, std::string task_name; bool has_abort_terminal_entry{ false }; int abort_terminal_index{ -1 }; - std::vector input_indexing; - std::vector output_indexing; + std::vector indexing; std::map remapping; if (YAML::Node n = freespace_config["task"]) @@ -162,15 +146,16 @@ RasterMotionTask::RasterMotionTask(std::string name, if (YAML::Node n = task_config["remapping"]) remapping = n.as>(); - if (YAML::Node n = task_config["input_indexing"]) - input_indexing = n.as>(); - else - throw std::runtime_error("RasterMotionTask, entry 'freespace' missing 'input_indexing' entry"); + if (task_config["input_indexing"]) + throw std::runtime_error("RasterMotionTask, input_indexing is no longer supported use 'indexing'"); + + if (task_config["output_indexing"]) + throw std::runtime_error("RasterMotionTask, output_indexing is no longer supported use 'indexing'"); - if (YAML::Node n = task_config["output_indexing"]) - output_indexing = n.as>(); + if (YAML::Node n = task_config["indexing"]) + indexing = n.as>(); else - throw std::runtime_error("RasterMotionTask, entry 'freespace' missing 'output_indexing' entry"); + throw std::runtime_error("RasterMotionTask, entry 'freespace' missing 'indexing' entry"); } else { @@ -179,19 +164,18 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - freespace_task_factory_ = - [task_name, abort_terminal_index, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - auto tr = createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); - static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); - return tr; - }; + freespace_task_factory_ = [task_name, abort_terminal_index, remapping, indexing, &plugin_factory]( + const std::string& name, std::size_t index) { + auto tr = createTask(name, task_name, remapping, indexing, plugin_factory, index); + static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); + return tr; + }; } else { - freespace_task_factory_ = [task_name, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - return createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + freespace_task_factory_ = [task_name, remapping, indexing, &plugin_factory](const std::string& name, + std::size_t index) { + return createTask(name, task_name, remapping, indexing, plugin_factory, index); }; } } @@ -205,8 +189,7 @@ RasterMotionTask::RasterMotionTask(std::string name, std::string task_name; bool has_abort_terminal_entry{ false }; int abort_terminal_index{ -1 }; - std::vector input_indexing; - std::vector output_indexing; + std::vector indexing; std::map remapping; if (YAML::Node n = raster_config["task"]) @@ -231,15 +214,16 @@ RasterMotionTask::RasterMotionTask(std::string name, if (YAML::Node n = task_config["remapping"]) remapping = n.as>(); - if (YAML::Node n = task_config["input_indexing"]) - input_indexing = n.as>(); - else - throw std::runtime_error("RasterMotionTask, entry 'raster' missing 'input_indexing' entry"); + if (task_config["input_indexing"]) + throw std::runtime_error("RasterMotionTask, input_indexing is no longer supported use 'indexing'"); - if (YAML::Node n = task_config["output_indexing"]) - output_indexing = n.as>(); + if (task_config["output_indexing"]) + throw std::runtime_error("RasterMotionTask, output_indexing is no longer supported use 'indexing'"); + + if (YAML::Node n = task_config["indexing"]) + indexing = n.as>(); else - throw std::runtime_error("RasterMotionTask, entry 'raster' missing 'output_indexing' entry"); + throw std::runtime_error("RasterMotionTask, entry 'raster' missing 'indexing' entry"); } else { @@ -248,19 +232,18 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - raster_task_factory_ = - [task_name, abort_terminal_index, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - auto tr = createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); - static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); - return tr; - }; + raster_task_factory_ = [task_name, abort_terminal_index, remapping, indexing, &plugin_factory]( + const std::string& name, std::size_t index) { + auto tr = createTask(name, task_name, remapping, indexing, plugin_factory, index); + static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); + return tr; + }; } else { - raster_task_factory_ = [task_name, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - return createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + raster_task_factory_ = [task_name, remapping, indexing, &plugin_factory](const std::string& name, + std::size_t index) { + return createTask(name, task_name, remapping, indexing, plugin_factory, index); }; } } @@ -274,8 +257,7 @@ RasterMotionTask::RasterMotionTask(std::string name, std::string task_name; bool has_abort_terminal_entry{ false }; int abort_terminal_index{ -1 }; - std::vector input_indexing; - std::vector output_indexing; + std::vector indexing; std::map remapping; if (YAML::Node n = transition_config["task"]) @@ -300,15 +282,16 @@ RasterMotionTask::RasterMotionTask(std::string name, if (YAML::Node n = task_config["remapping"]) remapping = n.as>(); - if (YAML::Node n = task_config["input_indexing"]) - input_indexing = n.as>(); - else - throw std::runtime_error("RasterMotionTask, entry 'transition' missing 'input_indexing' entry"); + if (task_config["input_indexing"]) + throw std::runtime_error("RasterMotionTask, input_indexing is no longer supported use 'indexing'"); + + if (task_config["output_indexing"]) + throw std::runtime_error("RasterMotionTask, output_indexing is no longer supported use 'indexing'"); - if (YAML::Node n = task_config["output_indexing"]) - output_indexing = n.as>(); + if (YAML::Node n = task_config["indexing"]) + indexing = n.as>(); else - throw std::runtime_error("RasterMotionTask, entry 'transition' missing 'output_indexing' entry"); + throw std::runtime_error("RasterMotionTask, entry 'transition' missing 'indexing' entry"); } else { @@ -317,19 +300,18 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - transition_task_factory_ = - [task_name, abort_terminal_index, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - auto tr = createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); - static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); - return tr; - }; + transition_task_factory_ = [task_name, abort_terminal_index, remapping, indexing, &plugin_factory]( + const std::string& name, std::size_t index) { + auto tr = createTask(name, task_name, remapping, indexing, plugin_factory, index); + static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); + return tr; + }; } else { - transition_task_factory_ = [task_name, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - return createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + transition_task_factory_ = [task_name, remapping, indexing, &plugin_factory](const std::string& name, + std::size_t index) { + return createTask(name, task_name, remapping, indexing, plugin_factory, index); }; } } diff --git a/tesseract_task_composer/planning/src/nodes/raster_only_motion_task.cpp b/tesseract_task_composer/planning/src/nodes/raster_only_motion_task.cpp index 4fd05d34db..6d60e72dc1 100644 --- a/tesseract_task_composer/planning/src/nodes/raster_only_motion_task.cpp +++ b/tesseract_task_composer/planning/src/nodes/raster_only_motion_task.cpp @@ -44,8 +44,7 @@ tesseract_planning::RasterOnlyMotionTask::TaskFactoryResults createTask(const std::string& name, const std::string& task_name, const std::map& remapping, - const std::vector& input_indexing, - const std::vector& output_indexing, + const std::vector& indexing, const tesseract_planning::TaskComposerPluginFactory& plugin_factory, std::size_t index) { @@ -59,34 +58,20 @@ createTask(const std::string& name, tf_results.node->renameOutputKeys(remapping); } - if (!input_indexing.empty()) + if (!indexing.empty()) { - std::map input_renaming; - for (const auto& x : input_indexing) + std::map renaming; + for (const auto& x : indexing) { std::string name = task_name; name.append("_"); name.append(x); name.append(std::to_string(index)); - input_renaming[x] = name; + renaming[x] = name; } - tf_results.node->renameInputKeys(input_renaming); - } - - if (!output_indexing.empty()) - { - std::map output_renaming; - for (const auto& x : output_indexing) - { - std::string name = task_name; - name.append("_"); - name.append(x); - name.append(std::to_string(index)); - output_renaming[x] = name; - } - - tf_results.node->renameOutputKeys(output_renaming); + tf_results.node->renameInputKeys(renaming); + tf_results.node->renameOutputKeys(renaming); } tf_results.input_key = tf_results.node->getInputKeys().front(); @@ -135,8 +120,7 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, std::string task_name; bool has_abort_terminal_entry{ false }; int abort_terminal_index{ -1 }; - std::vector input_indexing; - std::vector output_indexing; + std::vector indexing; std::map remapping; if (YAML::Node n = raster_config["task"]) @@ -161,15 +145,16 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (YAML::Node n = task_config["remapping"]) remapping = n.as>(); - if (YAML::Node n = task_config["input_indexing"]) - input_indexing = n.as>(); - else - throw std::runtime_error("RasterOnlyMotionTask, entry 'raster' missing 'input_indexing' entry"); + if (task_config["input_indexing"]) + throw std::runtime_error("RasterOnlyMotionTask, input_indexing is no longer supported use 'indexing'"); + + if (task_config["output_indexing"]) + throw std::runtime_error("RasterOnlyMotionTask, output_indexing is no longer supported use 'indexing'"); - if (YAML::Node n = task_config["output_indexing"]) - output_indexing = n.as>(); + if (YAML::Node n = task_config["indexing"]) + indexing = n.as>(); else - throw std::runtime_error("RasterOnlyMotionTask, entry 'raster' missing 'output_indexing' entry"); + throw std::runtime_error("RasterOnlyMotionTask, entry 'raster' missing 'indexing' entry"); } else { @@ -178,21 +163,20 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (has_abort_terminal_entry) { - raster_task_factory_ = - [task_name, abort_terminal_index, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - auto tr = createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + raster_task_factory_ = [task_name, abort_terminal_index, remapping, indexing, &plugin_factory]( + const std::string& name, std::size_t index) { + auto tr = createTask(name, task_name, remapping, indexing, plugin_factory, index); - static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); + static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); - return tr; - }; + return tr; + }; } else { - raster_task_factory_ = [task_name, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - return createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + raster_task_factory_ = [task_name, remapping, indexing, &plugin_factory](const std::string& name, + std::size_t index) { + return createTask(name, task_name, remapping, indexing, plugin_factory, index); }; } } @@ -206,8 +190,7 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, std::string task_name; bool has_abort_terminal_entry{ false }; int abort_terminal_index{ -1 }; - std::vector input_indexing; - std::vector output_indexing; + std::vector indexing; std::map remapping; if (YAML::Node n = transition_config["task"]) @@ -232,15 +215,16 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (YAML::Node n = task_config["remapping"]) remapping = n.as>(); - if (YAML::Node n = task_config["input_indexing"]) - input_indexing = n.as>(); - else - throw std::runtime_error("RasterOnlyMotionTask, entry 'transition' missing 'input_indexing' entry"); + if (task_config["input_indexing"]) + throw std::runtime_error("RasterOnlyMotionTask, input_indexing is no longer supported use 'indexing'"); + + if (task_config["output_indexing"]) + throw std::runtime_error("RasterOnlyMotionTask, output_indexing is no longer supported use 'indexing'"); - if (YAML::Node n = task_config["output_indexing"]) - output_indexing = n.as>(); + if (YAML::Node n = task_config["indexing"]) + indexing = n.as>(); else - throw std::runtime_error("RasterOnlyMotionTask, entry 'transition' missing 'output_indexing' entry"); + throw std::runtime_error("RasterOnlyMotionTask, entry 'transition' missing 'indexing' entry"); } else { @@ -249,21 +233,20 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (has_abort_terminal_entry) { - transition_task_factory_ = - [task_name, abort_terminal_index, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - auto tr = createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + transition_task_factory_ = [task_name, abort_terminal_index, remapping, indexing, &plugin_factory]( + const std::string& name, std::size_t index) { + auto tr = createTask(name, task_name, remapping, indexing, plugin_factory, index); - static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); + static_cast(*tr.node).setTerminalTriggerAbortByIndex(abort_terminal_index); - return tr; - }; + return tr; + }; } else { - transition_task_factory_ = [task_name, remapping, input_indexing, output_indexing, &plugin_factory]( - const std::string& name, std::size_t index) { - return createTask(name, task_name, remapping, input_indexing, output_indexing, plugin_factory, index); + transition_task_factory_ = [task_name, remapping, indexing, &plugin_factory](const std::string& name, + std::size_t index) { + return createTask(name, task_name, remapping, indexing, plugin_factory, index); }; } } diff --git a/tesseract_task_composer/test/tesseract_task_composer_planning_unit.cpp b/tesseract_task_composer/test/tesseract_task_composer_planning_unit.cpp index 16cbd0bdeb..0f0bb46e47 100644 --- a/tesseract_task_composer/test/tesseract_task_composer_planning_unit.cpp +++ b/tesseract_task_composer/test/tesseract_task_composer_planning_unit.cpp @@ -2226,18 +2226,15 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterMotionTask task("abc", config["config"], factory); EXPECT_EQ(task.getName(), "abc"); @@ -2298,8 +2295,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // outputs: [output_data] freespace: config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2323,7 +2319,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data])"; + indexing: [input_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2336,8 +2332,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2350,7 +2345,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - output_indexing: [output_data])"; + indexing: [output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2363,12 +2358,10 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2381,8 +2374,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline)"; YAML::Node config = YAML::Load(str); @@ -2397,12 +2389,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data])"; + indexing: [input_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2415,12 +2406,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - output_indexing: [output_data])"; + indexing: [output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2433,13 +2423,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2452,17 +2440,14 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2475,67 +2460,17 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline)"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } - { // Construction failure - std::string str = R"(config: - conditional: true - inputs: [input_data] - outputs: [output_data] - freespace: - task: FreespacePipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - raster: - task: CartesianPipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - transition: - task: CartesianPipeline - config: - input_indexing: [input_data])"; - YAML::Node config = YAML::Load(str); - // NOLINTNEXTLINE - EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); - } - - { // Construction failure - std::string str = R"(config: - conditional: true - inputs: [input_data] - outputs: [output_data] - freespace: - task: FreespacePipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - raster: - task: CartesianPipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - transition: - task: CartesianPipeline - config: - output_indexing: [output_data])"; - YAML::Node config = YAML::Load(str); - // NOLINTNEXTLINE - EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); - } - { // Serialization auto task = std::make_unique(); @@ -2634,18 +2569,15 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterMotionTask task("abc", config["config"], factory); @@ -2672,18 +2604,15 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterMotionTask task("abc", config["config"], factory); @@ -2714,18 +2643,15 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterMotionTask task("abc", config["config"], factory); @@ -2756,18 +2682,15 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterMotionTaskTests) // freespace: task: FreespacePipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterMotionTask task("abc", config["config"], factory); @@ -2811,13 +2734,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterOnlyMotionTask task("abc", config["config"], factory); EXPECT_EQ(task.getName(), "abc"); @@ -2878,8 +2799,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) outputs: [output_data] raster: config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2903,7 +2823,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data])"; + indexing: [input_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2916,7 +2836,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - output_indexing: [output_data])"; + indexing: [output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2929,8 +2849,7 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2943,12 +2862,10 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } @@ -2961,52 +2878,13 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline)"; YAML::Node config = YAML::Load(str); EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); // NOLINT } - { // Construction failure - std::string str = R"(config: - conditional: true - inputs: [input_data] - outputs: [output_data] - raster: - task: CartesianPipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - transition: - task: CartesianPipeline - config: - input_indexing: [input_data])"; - YAML::Node config = YAML::Load(str); - // NOLINTNEXTLINE - EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); - } - - { // Construction failure - std::string str = R"(config: - conditional: true - inputs: [input_data] - outputs: [output_data] - raster: - task: CartesianPipeline - config: - input_indexing: [input_data] - output_indexing: [output_data] - transition: - task: CartesianPipeline - config: - output_indexing: [output_data])"; - YAML::Node config = YAML::Load(str); - // NOLINTNEXTLINE - EXPECT_ANY_THROW(std::make_unique("abc", config["config"], factory)); - } - { // Serialization auto task = std::make_unique(); @@ -3104,13 +2982,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterOnlyMotionTask task("abc", config["config"], factory); @@ -3137,13 +3013,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterOnlyMotionTask task("abc", config["config"], factory); @@ -3174,13 +3048,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterOnlyMotionTask task("abc", config["config"], factory); @@ -3211,13 +3083,11 @@ TEST_F(TesseractTaskComposerPlanningUnit, TaskComposerRasterOnlyMotionTaskTests) raster: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data] + indexing: [input_data, output_data] transition: task: CartesianPipeline config: - input_indexing: [input_data] - output_indexing: [output_data])"; + indexing: [input_data, output_data])"; YAML::Node config = YAML::Load(str); RasterOnlyMotionTask task("abc", config["config"], factory);