本文整理匯總了Python中rospy.rostime.Time.from_sec方法的典型用法代碼示例。如果您正苦於以下問題:Python Time.from_sec方法的具體用法?Python Time.from_sec怎麽用?Python Time.from_sec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rospy.rostime.Time
的用法示例。
在下文中一共展示了Time.from_sec方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_start_end_time
# 需要導入模塊: from rospy.rostime import Time [as 別名]
# 或者: from rospy.rostime.Time import from_sec [as 別名]
def _get_start_end_time(self, limit):
"""
Returns the start and end time to use (rospy.Time).
also sets self.start_stamp, self.end_stamp
"""
from rospy.rostime import Time # @UnresolvedImport
self.info('limit: %r' % limit)
warnings.warn('Make better code for dealing with unindexed')
if limit is not None and limit != 0:
# try:
chunks = self.bag.__dict__['_chunks']
self.start_stamp = chunks[0].start_time.to_sec()
self.end_stamp = chunks[-1].end_time.to_sec()
start_time = Time.from_sec(self.start_stamp)
end_time = Time.from_sec(self.start_stamp + limit)
return start_time, end_time
# except Exception as e:
# self.error('Perhaps unindexed bag?')
# self.error(traceback.format_exc(e))
# raise
# start_time = None
# end_time = None
#
# self.info('start_stamp: %s' % self.start_stamp)
# self.info('end_stamp: %s' % self.end_stamp)
else:
self.start_stamp = None
self.end_stamp = None
return None, None
示例2: decode
# 需要導入模塊: from rospy.rostime import Time [as 別名]
# 或者: from rospy.rostime.Time import from_sec [as 別名]
def decode(self, _, data):
""" Generate a rospy.rostime.Time instance based on the given data of
the form 'YYYY-MM-DDTHH:MM:SS.mmmmmm' (ISO 8601).
"""
if '+' in data:
data = data[:data.index('+')]
try:
dt = datetime(year=int(data[0:4]), month=int(data[5:7]),
day=int(data[8:10]), hour=int(data[11:13]),
minute=int(data[14:16]), second=int(data[17:19]),
microsecond=int(data[20:]))
except ValueError:
return Time()
return Time.from_sec(time.mktime(dt.timetuple()))