磁铁#

Introduction#

The VEX VR Magnet lets your robot interact with magnetic objects by picking them up and releasing them.

Below is a list of all available methods:

Actions – Enable or disable the magnet.

  • energize – Sets the magnet to pick up or drop objects.

Actions#

energize#

energize sets the state of the magnet so it can pick up or drop objects.

Usage:
magnet.energize(action)

参数

描述

action

The state of the magnet to set:

  • BOOST – Enables the magnet to pick up objects.
  • DROP – Disables picking up objects and drops any held objects.
def main():
    # Pick up and drop off a disk
    drivetrain.drive_for(FORWARD, 800, MM)
    magnet.energize(BOOST)
    drivetrain.drive_for(REVERSE, 800, MM)
    magnet.energize(DROP)

# VR threads — Do not delete
vr_thread(main)