本文整理汇总了Python中pid.PID.get_pid方法的典型用法代码示例。如果您正苦于以下问题:Python PID.get_pid方法的具体用法?Python PID.get_pid怎么用?Python PID.get_pid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pid.PID
的用法示例。
在下文中一共展示了PID.get_pid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _map
# 需要导入模块: from pid import PID [as 别名]
# 或者: from pid.PID import get_pid [as 别名]
fifoCount -= packetSize
fifoBuffer = mpu.getFIFOBytes(packetSize)
yaw, rol, pit = mpu.dmpGetEuler(*mpu.dmpGetQuaternion(fifoBuffer))
g_pit, g_rol, g_yaw = mpu.dmpGetGyro(fifoBuffer)
yaw -= 6
#print(rol, pit, yaw, g_rol, g_pit, g_yaw)
# RC
#print('%s %s %s %s' % (rc_thr.get_width(), rc_rol.get_width(), rc_pit.get_width(), rc_yaw.get_width()))
rc_thr_width = rc_thr.get_width()
rc_rol_width = _map(rc_rol.get_width(), 995, 1945, -45, 45)
rc_pit_width = _map(rc_pit.get_width(), 995, 1945, -45, 45)
rc_yaw_width = _map(rc_yaw.get_width(), 995, 1945, -180, 180)
#print('%s %s %s' % (rc_rol_width, rc_pit_width, rc_yaw_width))
if rc_thr_width > 1200:
# Stablise PIDS
rol_stab_out = max(min(rs_pid.get_pid(rc_rol_width + rol, 1), 250), -250)
pit_stab_out = max(min(ps_pid.get_pid(rc_pit_width + pit, 1), 250), -250)
yaw_stab_out = max(min(ys_pid.get_pid(wrap_180(yaw_target + yaw), 1), 360), -360)
#print('%s %s %s' % (rol_stab_out, pit_stab_out, yaw_stab_out))
if abs(rc_yaw_width) > 5:
yaw_stab_out = rc_yaw_width
yaw_target = yaw
# rate PIDS
rol_out = max(min(rr_pid.get_pid(rol_stab_out + g_rol, 1), 500), -500)
pit_out = max(min(pr_pid.get_pid(pit_stab_out + g_pit, 1), 500), -500)
yaw_out = max(min(yr_pid.get_pid(yaw_stab_out + g_yaw, 1), 500), -500)
#print('%s %s %s' % (rol_out, pit_out, yaw_out))
# ESC
yaw_out = rc_yaw_width
esc_0.move(rc_thr_width - (0.866 * pit_out) + (0.5 * rol_out) - yaw_out)
esc_1.move(rc_thr_width - (0.866 * pit_out) - (0.5 * rol_out) + yaw_out)