2Partial stand-in for `rclpy.clock` in ROS1, providing `ClockType` and `Clock`.
4------------------------------------------------------------------------------
5This file is part of rosros - simple unified interface to ROS1 / ROS2.
6Released under the BSD License.
11------------------------------------------------------------------------------
13## @namespace rosros.rclify.clock
14from enum import IntEnum
23 """Enum for clock type."""
36 """Simple clock interface mimicking `rclpy.clock.Clock`, only providing `now()`."""
38 def __init__(self, *, clock_type=ClockType.SYSTEM_TIME):
39 """Raises error if unknown clock type."""
40 if not isinstance(clock_type, ClockType):
41 raise TypeError(
"Clock type must be a ClockType enum")
45 return "Clock(clock_type={0})".format(self.
clock_type.name)
48 """Returns `rospy.Time` according to clock type."""
50 result = rospy.get_rostime()
52 result = rospy.Time(nsecs=time.monotonic_ns())
54 result = rospy.Time(nsecs=time.time_ns())
56 patch.set_extra_attribute(result,
"_clock_type", self.
clock_type)
60__all__ = [
"ClockType",
"Clock"]
Simple clock interface mimicking `rclpy.clock.Clock`, only providing `now()`.
__init__(self, *clock_type=ClockType.SYSTEM_TIME)
Raises error if unknown clock type.
now(self)
Returns `rospy.Time` according to clock type.