Open5

ROS 2のuse_sim_timeはどうなっているのか?

f0reachf0reach

ROS TimeのTime Sourceについて

  • /clock topicに1つのソースからpublishする
  • なにもpublishされていない間は時刻が0になる = エラー判定してよい
  • 逆行した場合にコールバックが呼ばれる

Custom Time Source

TimeSourceをオーバーライドして実現できる

rclcppにおいて

実装は以下のファイル
https://github.com/ros2/rclcpp/blob/7ebc9e4cae34483c8d0510b650032a80ae84fd92/rclcpp/src/rclcpp/time_source.cpp

f0reachf0reach

rclcppでの扱いを読む

一般的に用いられているのはTimeSource::NodeStateによるclockのsubscriptionと思われる

https://github.com/ros2/rclcpp/blob/7ebc9e4cae34483c8d0510b650032a80ae84fd92/rclcpp/src/rclcpp/time_source.cpp#L191-L484

興味深いオプション: use_clock_thread_

clockの受信スレッドを分割できる

時間の設定関数 set_all_clocks

  1. set_clockを呼び出す
    2. rcl_disable_ros_time_overridercl_enable_ros_time_overrideで時間を上書きするかどうかを設定する
    3. rcl_set_ros_time_overrideで上書きする

rcl_ret_t rcl_set_ros_time_override(rcl_clock_t *clock, rcl_time_point_value_t time_value)
This function will update the internal storage for the RCL_ROS_TIME time source. If queried and override enabled the time source will return this value, otherwise it will return the system time.