Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tesseract_task_composer/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_library(
src/task_composer_node.cpp
src/task_composer_pipeline.cpp
src/task_composer_plugin_factory.cpp
src/task_composer_schema.cpp
src/task_composer_server.cpp
src/task_composer_task.cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class DoneTask : public TaskComposerTask
explicit DoneTask(std::string name, const YAML::Node& config, const TaskComposerPluginFactory& plugin_factory);
~DoneTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const DoneTask& rhs) const;
bool operator!=(const DoneTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ErrorTask : public TaskComposerTask
explicit ErrorTask(std::string name, const YAML::Node& config, const TaskComposerPluginFactory& plugin_factory);
~ErrorTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const ErrorTask& rhs) const;
bool operator!=(const ErrorTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class TESSERACT_TASK_COMPOSER_NODES_EXPORT HasDataStorageEntryTask : public Task
const TaskComposerPluginFactory& plugin_factory);
~HasDataStorageEntryTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const HasDataStorageEntryTask& rhs) const;
bool operator!=(const HasDataStorageEntryTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class RemapTask : public TaskComposerTask
explicit RemapTask(std::string name, const YAML::Node& config, const TaskComposerPluginFactory& plugin_factory);
~RemapTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const RemapTask& rhs) const;
bool operator!=(const RemapTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class StartTask : public TaskComposerTask
explicit StartTask(std::string name, const YAML::Node& config, const TaskComposerPluginFactory& plugin_factory);
~StartTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const StartTask& rhs) const;
bool operator!=(const StartTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class SyncTask : public TaskComposerTask
explicit SyncTask(std::string name, const YAML::Node& config, const TaskComposerPluginFactory& plugin_factory);
~SyncTask() override = default;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const SyncTask& rhs) const;
bool operator!=(const SyncTask& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class TaskComposerGraph : public TaskComposerNode
const TaskComposerNode* parent = nullptr,
const std::map<boost::uuids::uuid, tesseract_planning::TaskComposerNodeInfo>& results_map = {}) const override;

tesseract_common::PropertyTree getSchema() const override final;

bool operator==(const TaskComposerGraph& rhs) const;
bool operator!=(const TaskComposerGraph& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ class TaskComposerNode
const TaskComposerNode* parent = nullptr,
const ResultsMap& results_map = ResultsMap()) const;

/**
* @brief Get the tasks schema for yaml validation
* @return The tasks schema
*/
virtual tesseract_common::PropertyTree getSchema() const;

bool operator==(const TaskComposerNode& rhs) const;
bool operator!=(const TaskComposerNode& rhs) const;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file task_composer_schema.h
* @brief Task composer schema utils
*
* @author Levi Armstrong
* @date June 20. 2025
* @version TODO
* @bug No known bugs
*
* @copyright Copyright (c) 2025, Levi Armstrong
*
* @par License
* Software License Agreement (Apache License)
* @par
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* @par
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TESSERACT_TASK_COMPOSER_TASK_COMPOSER_SCHEMA_H
#define TESSERACT_TASK_COMPOSER_TASK_COMPOSER_SCHEMA_H

#include <tesseract_common/fwd.h>

#include <string_view>

namespace tesseract_common::property_attribute
{
constexpr std::string_view TASK_NAME{ "task_name" };
constexpr std::string_view FACTORY_NAME{ "factory_name" };
} // namespace tesseract_common::property_attribute

namespace tesseract_planning
{
namespace property_name
{
// General properties
constexpr std::string_view INPUTS{ "inputs" };
constexpr std::string_view OUTPUTS{ "outputs" };
constexpr std::string_view CONDITIONAL{ "conditional" };
constexpr std::string_view TRIGGER_ABORT{ "trigger_abort" };

// Input/Output property names
constexpr std::string_view PROGRAM{ "program" };
constexpr std::string_view ENVIRONMENT{ "environment" };
constexpr std::string_view PROFILES{ "profiles" };

// Graph/Pipeline properties
constexpr std::string_view NODES{ "nodes" };
constexpr std::string_view EDGES{ "edges" };
constexpr std::string_view TERMINALS{ "terminals" };
} // namespace property_name

tesseract_common::PropertyTree& addConditionalProperty(tesseract_common::PropertyTree& schema,
bool default_value = true);
tesseract_common::PropertyTree& addTriggerAbortProperty(tesseract_common::PropertyTree& schema,
bool default_value = false);
tesseract_common::PropertyTree& addInputsProperty(tesseract_common::PropertyTree& schema, bool required = true);
tesseract_common::PropertyTree& addOutputsProperty(tesseract_common::PropertyTree& schema, bool required = true);

tesseract_common::PropertyTree& addProgramProperty(tesseract_common::PropertyTree& schema);
tesseract_common::PropertyTree& addEnvironmentProperty(tesseract_common::PropertyTree& schema);
tesseract_common::PropertyTree& addProfilesProperty(tesseract_common::PropertyTree& schema);

tesseract_common::PropertyTree& addNodesProperty(tesseract_common::PropertyTree& schema);
tesseract_common::PropertyTree& addEdgesProperty(tesseract_common::PropertyTree& schema);
tesseract_common::PropertyTree& addTerminalsProperty(tesseract_common::PropertyTree& schema);

// Schema

tesseract_common::PropertyTree getTaskComposerGraphEdgeSchema();

} // namespace tesseract_planning

