本文整理汇总了Python中line.Line.signedDistance方法的典型用法代码示例。如果您正苦于以下问题:Python Line.signedDistance方法的具体用法?Python Line.signedDistance怎么用?Python Line.signedDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.signedDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: roadWidthArr
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import signedDistance [as 别名]
def roadWidthArr( roadPts ):
"points are expected to be 4 already sorted by BLBRTRRL image order"
assert len(roadPts) == 4, roadPts
bl,br,tr,tl = roadPts
lineL = Line(bl,tl)
lineR = Line(br,tr)
return abs(lineR.signedDistance(bl)),abs(lineL.signedDistance(br)),abs(lineL.signedDistance(tr)),abs(lineR.signedDistance(tl))
示例2: findBestLine
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import signedDistance [as 别名]
def findBestLine( arr ):
"find best fitting line in array of points (brute force)"
bestCount = 0
bestLine = None
for a in arr:
for b in arr:
if a != b:
line = Line(a,b)
count = 0
for c in arr:
if math.fabs( line.signedDistance(c) ) < 0.05:
count += 1
if count > bestCount:
print count, (a, b)
bestCount = count
bestLine = line
return bestLine
示例3: followRow
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import signedDistance [as 别名]
def followRow( drone, desiredHeight = 1.5, timeout = 10.0 ):
maxControlGap = 0.0
maxVideoDelay = 0.0
desiredSpeed = MAX_ALLOWED_SPEED
startTime = drone.time
sx,sy,sz,sa = 0,0,0,0
lastUpdate = None
refLine = None
while drone.time < startTime + timeout:
altitude = desiredHeight
if drone.altitudeData != None:
altVision = drone.altitudeData[0]/1000.0
altSonar = drone.altitudeData[3]/1000.0
altitude = (altSonar+altVision)/2.0
# TODO selection based on history? panic when min/max too far??
if abs(altSonar-altVision) > 0.5:
# print altSonar, altVision
altitude = max( altSonar, altVision ) # sonar is 0.0 sometimes (no ECHO)
sz = max( -0.2, min( 0.2, desiredHeight - altitude ))
if altitude > 2.5:
# wind and "out of control"
sz = max( -0.5, min( 0.5, desiredHeight - altitude ))
if drone.lastImageResult:
lastUpdate = drone.time
assert len( drone.lastImageResult ) == 2 and len( drone.lastImageResult[0] ) == 2, drone.lastImageResult
(frameNumber, timestamp), rowTopBottom = drone.lastImageResult
viewlog.dumpVideoFrame( frameNumber, timestamp )
# keep history small
videoTime = correctTimePeriod( timestamp/1000., ref=drone.time )
videoDelay = drone.time - videoTime
if videoDelay > 1.0:
print "!DANGER! - video delay", videoDelay
maxVideoDelay = max( videoDelay, maxVideoDelay )
toDel = 0
for oldTime, oldPose, oldAngles in drone.poseHistory:
toDel += 1
if oldTime >= videoTime:
break
drone.poseHistory = drone.poseHistory[:toDel]
tiltCompensation = Pose(desiredHeight*oldAngles[0], desiredHeight*oldAngles[1], 0) # TODO real height?
validRow = evalRowData( rowTopBottom )
print "FRAME", frameNumber/15, "[%.1f %.1f]" % (math.degrees(oldAngles[0]), math.degrees(oldAngles[1])), validRow
if validRow:
sp = groundPose( *rowTopBottom, scale=ROW_WIDTH/((validRow[0]+validRow[1])/2.0))
sPose = Pose( *oldPose ).add(tiltCompensation).add( sp )
refLine = Line( (sPose.x,sPose.y), (sPose.x + math.cos(sPose.heading), sPose.y + math.sin(sPose.heading)) )
errY, errA = 0.0, 0.0
if refLine:
errY = refLine.signedDistance( drone.coord )
errA = normalizeAnglePIPI( drone.heading - refLine.angle )
sx = max( 0, min( drone.speed, desiredSpeed - drone.vx ))
sy = max( -0.2, min( 0.2, -errY-drone.vy ))/2.0
sa = max( -0.1, min( 0.1, -errA/2.0 ))*1.35*(desiredSpeed/0.4)
prevTime = drone.time
drone.moveXYZA( sx, sy, sz, sa )
drone.poseHistory.append( (drone.time, (drone.coord[0], drone.coord[1], drone.heading), (drone.angleFB, drone.angleLR)) )
maxControlGap = max( drone.time - prevTime, maxControlGap )
return maxControlGap