Module#
Introduction#
The VEX AIR Drone features a module port, which can connect to various VEX AIR Modules. These allow the drone to drop and hold different payloads.
Note: These methods only work with the Motorized Hook Module and the Magnet Module.
Below is a list of all available methods:
Actions
drop_payload– Releases a payload using the attached module.hold_payload– Holds a payload using the attached module.
Getters
get_type– Returns the type of module that is attached to the drone.is_holding– Returns the current state of the Motorized Hook Module.
Actions#
drop_payload#
drop_payload releases a payload using the attached module. The Motorized Hook Module opens its hook, and the Magnet Module turns its magnet off.
Note: This method only works with the Motorized Hook Module and the Magnet Module.
Usage:
drone.module.drop_payload()
Parameters |
Description |
|---|---|
This method has no parameters. |
# 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 holds a payload using the attached module. The Motorized Hook Module closes its hook, and the Magnet Module turns its magnet on.
Note: This method only works with the Motorized Hook Module and the Magnet Module.
Usage:
drone.module.hold_payload()
Parameters |
Description |
|---|---|
This method has no parameters. |
# 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()
Getters#
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.
Usage:
drone.module.get_type()
Parameters |
Description |
|---|---|
This method has no parameters. |
# 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.
Note: This method only works with the Motorized Hook Module.
Usage:
drone.module.is_holding()
Parameters |
Description |
|---|---|
This method has no parameters. |
# 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)