Skip to content

Commit e506727

Browse files
Update online example to pause every 10 seconds
1 parent 915a9a5 commit e506727

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tesseract_examples/src/online_planning_example.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,12 @@ bool OnlinePlanningExample::onlinePlan()
322322
console_bridge::setLogLevel(console_bridge::LogLevel::CONSOLE_BRIDGE_LOG_INFO);
323323

324324
using namespace std::chrono;
325-
auto prev_start = high_resolution_clock::now();
325+
auto user_input_start = steady_clock::now();
326+
auto prev_start = steady_clock::now();
326327
while (realtime_running_)
327328
{
328-
auto start = high_resolution_clock::now();
329-
auto dt = 0.01 * duration<double>(start - prev_start).count();
329+
auto start = steady_clock::now();
330+
auto dt = 0.01 * std::chrono::duration<double>(start - prev_start).count();
330331
prev_start = start;
331332

332333
// Calculate current position of the robot and update environment current state
@@ -383,12 +384,19 @@ bool OnlinePlanningExample::onlinePlan()
383384
solver.setBoxSize(box_size_);
384385
}
385386

386-
auto stop = high_resolution_clock::now();
387+
auto stop = steady_clock::now();
387388
auto duration = duration_cast<microseconds>(stop - start) / static_cast<double>(num_steps);
388389

389390
// Update manipulator joint values and plot trajectory
390391
updateAndPlotTrajectory(x);
391392

393+
// Wait for user input every 5 seconds to allow viewing the trajectory
394+
if (std::chrono::duration<double>(steady_clock::now() - user_input_start).count() > 10)
395+
{
396+
plotter_->waitForInput("Pausing to allow viewing of trajectory. Hit enter to continue online planner.");
397+
user_input_start = steady_clock::now();
398+
}
399+
392400
std::string message =
393401
"Solver Frequency (Hz): " + std::to_string(1.0 / static_cast<double>(duration.count()) * 1000000.) +
394402
"\nCost: " + std::to_string(nlp_->evaluateTotalExactCost(x));

0 commit comments

Comments
 (0)