The magnet is only available on the Crane robot.
The magnet of the crane will only stick to containers.
A magnet can be either energised or de-energised, you can turn the magnet on or off by setting
r.magnet.energised like so:
# Turn on the magnet r.magnet.energised = True # Turn off the magnet r.magnet.energised = False
Check the spelling of
energised, it’s in British English,
energized will not work!
You can get the current state of the magnet by getting the value of
energized like so:
magnet_on = r.magnet.energised
The magnet can tell you if there is an object in range to be picked up. You can check if any object is in range by accessing the
# Is there a container nearby? is_nearby = r.magnet.nearby() # True or False