本文整理汇总了Python中pyfirmata.Arduino.servoDetach方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.servoDetach方法的具体用法?Python Arduino.servoDetach怎么用?Python Arduino.servoDetach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyfirmata.Arduino
的用法示例。
在下文中一共展示了Arduino.servoDetach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Uarm
# 需要导入模块: from pyfirmata import Arduino [as 别名]
# 或者: from pyfirmata.Arduino import servoDetach [as 别名]
class Uarm(object):
uarm = None
kAddrOffset = 90
kAddrAandB = 60
uarm_status = 0
pin2_status = 0
coord = {}
g_interpol_val_arr = {}
angle = {}
attachStaus = 0
def __init__(self,port):
self.uarm = Arduino(port)
self.uarmDetach()
def servoAttach(self,servo_number):
if servo_number == 1:
self.servo_base = self.uarm.get_pin('d:11:s')
elif servo_number == 2:
self.servo_left = self.uarm.get_pin('d:13:s')
elif servo_number == 3:
self.servo_right = self.uarm.get_pin('d:12:s')
elif servo_number == 4:
self.servo_end = self.uarm.get_pin('d:10:s')
else:
return
def servoDetach(self,servo_number):
if servo_number == 1:
self.uarm.servoDetach(11)
elif servo_number == 2:
self.uarm.servoDetach(13)
elif servo_number == 3:
self.uarm.servoDetach(12)
elif servo_number == 4:
self.uarm.servoDetach(10)
else:
return
def uarmDisconnect(self):
self.uarm.exit()
def uarmAttach(self):
curAngles = {}
if self.uarm_status == 0:
for n in range(1,5):
curAngles[n] = self.readAngle(n)
time.sleep(0.1)
n = 1
while n<5:
self.servoAttach(n)
n += 1
time.sleep(0.1)
self.writeAngle(curAngles[1],curAngles[2],curAngles[3],curAngles[4])
self.uarm_status = 1
def uarmDetach(self):
n = 1
while n<5:
self.servoDetach(n)
n += 1
self.uarm_status = 0
def angleConstrain(self,Angle):
if Angle <0:
return 0
elif Angle >180:
return 180
else:
return Angle
def writeServoAngleRaw(self,servo_number,Angle):
if servo_number == 1:
self.servo_base.write(self.angleConstrain(round(Angle)))
elif servo_number == 2:
self.servo_left.write(self.angleConstrain(round(Angle)))
elif servo_number == 3:
self.servo_right.write(self.angleConstrain(round(Angle)))
elif servo_number == 4:
self.servo_end.write(self.angleConstrain(round(Angle)))
else:
return
#.........这里部分代码省略.........