From a28e2360ccf5f7ff50f5a09cdf4086d30a9d4ff6 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Mon, 6 Nov 2023 16:19:31 -0600 Subject: [PATCH] Replace input_remapping and output_remapping with remapping --- tesseract_task_composer/README.rst | 16 +- .../config/task_composer_plugins.yaml | 40 ++--- ...ask_composer_plugins_no_trajopt_ifopt.yaml | 40 ++--- .../task_composer_executor_unit.hpp | 16 +- .../core/src/task_composer_graph.cpp | 15 +- .../planning/src/nodes/raster_motion_task.cpp | 145 ++++++++---------- .../src/nodes/raster_only_motion_task.cpp | 109 ++++++------- .../tesseract_task_composer_core_unit.cpp | 12 +- 8 files changed, 171 insertions(+), 222 deletions(-) diff --git a/tesseract_task_composer/README.rst b/tesseract_task_composer/README.rst index 37311870be..648b7e9f29 100644 --- a/tesseract_task_composer/README.rst +++ b/tesseract_task_composer/README.rst @@ -196,7 +196,7 @@ Leveraging a perviously defined task When using a perviously defined task it is referenced using `task:` instead of `class:`. -Also in most case the tasks inputs and sometimes the outputs must be renamed. This accomplished by leveraging the `input_remapping:` and `output_remapping:`. +Also in most case the tasks inputs and sometimes the outputs must be renamed. This accomplished by leveraging the `remapping:`. Also you can indicate that it should abort if a terminal is reached by specifying the terminal index `abort_terminal:`. If set to anything less than zero it will set all terminal tasks trigger abort to `false`. @@ -219,10 +219,8 @@ Also you can indicate that it should abort if a terminal is reached by specifyin config: conditional: false # Optional abort_terminal: 0 # Optional - input_remapping: # Optional + remapping: # Optional input_data: output_data - output_remapping: # Optional - output_data: output_data edges: - source: MinLengthTask destinations: [CartesianPipelineTask] @@ -375,21 +373,21 @@ Raster Motion Task freespace: task: FreespacePipeline config: - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] raster: task: CartesianPipeline config: - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] transition: task: FreespacePipeline config: - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -408,14 +406,14 @@ Raster Only Motion Task raster: task: CartesianPipeline config: - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] transition: task: FreespacePipeline config: - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] diff --git a/tesseract_task_composer/config/task_composer_plugins.yaml b/tesseract_task_composer/config/task_composer_plugins.yaml index dabd5fc4f6..6489807f3e 100644 --- a/tesseract_task_composer/config/task_composer_plugins.yaml +++ b/tesseract_task_composer/config/task_composer_plugins.yaml @@ -671,7 +671,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -679,7 +679,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -687,7 +687,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -749,7 +749,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -757,7 +757,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -765,7 +765,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -827,7 +827,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -835,7 +835,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -897,7 +897,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -905,7 +905,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -974,7 +974,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -982,7 +982,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -990,7 +990,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1061,7 +1061,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1069,7 +1069,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1077,7 +1077,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1148,7 +1148,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1156,7 +1156,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1227,7 +1227,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1235,7 +1235,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] 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 62b0bd9e8d..7751b0ad84 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 @@ -602,7 +602,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -610,7 +610,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -618,7 +618,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -680,7 +680,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -688,7 +688,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -696,7 +696,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -758,7 +758,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -766,7 +766,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -828,7 +828,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -836,7 +836,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -905,7 +905,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -913,7 +913,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -921,7 +921,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -992,7 +992,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1000,7 +1000,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1008,7 +1008,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1079,7 +1079,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1087,7 +1087,7 @@ task_composer_plugins: task: FreespaceTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1158,7 +1158,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] @@ -1166,7 +1166,7 @@ task_composer_plugins: task: CartesianTask config: abort_terminal: 0 - input_remapping: + remapping: input_data: output_data input_indexing: [output_data] output_indexing: [output_data] diff --git a/tesseract_task_composer/core/include/tesseract_task_composer/core/test_suite/task_composer_executor_unit.hpp b/tesseract_task_composer/core/include/tesseract_task_composer/core/test_suite/task_composer_executor_unit.hpp index 59778c7f23..7a0f41157e 100644 --- a/tesseract_task_composer/core/include/tesseract_task_composer/core/test_suite/task_composer_executor_unit.hpp +++ b/tesseract_task_composer/core/include/tesseract_task_composer/core/test_suite/task_composer_executor_unit.hpp @@ -154,10 +154,8 @@ void runTaskComposerExecutorTest() task: TestPipeline config: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: @@ -220,10 +218,8 @@ void runTaskComposerExecutorTest() task: TestPipeline config: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: @@ -286,10 +282,8 @@ void runTaskComposerExecutorTest() task: TestPipeline config: conditional: true - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: @@ -361,10 +355,8 @@ void runTaskComposerExecutorTest() task: TestGraph config: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: diff --git a/tesseract_task_composer/core/src/task_composer_graph.cpp b/tesseract_task_composer/core/src/task_composer_graph.cpp index 38f8045f48..0742312052 100644 --- a/tesseract_task_composer/core/src/task_composer_graph.cpp +++ b/tesseract_task_composer/core/src/task_composer_graph.cpp @@ -109,11 +109,18 @@ TaskComposerGraph::TaskComposerGraph(std::string name, throw std::runtime_error("YAML entry 'abort_terminal' is only supported for GRAPH and PIPELINE types"); } - if (YAML::Node n = tc["input_remapping"]) - task_node->renameInputKeys(n.as>()); + if (tc["input_remapping"]) + throw std::runtime_error("TaskComposerGraph, input_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = tc["output_remapping"]) - task_node->renameOutputKeys(n.as>()); + if (tc["output_remapping"]) + throw std::runtime_error("TaskComposerGraph, output_remapping is no longer supported use 'remapping'"); + + if (YAML::Node n = tc["remapping"]) + { + auto remapping = n.as>(); + task_node->renameInputKeys(remapping); + task_node->renameOutputKeys(remapping); + } } node_uuids[node_name] = addNode(std::move(task_node)); 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 ad390c9201..1baefdb4e4 100644 --- a/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp +++ b/tesseract_task_composer/planning/src/nodes/raster_motion_task.cpp @@ -43,8 +43,7 @@ namespace tesseract_planning::RasterMotionTask::TaskFactoryResults createTask(const std::string& name, const std::string& task_name, - const std::map& input_remapping, - const std::map& output_remapping, + const std::map& remapping, const std::vector& input_indexing, const std::vector& output_indexing, const tesseract_planning::TaskComposerPluginFactory& plugin_factory, @@ -53,11 +52,11 @@ createTask(const std::string& name, tesseract_planning::RasterMotionTask::TaskFactoryResults tf_results; tf_results.node = plugin_factory.createTaskComposerNode(task_name); tf_results.node->setName(name); - if (!input_remapping.empty()) - tf_results.node->renameInputKeys(input_remapping); - - if (!output_remapping.empty()) - tf_results.node->renameOutputKeys(output_remapping); + if (!remapping.empty()) + { + tf_results.node->renameInputKeys(remapping); + tf_results.node->renameOutputKeys(remapping); + } if (!input_indexing.empty()) { @@ -139,8 +138,7 @@ RasterMotionTask::RasterMotionTask(std::string name, int abort_terminal_index{ -1 }; std::vector input_indexing; std::vector output_indexing; - std::map input_remapping; - std::map output_remapping; + std::map remapping; if (YAML::Node n = freespace_config["task"]) task_name = n.as(); @@ -155,11 +153,14 @@ RasterMotionTask::RasterMotionTask(std::string name, abort_terminal_index = n.as(); } - if (YAML::Node n = task_config["input_remapping"]) - input_remapping = n.as>(); + if (task_config["input_remapping"]) + throw std::runtime_error("RasterMotionTask, input_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = task_config["output_remapping"]) - output_remapping = n.as>(); + if (task_config["output_remapping"]) + throw std::runtime_error("RasterMotionTask, output_remapping is no longer supported use 'remapping'"); + + if (YAML::Node n = task_config["remapping"]) + remapping = n.as>(); if (YAML::Node n = task_config["input_indexing"]) input_indexing = n.as>(); @@ -178,29 +179,19 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - freespace_task_factory_ = [task_name, - abort_terminal_index, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - auto tr = createTask( - name, task_name, input_remapping, output_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, 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; + }; } else { - freespace_task_factory_ = [task_name, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - return createTask( - name, task_name, input_remapping, output_remapping, input_indexing, output_indexing, plugin_factory, index); + 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); }; } } @@ -216,8 +207,7 @@ RasterMotionTask::RasterMotionTask(std::string name, int abort_terminal_index{ -1 }; std::vector input_indexing; std::vector output_indexing; - std::map input_remapping; - std::map output_remapping; + std::map remapping; if (YAML::Node n = raster_config["task"]) task_name = n.as(); @@ -232,11 +222,14 @@ RasterMotionTask::RasterMotionTask(std::string name, abort_terminal_index = n.as(); } - if (YAML::Node n = task_config["input_remapping"]) - input_remapping = n.as>(); + if (task_config["input_remapping"]) + throw std::runtime_error("RasterMotionTask, input_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = task_config["output_remapping"]) - output_remapping = n.as>(); + if (task_config["output_remapping"]) + throw std::runtime_error("RasterMotionTask, output_remapping is no longer supported use 'remapping'"); + + if (YAML::Node n = task_config["remapping"]) + remapping = n.as>(); if (YAML::Node n = task_config["input_indexing"]) input_indexing = n.as>(); @@ -255,29 +248,19 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - raster_task_factory_ = [task_name, - abort_terminal_index, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - auto tr = createTask( - name, task_name, input_remapping, output_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, 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; + }; } else { - raster_task_factory_ = [task_name, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - return createTask( - name, task_name, input_remapping, output_remapping, input_indexing, output_indexing, plugin_factory, index); + 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); }; } } @@ -293,8 +276,7 @@ RasterMotionTask::RasterMotionTask(std::string name, int abort_terminal_index{ -1 }; std::vector input_indexing; std::vector output_indexing; - std::map input_remapping; - std::map output_remapping; + std::map remapping; if (YAML::Node n = transition_config["task"]) task_name = n.as(); @@ -309,11 +291,14 @@ RasterMotionTask::RasterMotionTask(std::string name, abort_terminal_index = n.as(); } - if (YAML::Node n = task_config["input_remapping"]) - input_remapping = n.as>(); + if (task_config["input_remapping"]) + throw std::runtime_error("RasterMotionTask, input_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = task_config["output_remapping"]) - output_remapping = n.as>(); + if (task_config["output_remapping"]) + throw std::runtime_error("RasterMotionTask, output_remapping is no longer supported use 'remapping'"); + + if (YAML::Node n = task_config["remapping"]) + remapping = n.as>(); if (YAML::Node n = task_config["input_indexing"]) input_indexing = n.as>(); @@ -332,29 +317,19 @@ RasterMotionTask::RasterMotionTask(std::string name, if (has_abort_terminal_entry) { - transition_task_factory_ = [task_name, - abort_terminal_index, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - auto tr = createTask( - name, task_name, input_remapping, output_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, 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; + }; } else { - transition_task_factory_ = [task_name, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - return createTask( - name, task_name, input_remapping, output_remapping, input_indexing, output_indexing, plugin_factory, index); + 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); }; } } 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 8360eb4740..4fd05d34db 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 @@ -43,8 +43,7 @@ namespace tesseract_planning::RasterOnlyMotionTask::TaskFactoryResults createTask(const std::string& name, const std::string& task_name, - const std::map& input_remapping, - const std::map& output_remapping, + const std::map& remapping, const std::vector& input_indexing, const std::vector& output_indexing, const tesseract_planning::TaskComposerPluginFactory& plugin_factory, @@ -54,11 +53,11 @@ createTask(const std::string& name, tf_results.node = plugin_factory.createTaskComposerNode(task_name); tf_results.node->setName(name); - if (!input_remapping.empty()) - tf_results.node->renameInputKeys(input_remapping); - - if (!output_remapping.empty()) - tf_results.node->renameOutputKeys(output_remapping); + if (!remapping.empty()) + { + tf_results.node->renameInputKeys(remapping); + tf_results.node->renameOutputKeys(remapping); + } if (!input_indexing.empty()) { @@ -138,8 +137,7 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, int abort_terminal_index{ -1 }; std::vector input_indexing; std::vector output_indexing; - std::map input_remapping; - std::map output_remapping; + std::map remapping; if (YAML::Node n = raster_config["task"]) task_name = n.as(); @@ -154,11 +152,14 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, abort_terminal_index = n.as(); } - if (YAML::Node n = task_config["input_remapping"]) - input_remapping = n.as>(); + if (task_config["input_remapping"]) + throw std::runtime_error("RasterOnlyMotionTask, input_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = task_config["output_remapping"]) - output_remapping = n.as>(); + if (task_config["output_remapping"]) + throw std::runtime_error("RasterOnlyMotionTask, output_remapping is no longer supported use 'remapping'"); + + if (YAML::Node n = task_config["remapping"]) + remapping = n.as>(); if (YAML::Node n = task_config["input_indexing"]) input_indexing = n.as>(); @@ -177,31 +178,21 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (has_abort_terminal_entry) { - raster_task_factory_ = [task_name, - abort_terminal_index, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - auto tr = createTask( - name, task_name, input_remapping, output_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, 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; + }; } else { - raster_task_factory_ = [task_name, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - return createTask( - name, task_name, input_remapping, output_remapping, input_indexing, output_indexing, plugin_factory, index); + 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); }; } } @@ -217,8 +208,7 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, int abort_terminal_index{ -1 }; std::vector input_indexing; std::vector output_indexing; - std::map input_remapping; - std::map output_remapping; + std::map remapping; if (YAML::Node n = transition_config["task"]) task_name = n.as(); @@ -233,11 +223,14 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, abort_terminal_index = n.as(); } - if (YAML::Node n = task_config["input_remapping"]) - input_remapping = n.as>(); + if (task_config["input_remapping"]) + throw std::runtime_error("RasterOnlyMotionTask, input_remapping is no longer supported use 'remapping'"); + + if (task_config["output_remapping"]) + throw std::runtime_error("RasterOnlyMotionTask, output_remapping is no longer supported use 'remapping'"); - if (YAML::Node n = task_config["output_remapping"]) - output_remapping = n.as>(); + if (YAML::Node n = task_config["remapping"]) + remapping = n.as>(); if (YAML::Node n = task_config["input_indexing"]) input_indexing = n.as>(); @@ -256,31 +249,21 @@ RasterOnlyMotionTask::RasterOnlyMotionTask(std::string name, if (has_abort_terminal_entry) { - transition_task_factory_ = [task_name, - abort_terminal_index, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - auto tr = createTask( - name, task_name, input_remapping, output_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, 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; + }; } else { - transition_task_factory_ = [task_name, - input_remapping, - output_remapping, - input_indexing, - output_indexing, - &plugin_factory](const std::string& name, std::size_t index) { - return createTask( - name, task_name, input_remapping, output_remapping, input_indexing, output_indexing, plugin_factory, index); + 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); }; } } diff --git a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp index 65842afae1..2db6d776ab 100644 --- a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp +++ b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp @@ -933,10 +933,8 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerPipelineTests) // NOLINT task: TestPipeline config: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: @@ -1437,10 +1435,8 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerGraphTests) // NOLINT StartTask: task: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: @@ -1496,10 +1492,8 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerGraphTests) // NOLINT task: DoesNotExist config: conditional: false - input_remapping: + remapping: input_data: output_data - output_remapping: - output_data: input_data DoneTask: class: DoneTaskFactory config: