Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename TaskComposerInput to TaskComposerContext and simplify interfaces #379

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 4 additions & 5 deletions tesseract_examples/src/basic_cartesian_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_motion_planners/trajopt/profile/trajopt_default_plan_profile.h>

#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>

#include <tesseract_geometry/impl/octree.h>
Expand Down Expand Up @@ -256,8 +256,7 @@ bool BasicCartesianExample::run()
// Solve task
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand All @@ -267,7 +266,7 @@ bool BasicCartesianExample::run()
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand All @@ -276,7 +275,7 @@ bool BasicCartesianExample::run()
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}

} // namespace tesseract_examples
16 changes: 7 additions & 9 deletions tesseract_examples/src/car_seat_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_command_language/profile_dictionary.h>
#include <tesseract_command_language/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>

#include <tesseract_motion_planners/trajopt/profile/trajopt_default_composite_profile.h>
Expand Down Expand Up @@ -309,17 +309,16 @@ bool CarSeatExample::run()
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, input_data, profiles);

// Solve task
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

if (!input.isSuccessful())
if (!future->context->isSuccessful())
return false;

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand Down Expand Up @@ -398,17 +397,16 @@ bool CarSeatExample::run()
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, input_data, profiles);

// Solve task
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

if (!input.isSuccessful())
if (!future->context->isSuccessful())
return false;

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand Down
9 changes: 4 additions & 5 deletions tesseract_examples/src/freespace_hybrid_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_motion_planners/ompl/profile/ompl_default_plan_profile.h>
#include <tesseract_motion_planners/core/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>

Expand Down Expand Up @@ -187,15 +187,14 @@ bool FreespaceHybridExample::run()
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, input_data, profiles);

// Solve task
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand All @@ -204,6 +203,6 @@ bool FreespaceHybridExample::run()
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}
} // namespace tesseract_examples
9 changes: 4 additions & 5 deletions tesseract_examples/src/freespace_ompl_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_motion_planners/ompl/profile/ompl_default_plan_profile.h>
#include <tesseract_motion_planners/core/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>

Expand Down Expand Up @@ -187,15 +187,14 @@ bool FreespaceOMPLExample::run()
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, input_data, profiles);

// Solve task
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand All @@ -204,6 +203,6 @@ bool FreespaceOMPLExample::run()
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}
} // namespace tesseract_examples
9 changes: 4 additions & 5 deletions tesseract_examples/src/glass_upright_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_command_language/move_instruction.h>
#include <tesseract_command_language/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>

Expand Down Expand Up @@ -249,8 +249,7 @@ bool GlassUprightExample::run()
// Solve process plan
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand All @@ -260,7 +259,7 @@ bool GlassUprightExample::run()
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand All @@ -270,6 +269,6 @@ bool GlassUprightExample::run()
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}
} // namespace tesseract_examples
19 changes: 9 additions & 10 deletions tesseract_examples/src/pick_and_place_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_command_language/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/planning/profiles/contact_check_profile.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>

Expand Down Expand Up @@ -234,18 +234,17 @@ bool PickAndPlaceExample::run()
auto pick_problem = std::make_unique<PlanningTaskComposerProblem>(env_, pick_input_data, profiles);

// Solve task
TaskComposerInput pick_input(std::move(pick_problem));
TaskComposerFuture::UPtr pick_future = executor->run(*pick_task, pick_input);
TaskComposerFuture::UPtr pick_future = executor->run(*pick_task, std::move(pick_problem));
pick_future->wait();

