Αισθητήρες#
Εισαγωγή#
Το VEX AIR Drone περιλαμβάνει έναν αδρανειακό αισθητήρα για τη μέτρηση της περιστροφικής κίνησης και για την ανίχνευση αλλαγών στην κίνηση, καθώς και έναν αισθητήρα εμβέλειας για την ανίχνευση αποστάσεων. Το VEX AIR Drone μπορεί επίσης να παρακολουθεί τα επίπεδα μπαταρίας του. Αυτοί οι αισθητήρες επιτρέπουν στο drone να παρακολουθεί τον προσανατολισμό, την κατεύθυνση, την επιτάχυνση και την απόστασή του από αντικείμενα.
Παρακάτω είναι μια λίστα με όλες τις διαθέσιμες μεθόδους:
Αδρανειακό - Παρακολουθήστε την περιστροφική κίνηση του drone.
get_rotation– Returns how much the drone has turned since it started.get_heading– Returns the current heading (0 to 359.99°).get_yaw– Returns the yaw angle (–180 to 180°).get_roll– Returns the roll angle (–180 to 180°).get_pitch– Returns the pitch angle (–180 to 180°).reset_rotation– Resets the rotation value to 0.reset_heading– Sets the current heading to 0.set_heading– Sets the heading to a specific value.get_acceleration– Returns acceleration in a specific direction.get_turn_rate– Returns turning rate in degrees per second.
Εμβέλεια — Εντοπισμός αποστάσεων από τους αισθητήρες εμβέλειας του drone.
get_distance— Returns the distance between the selected Range Sensor and the nearest detected object.
Μπαταρία - Επιστροφή του ποσοστού μπαταρίας του drone.
get_battery_level– Returns the drone’s battery level in percent.
Αδρανειακό#
get_rotation#
get_rotation returns how many degrees the drone has turned since it started. It adds up all turns and returns the total in degrees: positive for clockwise, negative for counterclockwise.
Usage:
drone.inertial.get_rotation()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the rotation after turning
drone.take_off(climb_to=500)
drone.turn_for(LEFT, 450, 50)
print(drone.inertial.get_rotation(), end="")
drone.land()
get_heading#
get_heading returns the drone’s heading angle as a float in the range 0 to 359.99 degrees.
Usage:
drone.inertial.get_heading()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the drone's heading after turning
drone.take_off(climb_to=500)
drone.set_turn_velocity(100)
drone.turn(RIGHT)
wait(5, SECONDS)
controller.screen.print("Heading: ")
controller.screen.print(drone.inertial.get_heading())
drone.land()
get_yaw#
get_yaw returns the drone’s yaw angle in the range –180.0 to 180.0 degrees as a float.
Η παρακάτω εικόνα χρησιμοποιεί ένα βέλος για να δείξει την κατεύθυνση της θετικής περιστροφής για την εκτροπή.

Usage:
drone.inertial.get_yaw
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the yaw angle as you rotate the drone by hand
while True:
controller.screen.clear_screen()
controller.screen.set_cursor(1, 1)
controller.screen.print("Yaw: ")
controller.screen.print(drone.inertial.get_yaw())
wait(0.2, SECONDS)
get_roll#
get_roll returns the drone’s roll angle in the range –180.0 to 180.0 degrees as a float.
Η παρακάτω εικόνα χρησιμοποιεί ένα βέλος για να δείξει την κατεύθυνση της θετικής περιστροφής για την κύλιση.

Usage:
drone.inertial.get_roll()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the roll angle as you rotate the drone by hand
while True:
controller.screen.clear_screen()
controller.screen.set_cursor(1, 1)
controller.screen.print("Roll: ")
controller.screen.print(drone.inertial.get_roll())
wait(0.2, SECONDS)
get_pitch#
get_pitch returns the drone’s pitch angle in the range –180.0 to 180.0 degrees as a float.
Η παρακάτω εικόνα χρησιμοποιεί ένα βέλος για να δείξει την κατεύθυνση της θετικής περιστροφής για το βήμα.

