模块#

介绍#

VEX AIR 无人机配备一个模块端口,可连接各种 VEX AIR 模块。这些模块使无人机能够投放和承载不同的有效载荷。

**注意:**只有电动挂钩模块和磁铁模块可以用这些方法控制。

以下是所有可用方法的列表:

行动

吸气剂

  • get_type – Returns the type of module that is attached to the drone.

  • is_holding – Returns the current state of the Motorized Hook Module as a Boolean.

行动#

drop_payload#

drop_payload releases the currently held payload.

用法:

drone.module.drop_payload()

参数

描述

该方法没有参数。

# Demonstrate the Motorized Hook Module moving
drone.take_off(climb_to=800)
wait(1, SECONDS)
drone.module.hold_payload()
wait(2, SECONDS)
drone.module.drop_payload()
drone.land()

hold_payload#

hold_payload picks up the payload.

用法:

drone.module.hold()

参数

描述

该方法没有参数。

# Demonstrate the Motorized Hook Module moving
drone.take_off(climb_to=800)
wait(1, SECONDS)
drone.module.hold_payload()
wait(2, SECONDS)
drone.module.drop_payload()
drone.land()

吸气剂#

get_type#

get_type returns one of the following based on the module currently attached to the drone:

  • DroneModuleType.HOOK – The Motorized Hook Module is attached.

  • DroneModuleType.MAGNET – The Magnet Module is attached.

  • DroneModuleType.PASSIVE – The Passive Hook Module is attached or no module is attached.

用法:

drone.module.get_type()

参数

描述

该方法没有参数。

# Display what module is attached to the drone
# Change the module with Propeller Lock on during project
while True:
    clear_console()
    print(drone.module.get_type())
    wait(0.2,SECONDS)

is_holding#

is_holding returns a Boolean indicating whether the Motorized Hook Module is currently in the hold state, or in the drop state.

  • True – The Motorized Hook Module is lowered.

  • False – The Motorized Hook Module is raised.

**注意:**此方法仅适用于电动挂钩模块。

用法:

drone.module.is_holding()

参数

描述

该方法没有参数。

# Create a custom button to toggle the Motorized Hook Module
def hook_toggle():
    if drone.module.is_holding():
        drone.module.drop_payload()
    else:
        drone.module.hold_payload()

controller.button5.pressed(hook_toggle)