示例#1
0
def wiggle():
    '''
	Use randint() to generate integers from -wiggleRange to wiggleRange
	'''
    alterMove.linkageQ(1, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(2, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(3, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(4, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
示例#2
0
def wiggle():
    '''
	使用randint()来生成-wiggleRange到wiggleRange之间的整数
	'''
    alterMove.linkageQ(1, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(2, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(3, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
    alterMove.linkageQ(4, 0,
                       stayHeight + random.randint(-wiggleRange, wiggleRange))
示例#3
0
def pitchRoll(pIn, rIn):
    '''
	Because the back and forth movement of the legs is not required in the automatic stabilization mode
	So the X-axis coordinate point of the end point of each leg is 0
	'''
    xIn = 0
    '''
	Calculate the Y value of the end point of each leg through pIn and rIn
	'''
    y_1 = rangeCtrl(minHeight, maxHeight, middleHeight + pIn - rIn)
    y_2 = rangeCtrl(minHeight, maxHeight, middleHeight - pIn - rIn)
    y_3 = rangeCtrl(minHeight, maxHeight, middleHeight + pIn + rIn)
    y_4 = rangeCtrl(minHeight, maxHeight, middleHeight - pIn + rIn)
    '''
	Apply new coordinate values to the four legs
	'''
    alterMove.linkageQ(1, xIn, y_1)
    alterMove.linkageQ(2, xIn, y_2)
    alterMove.linkageQ(3, xIn, y_3)
    alterMove.linkageQ(4, xIn, y_4)
示例#4
0
def pitchRoll(pIn, rIn):
    '''
	由于自动稳定模式时不需要腿部的前后运动
	所以每条腿末端点的X轴坐标点都为0
	'''
    xIn = 0
    '''
	通过pIn和rIn来计算出每条腿末端点坐标值Y值
	'''
    y_1 = rangeCtrl(minHeight, maxHeight, middleHeight + pIn - rIn)
    y_2 = rangeCtrl(minHeight, maxHeight, middleHeight - pIn - rIn)
    y_3 = rangeCtrl(minHeight, maxHeight, middleHeight + pIn + rIn)
    y_4 = rangeCtrl(minHeight, maxHeight, middleHeight - pIn + rIn)
    '''
	将新的坐标值应用于四条腿
	'''
    alterMove.linkageQ(1, xIn, y_1)
    alterMove.linkageQ(2, xIn, y_2)
    alterMove.linkageQ(3, xIn, y_3)
    alterMove.linkageQ(4, xIn, y_4)
示例#5
0
|		  |
|		  |
2—————————4

x,y参数为着地点的坐标,x正值越大,着地点越偏向前进方向
y正值越大,着地点越偏向地面方向

当你控制每条腿的着地点位置时,不需要实例化Alter对象
因为实例化Alter对象主要目的是进行多线程控制

你可以通过编写着地点位置和设置恰当的延迟时间,为机器人编舞或者编辑其它动作

以下例程分别控制机器人的1、2、3、4号腿摆动,可以直观了解改函数地调用方法
'''
while 1:
    alterMove.linkageQ(1, 15, 50)
    time.sleep(1)

    alterMove.linkageQ(2, 15, 50)
    time.sleep(1)

    alterMove.linkageQ(3, 15, 50)
    time.sleep(1)

    alterMove.linkageQ(4, 15, 50)
    time.sleep(1)

    alterMove.linkageQ(1, -15, 50)
    time.sleep(1)

    alterMove.linkageQ(2, -15, 50)
示例#6
0
def standStill():
    alterMove.linkageQ(1, 0, stayHeight)
    alterMove.linkageQ(2, 0, stayHeight)
    alterMove.linkageQ(3, 0, stayHeight)
    alterMove.linkageQ(4, 0, stayHeight)