Skip to content

Commit 93a9745

Browse files
mpowelsonLevi Armstrong
and
Levi Armstrong
authored
Move ProcessInfo into ProcessInterface for outside access (#514)
* Move ProcessInfo into ProcessInterface for outside access * Rename Process to Task for generators and associated types ProcessGenerator -> TaskGenerator ProcessInterface -> TaskflowInterface ProcessInfo -> TaskInfo ProcessInfoContainer -> TaskInfoContainer ProcessInput -> TaskInput * Fix remaining changes Co-authored-by: Levi Armstrong <levi.armstrong@swri.org>
1 parent 7d70214 commit 93a9745

File tree

67 files changed

+1049
-1018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1049
-1018
lines changed

tesseract/tesseract_planning/tesseract_process_managers/CMakeLists.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ include(GenerateExportHeader)
4141

4242
# Create interface
4343
add_library(${PROJECT_NAME}
44-
src/core/process_input.cpp
44+
src/core/task_input.cpp
4545
src/core/debug_observer.cpp
46-
src/core/process_generator.cpp
46+
src/core/task_generator.cpp
4747
src/core/process_planning_future.cpp
4848
src/core/process_planning_server.cpp
4949
src/core/process_environment_cache.cpp
50-
src/core/process_interface.cpp
51-
src/core/process_info.cpp
50+
src/core/taskflow_interface.cpp
51+
src/core/task_info.cpp
5252
src/core/default_process_planners.cpp
5353
src/core/taskflow_container.cpp
5454
src/core/utils.cpp
55-
src/process_generators/continuous_contact_check_process_generator.cpp
56-
src/process_generators/discrete_contact_check_process_generator.cpp
57-
src/process_generators/fix_state_bounds_process_generator.cpp
58-
src/process_generators/fix_state_collision_process_generator.cpp
59-
src/process_generators/iterative_spline_parameterization_process_generator.cpp
60-
src/process_generators/motion_planner_process_generator.cpp
61-
src/process_generators/profile_switch_process_generator.cpp
62-
src/process_generators/seed_min_length_process_generator.cpp
55+
src/task_generators/continuous_contact_check_task_generator.cpp
56+
src/task_generators/discrete_contact_check_task_generator.cpp
57+
src/task_generators/fix_state_bounds_task_generator.cpp
58+
src/task_generators/fix_state_collision_task_generator.cpp
59+
src/task_generators/iterative_spline_parameterization_task_generator.cpp
60+
src/task_generators/motion_planner_task_generator.cpp
61+
src/task_generators/profile_switch_task_generator.cpp
62+
src/task_generators/seed_min_length_task_generator.cpp
6363
src/taskflow_generators/graph_taskflow.cpp
6464
src/taskflow_generators/raster_taskflow.cpp
6565
src/taskflow_generators/raster_global_taskflow.cpp

tesseract/tesseract_planning/tesseract_process_managers/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ This package contains process managers for Tesseract. Examples include
66
* Raster strip planning manager
77

88
## Overview
9-
### ProcessInput
10-
This package uses [Taskflow](https://github.com/taskflow/taskflow) to organize and perform robotics tasks. Each of the tasks in the system will take a ProcessInput which is just a Tesseract::ConstPtr and references to instructions and the seed.
9+
### TaskInput
10+
This package uses [Taskflow](https://github.com/taskflow/taskflow) to organize and perform robotics tasks. Each of the tasks in the system will take a TaskInput which is just a Tesseract::ConstPtr and references to instructions and the seed.
1111

12-
Each Task will operate on the instructions and the results will get stored in the seed. The ProcessInput does not own the instructions in order to keep it lightweight and able to be segmented into sub-ProcessInputs (see [] operator). Therefore, the instructions and seed passed into the ProcessInput must be kept alive by the user.
12+
Each Task will operate on the instructions and the results will get stored in the seed. The TaskInput does not own the instructions in order to keep it lightweight and able to be segmented into sub-TaskInputs (see [] operator). Therefore, the instructions and seed passed into the TaskInput must be kept alive by the user.
1313

14-
It is also worth noting that ProcessInput is not inherently thread-safe. Since taskflow will attempt to execute as many tasks in parallel as possible, it is the responsibility of the user to ensure that Tasks that use the same portions of the ProcessInput are not running at the same time. In practice, this shouldn't be difficult as many of the planning operations currently implemented have a clear order. However, you should not, for example, try to plan the same segment using two different planners at the same time without first making a copy of the inputs to the ProcessInput for each Task.
14+
It is also worth noting that TaskInput is not inherently thread-safe. Since taskflow will attempt to execute as many tasks in parallel as possible, it is the responsibility of the user to ensure that Tasks that use the same portions of the TaskInput are not running at the same time. In practice, this shouldn't be difficult as many of the planning operations currently implemented have a clear order. However, you should not, for example, try to plan the same segment using two different planners at the same time without first making a copy of the inputs to the TaskInput for each Task.
1515

1616
### Class Structure
1717
The package is divided into several types of classes

tesseract/tesseract_planning/tesseract_process_managers/examples/subtaskflow_example.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <taskflow/taskflow.hpp>
22
#include <tesseract_common/utils.h>
33

4-
struct ProcessInput
4+
struct TaskInput
55
{
66
int* cnt;
77
};
@@ -18,7 +18,7 @@ int main(int /*argc*/, char** /*argv*/)
1818
tf::Taskflow taskflow;
1919

2020
int num_subtaskflows = 1;
21-
ProcessInput input;
21+
TaskInput input;
2222
input.cnt = &num_subtaskflows;
2323

2424
tf::Task t = taskflow.placeholder();

tesseract/tesseract_planning/tesseract_process_managers/include/tesseract_process_managers/core/process_info.h

-87
This file was deleted.

tesseract/tesseract_planning/tesseract_process_managers/include/tesseract_process_managers/core/process_planning_future.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3333
#include <taskflow/taskflow.hpp>
3434
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3535

36-
#include <tesseract_process_managers/core/process_interface.h>
36+
#include <tesseract_process_managers/core/taskflow_interface.h>
3737
#include <tesseract_process_managers/core/taskflow_generator.h>
3838

3939
#include <tesseract_motion_planners/core/types.h>
@@ -60,7 +60,7 @@ struct ProcessPlanningFuture
6060
std::future<void> process_future;
6161

6262
/** @brief This is used to abort the associated process and check if the process was successful */
63-
ProcessInterface::Ptr interface;
63+
TaskflowInterface::Ptr interface;
6464

6565
#ifndef SWIG
6666
/** @brief The stored input to the process */
@@ -77,6 +77,7 @@ struct ProcessPlanningFuture
7777

7878
/** @brief The stored composite profile remapping */
7979
std::unique_ptr<const PlannerProfileRemapping> composite_profile_remapping;
80+
8081
#else
8182
// clang-format off
8283
%extend {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file process_generator.h
2+
* @file task_generator.h
33
* @brief Process generator
44
*
55
* @author Matthew Powelson
@@ -23,8 +23,8 @@
2323
* See the License for the specific language governing permissions and
2424
* limitations under the License.
2525
*/
26-
#ifndef TESSERACT_PROCESS_MANAGERS_PROCESS_GENERATOR_H
27-
#define TESSERACT_PROCESS_MANAGERS_PROCESS_GENERATOR_H
26+
#ifndef TESSERACT_PROCESS_MANAGERS_TASK_GENERATOR_H
27+
#define TESSERACT_PROCESS_MANAGERS_TASK_GENERATOR_H
2828

2929
#include <tesseract_common/macros.h>
3030
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
@@ -33,28 +33,28 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3333
#include <taskflow/taskflow.hpp>
3434
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3535

36-
#include <tesseract_process_managers/core/process_input.h>
36+
#include <tesseract_process_managers/core/task_input.h>
3737

3838
namespace tesseract_planning
3939
{
4040
/**
4141
* @brief This is a base class for generating instances of processes as tasks such that they may be executed in
42-
* parallel. A typical workflow would be task t = process_generator.generateTask(input, taskflow)
42+
* parallel. A typical workflow would be task t = task_generator.generateTask(input, taskflow)
4343
*
4444
* Only unique pointers should be used because of the ability to abort the process. With recent changes this may no
4545
* longer be valid but need to investigate.
4646
*/
47-
class ProcessGenerator
47+
class TaskGenerator
4848
{
4949
public:
50-
using UPtr = std::unique_ptr<ProcessGenerator>;
50+
using UPtr = std::unique_ptr<TaskGenerator>;
5151

52-
ProcessGenerator(std::string name = "");
53-
virtual ~ProcessGenerator() = default;
54-
ProcessGenerator(const ProcessGenerator&) = delete;
55-
ProcessGenerator& operator=(const ProcessGenerator&) = delete;
56-
ProcessGenerator(ProcessGenerator&&) = delete;
57-
ProcessGenerator& operator=(ProcessGenerator&&) = delete;
52+
TaskGenerator(std::string name = "");
53+
virtual ~TaskGenerator() = default;
54+
TaskGenerator(const TaskGenerator&) = delete;
55+
TaskGenerator& operator=(const TaskGenerator&) = delete;
56+
TaskGenerator(TaskGenerator&&) = delete;
57+
TaskGenerator& operator=(TaskGenerator&&) = delete;
5858

5959
/**
6060
* @brief Get the task name
@@ -68,29 +68,29 @@ class ProcessGenerator
6868
* @param taskflow The taskflow to associate the task with
6969
* @return Task
7070
*/
71-
virtual tf::Task generateTask(ProcessInput input, tf::Taskflow& taskflow);
71+
virtual tf::Task generateTask(TaskInput input, tf::Taskflow& taskflow);
7272

7373
/**
7474
* @brief Assign work to the provided task
7575
* @param input The process input
7676
* @param task The task to assign the work to
7777
*/
78-
virtual void assignTask(ProcessInput input, tf::Task& task);
78+
virtual void assignTask(TaskInput input, tf::Task& task);
7979

8080
/**
8181
* @brief Generated a Task
8282
* @param input The process input
8383
* @param taskflow The taskflow to associate the task with
8484
* @return Conditional Task
8585
*/
86-
virtual tf::Task generateConditionalTask(ProcessInput input, tf::Taskflow& taskflow);
86+
virtual tf::Task generateConditionalTask(TaskInput input, tf::Taskflow& taskflow);
8787

8888
/**
8989
* @brief Assign work to the provided task
9090
* @param input The process input
9191
* @param task The task to assign the work to
9292
*/
93-
virtual void assignConditionalTask(ProcessInput input, tf::Task& task);
93+
virtual void assignConditionalTask(TaskInput input, tf::Task& task);
9494

9595
protected:
9696
/** @brief The name of the process */
@@ -101,14 +101,14 @@ class ProcessGenerator
101101
* @param input The process input
102102
* @return Task
103103
*/
104-
virtual void process(ProcessInput input, std::size_t unique_id) const = 0;
104+
virtual void process(TaskInput input, std::size_t unique_id) const = 0;
105105

106106
/**
107107
* @brief Generate Conditional Task
108108
* @param input The process input
109109
* @return Conditional Task
110110
*/
111-
virtual int conditionalProcess(ProcessInput input, std::size_t unique_id) const = 0;
111+
virtual int conditionalProcess(TaskInput input, std::size_t unique_id) const = 0;
112112
};
113113

114114
} // namespace tesseract_planning
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* @file task_info.h
3+
* @brief Process Info
4+
*
5+
* @author Matthew Powelson
6+
* @date July 15. 2020
7+
* @version TODO
8+
* @bug No known bugs
9+
*
10+
* @copyright Copyright (c) 2020, Southwest Research Institute
11+
*
12+
* @par License
13+
* Software License Agreement (Apache License)
14+
* @par
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* @par
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
#ifndef TESSERACT_PROCESS_MANAGERS_task_info_H
27+
#define TESSERACT_PROCESS_MANAGERS_task_info_H
28+
29+
#include <tesseract_common/macros.h>
30+
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
31+
#include <memory>
32+
#include <shared_mutex>
33+
#include <map>
34+
TESSERACT_COMMON_IGNORE_WARNINGS_POP
35+
36+
#ifdef SWIG
37+
%shared_ptr(tesseract_planning::TaskInfo)
38+
%template(TaskInfoMap) std::map<std::size_t, std::shared_ptr<const tesseract_planning::TaskInfo>>;
39+
%shared_ptr(tesseract_planning::TaskInfoContainer)
40+
#endif // SWIG
41+
42+
namespace tesseract_planning
43+
{
44+
/** Stores information about a Task */
45+
class TaskInfo
46+
{
47+
public:
48+
using Ptr = std::shared_ptr<TaskInfo>;
49+
using ConstPtr = std::shared_ptr<const TaskInfo>;
50+
51+
TaskInfo(std::size_t unique_id, std::string name = "");
52+
virtual ~TaskInfo() = default;
53+
TaskInfo(const TaskInfo&) = default;
54+
TaskInfo& operator=(const TaskInfo&) = default;
55+
TaskInfo(TaskInfo&&) = default;
56+
TaskInfo& operator=(TaskInfo&&) = default;
57+
58+
/** @brief Value returned from the Task on completion */
59+
int return_value;
60+
61+
/** @brief Unique ID generated for the Task by Taskflow */
62+
std::size_t unique_id;
63+
64+
std::string task_name;
65+
66+
std::string message;
67+
};
68+
69+
/** @brief A threadsafe container for TaskInfos */
70+
struct TaskInfoContainer
71+
{
72+
using Ptr = std::shared_ptr<TaskInfoContainer>;
73+
using ConstPtr = std::shared_ptr<const TaskInfoContainer>;
74+
75+
void addTaskInfo(TaskInfo::ConstPtr task_info);
76+
77+
TaskInfo::ConstPtr operator[](std::size_t index) const;
78+
79+
/** @brief Get a copy of the task_info_map_ in case it gets resized*/
80+
std::map<std::size_t, TaskInfo::ConstPtr> getTaskInfoMap() const;
81+
82+
private:
83+
mutable std::shared_mutex mutex_;
84+
std::map<std::size_t, TaskInfo::ConstPtr> task_info_map_;
85+
};
86+
} // namespace tesseract_planning
87+
88+
#endif // TESSERACT_PROCESS_MANAGERS_task_info_H

0 commit comments

Comments
 (0)