Skip to content

Commit

Permalink
Fix precision error in ros clock sleep (#528)
Browse files Browse the repository at this point in the history
ros clock used AlicaTime::inSeconds() to convert
the duration of the sleep to seconds. However, this
works out to 0 for any time interval < 1 sec. Since
the sleep time is 33 ms in step engine, this can
cause problems. Futher, this rounding behaviour
is not intuitive for users of the clock in general
  • Loading branch information
veerajsk authored Dec 16, 2024
1 parent 209b61e commit 5afc703
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "engine/AlicaClock.h"
#include "ros/time.h"
#include <clock/AlicaROSClock.h>

Expand All @@ -18,7 +19,7 @@ alica::AlicaTime AlicaROSClock::now() const

void AlicaROSClock::sleep(const alica::AlicaTime& time) const
{
ros::Duration(time.inSeconds()).sleep();
ros::Duration((double) time.inNanoseconds() / alica::AlicaTime::seconds(1).inNanoseconds()).sleep();
}

} // namespace alicaRosProxy

0 comments on commit 5afc703

Please sign in to comment.