當前位置: 首頁>>代碼示例>>Python>>正文


Python Tracker.get_position方法代碼示例

本文整理匯總了Python中tracker.Tracker.get_position方法的典型用法代碼示例。如果您正苦於以下問題:Python Tracker.get_position方法的具體用法?Python Tracker.get_position怎麽用?Python Tracker.get_position使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tracker.Tracker的用法示例。


在下文中一共展示了Tracker.get_position方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: time

# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import get_position [as 別名]
    #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:
            print len(moved), (shape + 's' if shape !='axis' else shape), "were moved by", " and ".join(["%s-%d" % (shape, i[1]) for i in moved]), "units"
        cache["%s-%d" % (shape, moved[0][1])] = time()

    
    sleep(0.1)
開發者ID:gcobos,項目名稱:leggedbot,代碼行數:32,代碼來源:test_tracker.py


注:本文中的tracker.Tracker.get_position方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。