INNER CODE UNIT · Python

main

ryan4yin/knowledge · electrical-engineering/raspberrypi/robot_arm_pi.py:55

def main():
    left_value = 0
    right_value = 0
    base_value = 0

    while True or KeyboardInterrupt:
        e =  pygame.event.poll()
        # <Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 1, 'value': 0.8169499801629688})>
        if e.type == JOYAXISMOTION:
            # 左摇杆(平面直角坐标系)
            if  e.axis == 0: # x 轴,左舵机
                left_value = e.value
            elif e.axis == 1:  # y 轴,右舵机
                right_value = e.value
            # 右摇杆
            elif  e.axis == 2:  # x 轴,基座旋转
                base_value = e.value
            # elif e.axis == 3:  # Y 轴,钳子收缩

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…