Αισθητήρας GPS#
Εισαγωγή#
Ο αισθητήρας GPS (Game Positioning System™) παρέχει ακριβή παρακολούθηση θέσης και προσανατολισμού για ένα ρομπότ στο Πεδίο VEX. Χρησιμοποιεί τον Κώδικα Πεδίου GPS γύρω από την περίμετρο του Πεδίου για να υπολογίσει τις συντεταγμένες X και Y και την κατεύθυνση του ρομπότ σε πραγματικό χρόνο.
Ο αισθητήρας GPS επιστρέφει τη θέση του ρομπότ χρησιμοποιώντας ένα σημείο αναφοράς που υπολογίζεται αυτόματα από τις μετατοπίσεις που εισάγονται κατά τη διαμόρφωση του αισθητήρα GPS στο παράθυρο Συσκευές.
Για περισσότερες πληροφορίες σχετικά με τον αισθητήρα GPS, διαβάστε την ενότητα Χρήση του αισθητήρα GPS με το VEX V5 στη βιβλιοθήκη VEX.
Το σημείο αναφοράς λειτουργεί ως η θέση (0, 0) του αισθητήρα GPS, όπου όλες οι συντεταγμένες, οι κατευθύνσεις και οι κινήσεις που επιστρέφονται από τις μεθόδους GPS είναι σχετικές με αυτό το διαμορφωμένο σημείο.

This page uses gps_sensor as the example GPS Sensor name. Replace it with your own configured name as needed.
Παρακάτω είναι μια λίστα με τις διαθέσιμες μεθόδους:
calibrate– Calibrates the GPS Sensor to set its heading as the current drivetrain heading.set_origin– Sets the position of the reference point on the robot.set_location– Sets both the reference point’s position and heading on the Field.x_position– Returns the reference point’s x coordinate on the Field.y_position– Returns the reference point’s y coordinate on the Field.heading– Returns the reference point’s heading based on the Field orientation.acceleration– Returns the robot’s acceleration on a selected axis.gyro_rate– Returns the robot’s rotational speed on a selected axis.orientation– Returns the robot’s roll, pitch, or yaw orientation in degrees.quality– Returns the signal strength of the GPS Sensor.changed– Registers a function to be called whenever the GPS Sensor detects a change in heading.
Constructor – Χειροκίνητη αρχικοποίηση ενός αισθητήρα GPS.
Gps– Creates a GPS Sensor.
μετρώ την διάμετρο#
calibrate calibrates the reference point, setting its configured heading as the current drivetrain heading. During this time, the robot must remain completely still as movement during calibration will produce inaccurate results.
Usage:
gps_sensor.calibrate()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
set_origin#
set_origin sets the position of the reference point on the robot manually. This can be done so to manually set a GPS Sensor’s location on a robot instead of doing so in the configuration settings.
Usage:
gps_sensor.set_origin(x, y, distance_units)
Παράμετροι |
Περιγραφή |
|---|---|
χ |
Η συντεταγμένη x του σημείου αναφοράς στο ρομπότ. |
y |
Η συντεταγμένη y του σημείου αναφοράς στο ρομπότ. |
μονάδες_απόστασης |
The unit of measurement for the x and y coordinates:
|
# GPS Sensor is mounted 25mm forward
# from the reference point on a robot
gps.set_origin(0, 25, MM)
ορισμός_τοποθεσίας#
set_location sets the position and heading of the reference point on the Field manually. This can be done to help reduce inaccuracies if the GPS Sensor is too close to the Field’s walls on startup to get a sufficient amount of the GPS Field Code in its view.

