问题
- 在两个点间移动时可能出错
- 黑盒验证算法的完备性
测试方法
- 在一个空间范围内随机生成点
-
空间范围选取比较小以确保安全
测试空间
生成点
- 在X,Y,Z范围内随机生成点
def genRandom( lastXyz=(255,0,512) ):
"""
gen a random (x,y,z) in cubicRange
"""
distance = 0
while( distance < 5 ):
x = random.randint( cubicRange[0], cubicRange[1] )
y = random.randint( cubicRange[2], cubicRange[3] )
z = random.randint( cubicRange[4], cubicRange[5] )
distance = spaceDistance( (x,y,z), lastXyz )
return (x,y,z),distance
- 随机生成的点需要剔除距离比较小的点,距离使用欧氏距离
def spaceDistance( xyz1, xyz2 ):
"""
calc the space distance (xyz1) -- (xyz2)
"""
distance = 0
for i in range( 0, 3 ):
distance = math.pow( xyz1[i] - xyz2[i], 2 )
return math.sqrt( distance )
随机测试
- 发送点,控制移动
xyz = ( 255,0,512)
for i in range( 0, 100000 ):
xyz, distance = genRandom( xyz )
print ( "%g,%g,%g,%g" % ( xyz[0],xyz[1],xyz[2], distance ) )
startTime = datetime.datetime.now()
robo.goto( xyz[0],xyz[1],xyz[2], math.pow(distance,1/8) )
print( ( datetime.datetime.now() - startTime).seconds )
网友评论