Skip to content

Commit

Permalink
Update tesseract examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Sep 29, 2023
1 parent dacd8a4 commit 322446c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 61 deletions.
8 changes: 2 additions & 6 deletions tesseract_examples/src/basic_cartesian_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,19 @@ bool BasicCartesianExample::run()
// Create task
const std::string task_name = (ifopt_) ? "TrajOptIfoptPipeline" : "TrajOptPipeline";
TaskComposerNode::UPtr task = factory.createTaskComposerNode(task_name);
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

if (plotter_ != nullptr && plotter_->isConnected())
plotter_->waitForInput("Hit Enter to solve for trajectory.");

// Solve task
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem), std::move(input_data));
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand Down
16 changes: 4 additions & 12 deletions tesseract_examples/src/car_seat_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,14 @@ bool CarSeatExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

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

if (!future->context->isSuccessful())
Expand Down Expand Up @@ -386,18 +382,14 @@ bool CarSeatExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

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

if (!future->context->isSuccessful())
Expand Down
8 changes: 2 additions & 6 deletions tesseract_examples/src/freespace_hybrid_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,14 @@ bool FreespaceHybridExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("FreespacePipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

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

// Plot Process Trajectory
Expand Down
8 changes: 2 additions & 6 deletions tesseract_examples/src/freespace_ompl_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,14 @@ bool FreespaceOMPLExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("OMPLPipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

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

// Plot Process Trajectory
Expand Down
8 changes: 2 additions & 6 deletions tesseract_examples/src/glass_upright_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,19 @@ bool GlassUprightExample::run()
// Create task
const std::string task_name = (ifopt_) ? "TrajOptIfoptPipeline" : "TrajOptPipeline";
TaskComposerNode::UPtr task = factory.createTaskComposerNode(task_name);
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

if (plotter_ != nullptr && plotter_->isConnected())
plotter_->waitForInput("Hit Enter to solve for trajectory.");

// Solve process plan
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem), std::move(input_data));
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand Down
17 changes: 4 additions & 13 deletions tesseract_examples/src/pick_and_place_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,14 @@ bool PickAndPlaceExample::run()

// Create task
TaskComposerNode::UPtr pick_task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string pick_input_key = pick_task->getInputKeys().front();
const std::string pick_output_key = pick_task->getOutputKeys().front();

// Create Task Input Data
auto pick_input_data = std::make_unique<TaskComposerDataStorage>();
pick_input_data->setData(pick_input_key, pick_program);

// Create Task Composer Problem
auto pick_problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
pick_problem->input_instruction = pick_program;

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

if (!pick_future->context->isSuccessful())
Expand Down Expand Up @@ -344,19 +340,14 @@ bool PickAndPlaceExample::run()

// Create task
TaskComposerNode::UPtr place_task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string place_input_key = pick_task->getInputKeys().front();
const std::string place_output_key = pick_task->getOutputKeys().front();

// Create Task Input Data
auto place_input_data = std::make_unique<TaskComposerDataStorage>();
place_input_data->setData(place_input_key, place_program);

// Create Task Composer Problem
auto place_problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
place_problem->input_instruction = place_program;

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

if (!place_future->context->isSuccessful())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,17 @@ bool PuzzlePieceAuxillaryAxesExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

if (plotter_ != nullptr)
plotter_->waitForInput();

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

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

// Plot Process Trajectory
Expand Down
8 changes: 2 additions & 6 deletions tesseract_examples/src/puzzle_piece_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,19 @@ bool PuzzlePieceExample::run()

// Create task
TaskComposerNode::UPtr task = factory.createTaskComposerNode("TrajOptPipeline");
const std::string input_key = task->getInputKeys().front();
const std::string output_key = task->getOutputKeys().front();

// Create Task Input Data
auto input_data = std::make_unique<TaskComposerDataStorage>();
input_data->setData(input_key, program);

if (plotter_ != nullptr)
plotter_->waitForInput();

// Create Task Composer Problem
auto problem = std::make_unique<PlanningTaskComposerProblem>(env_, profiles);
problem->input_instruction = program;

// Solve task
tesseract_common::Timer stopwatch;
stopwatch.start();
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem), std::move(input_data));
TaskComposerFuture::UPtr future = executor->run(*task, std::move(problem));
future->wait();

stopwatch.stop();
Expand Down

0 comments on commit 322446c

Please sign in to comment.