Usage:
drone.inertial.get_pitch()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the pitch angle as you rotate the drone by hand
while True:
controller.screen.clear_screen()
controller.screen.set_cursor(1, 1)
controller.screen.print("Pitch: ")
controller.screen.print(drone.inertial.get_pitch())
wait(0.2, SECONDS)
reset_rotation#
reset_rotation resets the drone’s rotation value to 0 degrees.
Usage:
drone.inertial.reset_rotation()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the new rotation after resetting
drone.take_off(climb_to=500)
drone.turn(RIGHT)
while not drone.inertial.get_rotation() > 360:
wait(5, MSEC)
drone.hover()
drone.inertial.reset_rotation()
wait(1, SECONDS)
print(drone.inertial.get_rotation(), end="")
drone.land()
reset_heading#
reset_heading resets the drone’s heading to 0 degrees.
Χρήση:
drone.inertial.reset_heading()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Turn to a heading, reset the heading, and turn to the same heading.
drone.take_off(climb_to=500)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.inertial.reset_heading()
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.land()
set_heading#
set_heading sets the drone’s heading to a specified value in degrees.
Χρήση:
drone.inertial.set_heading(heading)
Παράμετροι |
Περιγραφή |
|---|---|
|
Η τιμή που θα χρησιμοποιηθεί για τη νέα κατεύθυνση στο εύρος 0 έως 359,99 μοίρες. |
# Turn to a heading, set the heading, and turn to the same heading.
drone.take_off(climb_to=500)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.inertial.set_heading(90)
drone.turn_to(heading=180, velocity=50)
wait(3,SECONDS)
drone.land()
get_acceleration#
get_acceleration returns the drone’s acceleration in a specified direction. The returned value represents the rate of change in velocity, measured in units of g (where 1g ≈ 9.81 m/s²), as a float ranging from -4.00 to 4.00.
Η παρακάτω εικόνα χρησιμοποιεί βέλη για να δείξει την κατεύθυνση της θετικής επιτάχυνσης για εμπρός και δεξιά, και της αρνητικής επιτάχυνσης για προς τα κάτω.

Χρήση:
drone.inertial.get_acceleration(type)
Παράμετροι |
Περιγραφή |
|---|---|
|
The direction of acceleration to report:
|
# Display the acceleration as the drone takes off
drone.take_off(500, wait=False)
while True:
controller.screen.clear_screen()
controller.screen.set_cursor(1, 1)
controller.screen.print(drone.inertial.get_acceleration(DOWNWARD))
wait(5, MSEC)
get_turn_rate#
get_turn_rate returns the rate at which the drone is rotating along the specified axis. This returns a value in degrees per second \(dps\) as a float from –1000.00 to 1000.00 dps.
Η παρακάτω εικόνα χρησιμοποιεί βέλη για να δείξει την κατεύθυνση της θετικής περιστροφής για κύλιση, κλίση και εκτροπή.

Usage:
drone.inertial.get_turn_rate(axis)
Παράμετροι |
Περιγραφή |
|---|---|
|
Which orientation to report:
|
# Display the drone turn rate as it is rotated by hand.
while True:
controller.screen.clear_screen()
controller.screen.set_cursor(7, 1)
controller.screen.print(drone.inertial.get_turn_rate(ROLL))
Σειρά#
get_distance#
get_distance returns the distance between the selected Range Sensor and the nearest detected object.
Usage:
drone.range.get_distance(range, units)
Παράμετροι |
Περιγραφή |
|---|---|
|
The Range Sensor to use: |
|
Optional. The distance unit:
|
# Fly forward until close to an object
drone.take_off(climb_to=500)
drone.move_at(direction=0, velocity=50)
while not drone.range.get_distance(FORWARD_RANGE, MM) < 750:
wait(0.1, SECONDS)
drone.land()
Μπαταρία#
get_battery_level#
get_battery_level returns the drone’s battery charge level as a percentage. This returns a number from 0 to 100.
Usage:
drone.get_battery_level()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
# Display the drone's battery level
if drone.get_battery_level() < 25:
controller.screen.print("Charge the drone Battery!")
else:
controller.screen.print("Ready to fly!")