RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
TimeHelper类 参考

提供与时间相关的功能。 该类的存在是为了在真实硬件和仿真环境(可能比实时快或慢)下使用相同的脚本逻辑。 在真实硬件上运行时,该类可使用ROS的时间函数;在仿真环境中不依赖ROS。 更多...

Public 成员函数

 __init__ (self)
 构造函数,初始化TimeHelper类对象的相关属性。
 
 time (self)
 获取当前系统时间(单位:秒)。
 
 sleep (self, duration)
 使当前线程休眠指定时长(秒)。
 
 sleepForRate (self, rateHz)
 根据设定的频率使循环以指定的速率执行。
 
 isShutdown (self)
 检查脚本是否应终止(例如用户Ctrl-C)。
 

Public 属性

 rosRate
 
 rateHz
 
 visualizer
 

详细描述

提供与时间相关的功能。 该类的存在是为了在真实硬件和仿真环境(可能比实时快或慢)下使用相同的脚本逻辑。 在真实硬件上运行时,该类可使用ROS的时间函数;在仿真环境中不依赖ROS。

Object containing all time-related functionality.

This class mainly exists to support both real hardware and (potentially
faster or slower than realtime) simulation with the same script.
When running on real hardware, this class uses ROS time functions.
The simulation equivalent does not depend on ROS.

Attributes:
    visualizer: No-op object conforming to the Visualizer API used in
        simulation scripts. Maintains the property that scripts should not
        know/care if they are running in simulation or not.

构造及析构函数说明

◆ __init__()

__init__ ( self)

构造函数,初始化TimeHelper类对象的相关属性。

成员函数说明

◆ isShutdown()

isShutdown ( self)

检查脚本是否应终止(例如用户Ctrl-C)。

  • 返回
    bool: True表示应终止脚本执行,False表示继续执行。
    Returns true if the script should abort, e.g. from Ctrl-C.

◆ sleep()

sleep ( self,
duration )

使当前线程休眠指定时长(秒)。

  • 参数
    duration(float): 需要休眠的时间,单位为秒。
    Sleeps for the provided duration in seconds.

◆ sleepForRate()

sleepForRate ( self,
rateHz )

根据设定的频率使循环以指定的速率执行。

  • 参数
    rateHz(float): 期望的循环频率(Hz)。
    Sleeps so that, if called in a loop, executes at specified rate.

◆ time()

time ( self)

获取当前系统时间(单位:秒)。

  • 返回
    float: 返回当前系统时间(秒)。
    Returns the current time in seconds.

该类的文档由以下文件生成: