How to create ROS message header time stamp?
Show older comments
Trying to write a Matlab Function to retrieve ROS time and then write this time in Sec and Nsec in a ROS message. Matlab function intended to run as part of a larger Simulink model.
Tried this function:
function msg = assignString(blankMessage)
coder.extrinsic ('rostime');
coder.extrinsic ('now');
t=rostime('now'); %get rostime
blankMessage.Header.Stamp.Sec = t.Sec; %populate blank header
blankMessage.Header.Stamp.Nsec = t.Nsec; %populate blank header
msg = blankMessage;
But get error: Attempt to extract field 'Sec' from 'mxArray'.
Function 'MATLAB Function' (#260.161.162), line 7, column 33: "t" Launch diagnostic report. Component:MATLAB Function | Category:Coder error Attempt to extract field 'Nsec' from 'mxArray'.
Function 'MATLAB Function' (#260.224.225), line 8, column 34: "t" Launch diagnostic report. Component:MATLAB Function | Category:Coder error
Any help would be great! Apologies, I am fairly new to Matlab and Simulink...
Accepted Answer
More Answers (0)
Categories
Find more on Publishers and Subscribers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!