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

time_until_next_call returns max if timer is canceled #907

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion rclpy/src/rclpy/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <rcl/timer.h>
#include <rcl/types.h>

#include <limits>
#include <memory>
#include <stdexcept>

Expand Down Expand Up @@ -109,7 +110,10 @@ int64_t Timer::time_until_next_call()
{
int64_t remaining_time;
rcl_ret_t ret = rcl_timer_get_time_until_next_call(rcl_timer_.get(), &remaining_time);
if (ret != RCL_RET_OK) {

if (ret == RCL_RET_TIMER_CANCELED) {
return std::numeric_limits<int64_t>::max();
} else if (ret != RCL_RET_OK) {
throw RCLError("failed to get time until next timer call");
}

Expand Down
1 change: 1 addition & 0 deletions rclpy/src/rclpy/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Timer : public Destroyable, public std::enable_shared_from_this<Timer>
/// Get the time before the timer will be ready
/**
* the returned time can be negative, this means that the timer is ready and hasn't been called yet
* the returned time for a canceled timer is the max representation of an int64_t
*
* Raises RCLError there is an rcl error
*
Expand Down