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


Python Tracker.get_distance方法代码示例

本文整理汇总了Python中tracker.Tracker.get_distance方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.get_distance方法的具体用法?Python Tracker.get_distance怎么用?Python Tracker.get_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tracker.Tracker的用法示例。


在下文中一共展示了Tracker.get_distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: time

# 需要导入模块: from tracker import Tracker [as 别名]
# 或者: from tracker.Tracker import get_distance [as 别名]
# TODO: Every loop, evaluates all the programs, makes modifications and evaluates again

cache = {}
while tracker.running:
    
    #print "One second range for X", tracker.get_position('axis', time_from = time() - 1)
    #print "3 last positions of circles", tracker.get_position('circle', limit = 3)
    #print "Triangle AVG speed:", tracker.get_path_speed('triangle', time_from = time()-5)[0:]
    #print "Triangle instant speed:", tracker.get_speed('triangle')[0:]
    #print "Arrow angle", tracker.get_angle('arrow')
    
    # Check movements (events)
    for shape in ( 'arrow', ): # 'triangle', 'circle', 'square', 'axis',
        #t = time()
        distances = tracker.get_distance(shape, time_from = time() - 2)
        #print "Distance takes", time()-t
        moved = [ (int(distance*100)/100, i) for i, distance in enumerate(distances) if distance > 2]
        #print moved
        if not moved:
            continue
        
        if cache.get("%s-%d" % (shape, moved[0][1])) > time()-2:
            continue

        if len(moved) == 1:
            print "%s-%d" % (shape, moved[0][1]), "moved by", moved[0][0], "units"
            positions = tracker.get_position(shape, time_from = time() - 2)
            if len(positions) and positions[moved[0][1]]:
                print "From", positions[moved[0][1]][0],"to",positions[moved[0][1]][-1]
        else:
开发者ID:gcobos,项目名称:leggedbot,代码行数:32,代码来源:test_tracker.py


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