Documentation

Current Time

Retrieve current ROS time or system time

  • 库:
  • ROS Toolbox / ROS

Description

TheCurrent Timeblock outputs the current ROS or system time.ROS Timeis based on the system clock of your computer or the/clocktopic being published on the ROS node.

Use this block to synchronize your simulation time with your connected ROS node.

If theuse_sim_timeROS parameter is set totrue, the block returns the simulation time published on the/clocktopic. Otherwise, the block returns the system time of your machine.

Ports

Output

expand all

ROS time, returned as a bus signal or a scalar. The bus represents arosgraph_msgs/ClockROS message withSecandNSecelements. The scalar is the ROS time in seconds. If no time has been received on the/clocktopic, the block outputs0.

Data Types:bus|double

Parameters

expand all

Format of ROSTimeoutput, specified as eitherbusordouble.

Interval between outputs, specified as a numeric scalar.

For more information, seeSpecify Sample Time(Simulink).

Tips

  • To set theuse_sim_timeparameters and get time from a/clocktopic:

    Connect to a ROS network, then use theSet Parameterblock or set the parameter in the MATLAB®command window:

    ptree = rosparam; set(ptree,'/use_sim_time',true)

    Usually, the ROS node that publishes on the/clocktopic sets up the parameter.

See Also

Blocks

Functions

External Websites

Introduced in R2019b