ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

seq or time stamp for publishing a message

asked 2018-03-07 15:47:45 -0500

Ashecotton gravatar image

Hi I am currently working on a web interface to control a turtlebot and i am using ROSLIBJS but i am not too sure what to put for seq and time stamp for the /MoveBaseActionGoal message. If I put a number, it will work for the first time but it i want the turtlebot to go to another destination after it reached its first goal, it will not work because the time stamp is supposed to be the ROS time now. However, I don't know how to get ros time now on ROSLIBJS.

edit retag flag offensive close merge delete


As far as I can recall the seq field should be set for you and you should use ROS time to set the time stamp. I can't look up the documentation for this which is why I'm posting this as a comment.

jayess gravatar image jayess  ( 2018-03-07 16:06:16 -0500 )edit

Yeah me too, I understand that I need ros time for the time stamp but I just don’t know how to get it in the JavaScript or ROSLIBJS. Thanks for the help anyway.

Ashecotton gravatar image Ashecotton  ( 2018-03-07 19:03:37 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-03-07 19:20:37 -0500

jayess gravatar image

If you look at the implementation of the SimpleActionServer, you'll see that you can use the Date object to get the time (in milliseconds):

var currentTime = new Date();
var secs = Math.floor(currentTime.getTime()/1000);
var nsecs = Math.round(1000000000*(currentTime.getTime()/1000-secs));
that.statusMessage.header.stamp.secs = secs;
that.statusMessage.header.stamp.nsecs = nsecs;
edit flag offensive delete link more

Question Tools



Asked: 2018-03-07 15:47:45 -0500

Seen: 1,293 times

Last updated: Mar 07 '18