if (!pick_input.isSuccessful())
if (!pick_future->context->isSuccessful())
return false;

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = pick_input.data_storage.getData(pick_output_key).as<CompositeInstruction>();
auto ci = pick_future->context->getDataStorage().getData(pick_output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand Down Expand Up @@ -278,7 +277,8 @@ bool PickAndPlaceExample::run()
env_->applyCommands(cmds);

// Get the last move instruction
CompositeInstruction pick_composite = pick_input.data_storage.getData(pick_output_key).as<CompositeInstruction>();
CompositeInstruction pick_composite =
pick_future->context->getDataStorage().getData(pick_output_key).as<CompositeInstruction>();
const MoveInstructionPoly* pick_final_state = pick_composite.getLastMoveInstruction();

// Retreat to the approach pose
Expand Down Expand Up @@ -355,18 +355,17 @@ bool PickAndPlaceExample::run()
auto place_problem = std::make_unique<PlanningTaskComposerProblem>(env_, place_input_data, profiles);

// Solve task
TaskComposerInput place_input(std::move(place_problem));
TaskComposerFuture::UPtr place_future = executor->run(*place_task, place_input);
TaskComposerFuture::UPtr place_future = executor->run(*place_task, std::move(place_problem));
place_future->wait();

if (!place_input.isSuccessful())
if (!place_future->context->isSuccessful())
return false;

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = place_input.data_storage.getData(place_output_key).as<CompositeInstruction>();
auto ci = place_future->context->getDataStorage().getData(place_output_key).as<CompositeInstruction>();
tesseract_common::Toolpath toolpath = toToolpath(ci, *env_);
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_motion_planners/trajopt/profile/trajopt_default_solver_profile.h>
#include <tesseract_motion_planners/core/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>
#include <trajopt_sco/osqp_interface.hpp>
Expand Down Expand Up @@ -240,21 +240,20 @@ bool PuzzlePieceAuxillaryAxesExample::run()
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, input_data, profiles);

// Solve task
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

// Plot Process Trajectory
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
plotter_->plotTrajectory(trajectory, *state_solver);
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}
} // namespace tesseract_examples
9 changes: 4 additions & 5 deletions tesseract_examples/src/puzzle_piece_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_motion_planners/trajopt/profile/trajopt_default_solver_profile.h>
#include <tesseract_motion_planners/core/utils.h>
#include <tesseract_task_composer/planning/planning_task_composer_problem.h>
#include <tesseract_task_composer/core/task_composer_input.h>
#include <tesseract_task_composer/core/task_composer_context.h>
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
#include <tesseract_visualization/markers/toolpath_marker.h>

Expand Down Expand Up @@ -234,8 +234,7 @@ bool PuzzlePieceExample::run()
// Solve task
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerInput input(std::move(problem));
TaskComposerFuture::UPtr future = executor->run(*task, input);
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand All @@ -245,13 +244,13 @@ bool PuzzlePieceExample::run()
if (plotter_ != nullptr && plotter_->isConnected())
{
plotter_->waitForInput();
auto ci = input.data_storage.getData(output_key).as<CompositeInstruction>();
auto ci = future->context->getDataStorage().getData(output_key).as<CompositeInstruction>();
tesseract_common::JointTrajectory trajectory = toJointTrajectory(ci);
auto state_solver = env_->getStateSolver();
plotter_->plotTrajectory(trajectory, *state_solver);
}

CONSOLE_BRIDGE_logInform("Final trajectory is collision free");
return input.isSuccessful();
return future->context->isSuccessful();
}
} // namespace tesseract_examples
2 changes: 1 addition & 1 deletion tesseract_task_composer/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_library(
${PROJECT_NAME}
src/task_composer_data_storage.cpp
src/task_composer_context.cpp
src/task_composer_executor.cpp
src/task_composer_graph.cpp
src/task_composer_input.cpp
src/task_composer_node.cpp
src/task_composer_node_info.cpp
src/task_composer_pipeline.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AbortTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DoneTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ErrorTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RemapTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StartTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class SyncTask : public TaskComposerTask
template <class Archive>
void serialize(Archive& ar, const unsigned int version); // NOLINT

TaskComposerNodeInfo::UPtr runImpl(TaskComposerInput& input,
TaskComposerNodeInfo::UPtr runImpl(const TaskComposerContext::Ptr& context,
OptionalTaskComposerExecutor executor = std::nullopt) const override final;
};

Expand Down
Loading