#endif // TESSERACT_TASK_COMPOSER_TASK_COMPOSER_SCHEMA_H
23 changes: 23 additions & 0 deletions tesseract_task_composer/core/src/nodes/done_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <boost/serialization/string.hpp>
#include <yaml-cpp/yaml.h>
#include <tesseract_common/serialization.h>
#include <tesseract_common/property_tree.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_task_composer/core/nodes/done_task.h>
#include <tesseract_task_composer/core/task_composer_node_info.h>
#include <tesseract_task_composer/core/task_composer_schema.h>

namespace tesseract_planning
{
Expand All @@ -46,6 +48,27 @@ DoneTask::DoneTask(std::string name, const YAML::Node& config, const TaskCompose
{
}

tesseract_common::PropertyTree DoneTask::getSchema() const
{
using namespace tesseract_common;

PropertyTree schema;
schema.setAttribute(property_attribute::TYPE, property_type::CONTAINER);
schema.setAttribute(property_attribute::REQUIRED, true);
schema.setAttribute(property_attribute::TASK_NAME, "DoneTask");
schema.setAttribute(property_attribute::FACTORY_NAME, "DoneTaskFactory");
schema.setAttribute(property_attribute::DOC,
"A task which is typically called last to indicate success of a pipeline");
std::map<int, std::string> return_options;
return_options[1] = "Successful";
schema.setAttribute("return_options", YAML::Node(return_options));

addConditionalProperty(schema, false);
addTriggerAbortProperty(schema);

return schema;
}

TaskComposerNodeInfo DoneTask::runImpl(TaskComposerContext& /*context*/,
OptionalTaskComposerExecutor /*executor*/) const
{
Expand Down
23 changes: 23 additions & 0 deletions tesseract_task_composer/core/src/nodes/error_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <boost/serialization/string.hpp>
#include <yaml-cpp/yaml.h>
#include <tesseract_common/serialization.h>
#include <tesseract_common/property_tree.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_task_composer/core/nodes/error_task.h>
#include <tesseract_task_composer/core/task_composer_node_info.h>
#include <tesseract_task_composer/core/task_composer_schema.h>

namespace tesseract_planning
{
Expand All @@ -46,6 +48,27 @@ ErrorTask::ErrorTask(std::string name, const YAML::Node& config, const TaskCompo
{
}

tesseract_common::PropertyTree ErrorTask::getSchema() const
{
using namespace tesseract_common;

PropertyTree schema;
schema.setAttribute(property_attribute::TYPE, property_type::CONTAINER);
schema.setAttribute(property_attribute::REQUIRED, true);
schema.setAttribute(property_attribute::TASK_NAME, "ErrorTask");
schema.setAttribute(property_attribute::FACTORY_NAME, "ErrorTaskFactory");
schema.setAttribute(property_attribute::DOC,
"A task which is typically called last to indicate success of a pipeline");
std::map<int, std::string> return_options;
return_options[0] = "Error";
schema.setAttribute("return_options", YAML::Node(return_options));

addConditionalProperty(schema, false);
addTriggerAbortProperty(schema);

return schema;
}

TaskComposerNodeInfo ErrorTask::runImpl(TaskComposerContext& /*context*/,
OptionalTaskComposerExecutor /*executor*/) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <boost/serialization/map.hpp>
#include <yaml-cpp/yaml.h>
#include <tesseract_common/serialization.h>
#include <tesseract_common/property_tree.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_task_composer/core/nodes/has_data_storage_entry_task.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_data_storage.h>
#include <tesseract_task_composer/core/task_composer_node_info.h>
#include <tesseract_task_composer/core/task_composer_schema.h>

namespace tesseract_planning
{
Expand All @@ -34,6 +36,36 @@ HasDataStorageEntryTask::HasDataStorageEntryTask(std::string name,
{
}

tesseract_common::PropertyTree HasDataStorageEntryTask::getSchema() const
{
using namespace tesseract_common;

PropertyTree schema;
schema.setAttribute(property_attribute::TYPE, property_type::CONTAINER);
schema.setAttribute(property_attribute::REQUIRED, true);
schema.setAttribute(property_attribute::TASK_NAME, "HasDataStorageEntryTask");
schema.setAttribute(property_attribute::FACTORY_NAME, "HasDataStorageEntryTaskFactory");
schema.setAttribute(property_attribute::DOC, "A task to check for entries in the data storage");

std::map<int, std::string> return_options;
return_options[0] = "Error";
return_options[0] = "Successful";
schema.setAttribute("return_options", YAML::Node(return_options));

addConditionalProperty(schema, false);
addTriggerAbortProperty(schema);

PropertyTree& inputs = addInputsProperty(schema);
{
auto& prop = inputs[INPUT_KEYS_PORT];
prop.setAttribute(property_attribute::TYPE, property_type::createList(property_type::STRING));
prop.setAttribute(property_attribute::DOC, "A list of keys to check for entries in data storage");
prop.setAttribute(property_attribute::REQUIRED, true);
}

return schema;
}

TaskComposerNodePorts HasDataStorageEntryTask::ports()
{
TaskComposerNodePorts ports;
Expand Down
47 changes: 47 additions & 0 deletions tesseract_task_composer/core/src/nodes/remap_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <boost/serialization/map.hpp>
#include <yaml-cpp/yaml.h>
#include <tesseract_common/serialization.h>
#include <tesseract_common/property_tree.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_task_composer/core/nodes/remap_task.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_data_storage.h>
#include <tesseract_task_composer/core/task_composer_node_info.h>
#include <tesseract_task_composer/core/task_composer_schema.h>

namespace tesseract_planning
{
Expand Down Expand Up @@ -72,6 +74,51 @@ RemapTask::RemapTask(std::string name, const YAML::Node& config, const TaskCompo
copy_ = n.as<bool>();
}

tesseract_common::PropertyTree RemapTask::getSchema() const
{
using namespace tesseract_common;

PropertyTree schema;
schema.setAttribute(property_attribute::TYPE, property_type::CONTAINER);
schema.setAttribute(property_attribute::REQUIRED, true);
schema.setAttribute(property_attribute::TASK_NAME, "RemapTask");
schema.setAttribute(property_attribute::FACTORY_NAME, "RemapTaskFactory");
schema.setAttribute(property_attribute::DOC, "A task to remap data stored in data storage from one key to another");

std::map<int, std::string> return_options;
return_options[0] = "Error";
return_options[0] = "Successful";
schema.setAttribute("return_options", YAML::Node(return_options));

addConditionalProperty(schema, false);
addTriggerAbortProperty(schema);
{
auto& prop = schema["copy"];
prop.setAttribute(property_attribute::TYPE, property_type::BOOL);
prop.setAttribute(property_attribute::DEFAULT, false);
prop.setAttribute(property_attribute::DOC, "Indicate if data should be copied, otherwise it is moved");
prop.setAttribute(property_attribute::REQUIRED, false);
}

PropertyTree& inputs = addInputsProperty(schema);
{
auto& prop = inputs[INOUT_KEYS_PORT];
prop.setAttribute(property_attribute::TYPE, property_type::createList(property_type::STRING));
prop.setAttribute(property_attribute::DOC, "A list of keys in data storage to copy/move");
prop.setAttribute(property_attribute::REQUIRED, true);
}

PropertyTree& outputs = addInputsProperty(schema);
{
auto& prop = outputs[INOUT_KEYS_PORT];
prop.setAttribute(property_attribute::TYPE, property_type::createList(property_type::STRING));
prop.setAttribute(property_attribute::DOC, "A list of keys in data storage to copy/move");
prop.setAttribute(property_attribute::REQUIRED, true);
}

return schema;
}

TaskComposerNodePorts RemapTask::ports()
{
TaskComposerNodePorts ports;
Expand Down
Loading
Loading