Usage:
gps_sensor.set_location(x, y, distance_units, heading, heading_units)
Παράμετροι |
Περιγραφή |
|---|---|
χ |
Η συντεταγμένη x του σημείου αναφοράς στο Πεδίο. |
y |
Η συντεταγμένη y του σημείου αναφοράς στο Πεδίο. |
μονάδες_απόστασης |
The unit of measurement for the x and y coordinates:
|
επικεφαλίδα |
Η κατεύθυνση προς την οποία είναι στραμμένο το σημείο αναφοράς σε σχέση με την απόλυτη κατεύθυνση πεδίου από 0 έως 359,9 μοίρες. |
μονάδες_επικεφαλίδας |
The unit of measurement for the heading: |
x_θέση#
x_position returns the reference point’s x coordinate on the Field.
Usage:
gps_sensor.x_position(units)
Παράμετροι |
Περιγραφή |
|---|---|
μονάδα |
The unit of measurement:
|
y_θέση#
y_position returns the reference point’s y coordinate on the Field.
Usage:
gps_sensor.y_position(units)
Παράμετροι |
Περιγραφή |
|---|---|
μονάδα |
The unit of measurement:
|
επικεφαλίδα#
heading returns the reference point’s heading based on the Field’s orientation from 0 to 359.9 degrees.
Η κατεύθυνση αντιστοιχεί στην απόλυτη κατεύθυνση πεδίου, η οποία είναι ένα εύρος από 0º έως 359,9º δεξιόστροφα. Η 0º βρίσκεται στη θέση 12 η ώρα.

Usage:
gps_sensor.heading()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
επιτάχυνση#
acceleration returns the robot’s acceleration on a specified axis from -4.0 to 4.0 Gs.
Usage:
gps_sensor.acceleration(axis)
Παράμετροι |
Περιγραφή |
|---|---|
άξονας |
Which axis to use:
|
gyro_rate#
gyro_rate returns the robot’s rotational speed on a selected axis.
Usage:
gps_sensor.gyro_rate(axis, units)
Παράμετροι |
Περιγραφή |
|---|---|
άξονας |
Which axis to use:
|
μονάδες |
The unit of measurement:
|
προσανατολισμός#
orientation returns the robot’s roll, pitch, or yaw orientation in degrees.
Usage:
gps_sensor.orientation(axis, units)
Παράμετροι |
Περιγραφή |
|---|---|
άξονας |
Which orientation to use:
|
μονάδες |
The unit of measurement: |
ποιότητα#
quality returns the signal strength of the GPS Sensor as a percent.
Πιθανές τιμές |
Περιγραφή |
|---|---|
100 |
Όλα τα αναφερόμενα δεδομένα θέσης και κατεύθυνσης από τον αισθητήρα GPS είναι έγκυρα. |
~90 |
Οποιαδήποτε δεδομένα θέσης δεν υπολογίζονται πλέον με τη συλλογή πληροφοριών από τον Κώδικα Πεδίου GPS, αλλά μέσω εναλλακτικών μέσων. |
0 - 80 |
Μόνο οι τιμές κατεύθυνσης του αισθητήρα GPS είναι έγκυρες, αλλά καθώς περνάει ο χρόνος και ένας αισθητήρας GPS δεν σαρώνει επαρκώς τον Κώδικα Πεδίου GPS για να προσδιορίσει με ακρίβεια τις πληροφορίες θέσης και κατεύθυνσης, η αναφερόμενη ποιότητα σήματος θα συνεχίσει να μειώνεται μέχρι το 0, όπου τυχόν δεδομένα του αισθητήρα GPS ουσιαστικά παγώνουν και δεν ισχύουν πλέον. |
Usage:
gps_sensor.quality()
Παράμετροι |
Περιγραφή |
|---|---|
Αυτή η μέθοδος δεν έχει παραμέτρους. |
άλλαξε#
changed registers a function to be called whenever the GPS Sensor detects a change in heading.
Usage:
gps_sensor.changed(callback, arg)
Παράμετροι |
Περιγραφή |
|---|---|
|
Μια προηγουμένως καθορισμένη συνάρτηση που εκτελείται όταν αλλάζει η κατεύθυνση του αισθητήρα GPS. |
|
Προαιρετικό. Μια πλειάδα που περιέχει ορίσματα για να μεταβιβαστούν στη συνάρτηση επανάκλησης. Δείτε Χρήση Συναρτήσεων με Παραμέτρους για περισσότερες πληροφορίες. |
def my_function():
brain.screen.print("GPS heading changed")
# Call my_function whenever gps_sensor's heading changes
gps_sensor.changed(my_function)
Κατασκευαστής#
Constructors are used to manually create Gps objects, which are necessary for configuring a GPS Sensor outside of VEXcode.
Gps#
Gps creates a GPS Sensor.
Usage:
Gps(smartport)
Παράμετρος |
Περιγραφή |
|---|---|
|
The Smart Port that the GPS Sensor is connected to, written as |
# Create a GPS Sensor in Port 10
gps_sensor = Gps(Ports.PORT10)