Skip to content

Commit

Permalink
Deleted unnecessary wait and corrected style (ros-navigation#1622)
Browse files Browse the repository at this point in the history
Signed-off-by: Aitor Miguel Blanco <aitormibl@gmail.com>
  • Loading branch information
gimait committed Apr 14, 2020
1 parent b881af3 commit f6c7160
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions nav2_recoveries/plugins/wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ Wait::~Wait()

Status Wait::onRun(const std::shared_ptr<const WaitAction::Goal> command)
{
run_end_ = std::chrono::steady_clock::now() + rclcpp::Duration(command->time).to_chrono<std::chrono::nanoseconds>();
wait_end_ = std::chrono::steady_clock::now() +
rclcpp::Duration(command->time).to_chrono<std::chrono::nanoseconds>();
return Status::SUCCEEDED;
}

Status Wait::onCycleUpdate()
{
auto current_point = std::chrono::steady_clock::now();
auto time_left = std::chrono::duration_cast<std::chrono::nanoseconds>(run_end_ - current_point).count();
auto time_left =
std::chrono::duration_cast<std::chrono::nanoseconds>(wait_end_ - current_point).count();

if (time_left > 0) {
return Status::RUNNING;
}
else {
rclcpp::sleep_for(std::chrono::milliseconds(100));
} else {
return Status::SUCCEEDED;
}
}
Expand Down
2 changes: 1 addition & 1 deletion nav2_recoveries/plugins/wait.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Wait : public Recovery<WaitAction>
Status onCycleUpdate() override;

protected:
std::chrono::time_point<std::chrono::steady_clock> run_end_;
std::chrono::time_point<std::chrono::steady_clock> wait_end_;
};

} // namespace nav2_recoveries
Expand Down

0 comments on commit f6c7160

Please sign in to comment.