Use system time as default for a node's clock

asked 2023-07-03 14:51:32 -0500

slim71 gravatar image

updated 2023-07-03 15:03:32 -0500

Hi all.
I was reviewing stuff about nodes' Clock and Time in general, to use in a project. I think I understand the difference between using an "external/custom" Clock and the one owned by a Node, especially when used in simulations.

Now, since I plan to use multiple nodes in my project which will have to exchange data carrying out a timestamp, I thought about making all of their clock stick to the system clock. This way I'm sure they have the same reference point and they are "synchronized" (or rather, as mush as they can be).
Is there a way to accomplish this? Following questions and PRs online I've seen this line being used in a RealSense project, but I'm not sure that's what I want or something custom, since I cannot find any reference for it.

Just in case the link breaks, here is the snippet I refer to. Notice the _ros_clock(RCL_ROS_TIME).

RealSenseCameraNode() : Node(
    "RealSenseCameraNode",
    rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true)),
    _ros_clock(RCL_ROS_TIME),
    _serial_no(""),
    _base_frame_id(""),
    qos(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_default)),
    _intialize_time_base(false) {
  // ..............
  }
edit retag flag offensive close merge delete