www.gusucode.com > robotics 案例源码程序 matlab代码 > robotics/ROSTimeToMLTimeExample.m
%% ROS Time to MATLAB Time Example % This example shows how to convert current ROS time into a MATLAB(R) % standard time. The ROS Time object is first converted to a double in % seconds, then to the specified MATLAB time. % Copyright 2015 The MathWorks, Inc. % Sets up ROS network and stores ROS time rosinit t = rostime('now'); % Converts ROS time to a double in seconds secondtime = double(t.Sec)+double(t.Nsec)*10^-9; % Sets time to a specified MATLAB format time = datetime(secondtime, 'ConvertFrom','posixtime') % Shuts down ROS network rosshutdown