当前位置: 首页>>代码示例>>Python>>正文


Python Time.from_sec方法代码示例

本文整理汇总了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
开发者ID:spillai,项目名称:procgraph,代码行数:33,代码来源:bagread.py

示例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()))
开发者ID:dreamfrog,项目名称:rce,代码行数:18,代码来源:converter.py


注:本文中的rospy.rostime.Time.from_sec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。