Skip to content
Snippets Groups Projects
Commit 691abe36 authored by Steven Macenski's avatar Steven Macenski
Browse files

using builtin msgs duration

parent 21a3b113
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ public:
duration *= -1;
}
goal_.time = duration;
goal_.time.sec = duration;
}
};
......
#goal definition
int32 time
builtin_interfaces/Duration time
---
#result definition
std_msgs/Empty result
......
......@@ -24,7 +24,7 @@ namespace nav2_recoveries
Wait::Wait()
: Recovery<WaitAction>()
{
duration_ = 0.0;
duration_.sec = 0.0;
}
Wait::~Wait()
......@@ -39,9 +39,8 @@ Status Wait::onRun(const std::shared_ptr<const WaitAction::Goal> command)
Status Wait::onCycleUpdate()
{
RCLCPP_INFO(node_->get_logger(), "Waiting %i seconds.", duration_);
auto sleep_dur = std::chrono::seconds(duration_);
rclcpp::sleep_for(sleep_dur);
rclcpp::sleep_for(
rclcpp::Duration(duration_).to_chrono<std::chrono::nanoseconds>());
return Status::SUCCEEDED;
}
......
......@@ -37,7 +37,7 @@ public:
Status onCycleUpdate() override;
protected:
int duration_;
builtin_interfaces::msg::Duration duration_;
};
} // namespace nav2_recoveries
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment