How To Create A Ros Publisher That Sends The Actual Wall Clock Time To The Subscriber?
Solution 1:
You should be familiar with all the ROS pre-defined message types (although some are significantly more used than others), including the std_msgsstd_msgs/Header message. It includes the std_msgs/Time message and a frame_id
(String) term, for which you could store the location of the time.
Also, the ROS time
type (for which there is a std_msg Time
wrapping it), needs to be acquired from the appropriate ROS (rospy) method, not localtime()
(although you could make the time
from the localtime()
if you wanted).
For more time
/Time references, here is the overview, client time libraries, and python / rospy specifics. The gist is the three (completely equivalent) functions:
rospy.Time.now() #get time as rospy.Time instance
rospy.get_rostime() #get time as rospy.Time instance, same as .now()
rospy.get_time() #get time as float secs
Remember the standard for the "current time" is seconds from 1970 UTC/GMT (timezone +-0). rospy.Time holds to this as it uses python's time.time()
for the current ROS time (which is just a tuple of the seconds since and extra nanoseconds from the second). This will allow you to use the rest of the python tools to format it as you wish. ROS also allows a "simulated time" with the Clock
, as you saw, but that is a fun feature for simulation that isn't what you get by default when you use Time
(no need to worry).
Post a Comment for "How To Create A Ros Publisher That Sends The Actual Wall Clock Time To The Subscriber?"