Skip to content

Commit

Permalink
roscpp/service: use WallTime/WallDuration for waiting (#1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwecht authored and dirk-thomas committed Aug 3, 2020
1 parent aa79a20 commit bda9949
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions clients/roscpp/src/libros/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ bool service::waitForService(const std::string& service_name, ros::Duration time
{
std::string mapped_name = names::resolve(service_name);

Time start_time = Time::now();
const WallTime start_time = WallTime::now();
const WallDuration wall_timeout{timeout.toSec()};

bool printed = false;
bool result = false;
Expand All @@ -103,17 +104,17 @@ bool service::waitForService(const std::string& service_name, ros::Duration time
{
printed = true;

if (timeout >= Duration(0))
if (wall_timeout >= WallDuration(0))
{
Time current_time = Time::now();
const WallTime current_time = WallTime::now();

if ((current_time - start_time) >= timeout)
if ((current_time - start_time) >= wall_timeout)
{
return false;
}
}

Duration(0.02).sleep();
WallDuration(0.02).sleep();
}
}

Expand Down

0 comments on commit bda9949

Please sign in to comment.