Γυροσκοπικός αισθητήρας#
Εισαγωγή#
The gyro class is used to measure the robot’s heading and rotational movement, allowing tracking of orientation over time.
Κατασκευαστής κλάσης#
gyro(
triport::port &port);
Καταστροφέας κλάσης#
Destroys the gyro object and releases associated resources.
virtual ~gyro();
Παράμετροι#
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The 3-Wire Port that the Gyro Sensor is connected to, written as |
Παράδειγμα#
// Create a gyro instance in Port A
gyro GyroA = gyro(Brain.ThreeWirePort.A);
Συναρτήσεις Μελών#
The gyro class includes the following member functions:
calibrate— Calibrates the gyro for stable heading tracking.setHeading— Sets the heading of the gyro.setRotation— Sets the current rotation value of the gyro.heading— Returns the heading of the gyro.rotation— Returns the rotation of the gyro.
Before calling any gyro member functions, a gyro instance must be created, as shown below:
/* This constructor is required when using VS Code.
Gyro Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a gyro instance in Port A
gyro GyroA = gyro(Brain.ThreeWirePort.A);
calibrate#
Βαθμονομεί τον γυροσκοπικό αισθητήρα.
Available Functionsvoid calibrate(
int32_t value = 0 );
Παράμετροι |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The time in seconds to spend calibrating. Default is |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Notescalibrateshould only be called when the sensor is not moving.
// Start calibration with the calibration time set to 3 seconds.
GyroA.calibrate(3);
setHeading#
Ορίζει την κατεύθυνση του γυροσκοπικού αισθητήρα σε μια συγκεκριμένη τιμή.
Available Functionsvoid setHeading(
double value,
rotationUnits units );
Παράμετροι |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η τιμή που θα χρησιμοποιηθεί για τη νέα επικεφαλίδα. |
|
|
The unit that represents the heading:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
setRotation#
Ορίζει την περιστροφή του γυροσκοπικού αισθητήρα σε μια συγκεκριμένη τιμή.
Available Functionsvoid setRotation(
double value,
rotationUnits units );
Παράμετροι |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Η τιμή που θα χρησιμοποιηθεί για τη νέα τιμή περιστροφής. |
|
|
The unit that represents the rotation value:
|
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
heading#
Επιστρέφει την τρέχουσα κατεύθυνση του γυροσκοπικού αισθητήρα.
Available Functionsdouble heading(
rotationUnits units = degrees );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit that represents the heading:
|
Returns a double representing the current heading of the Gyro Sensor in the specified units, defaulting to degrees.
// Get the current heading for the Gyro.
double value = GyroA.heading();
Brain.Screen.print(value);
rotation#
Επιστρέφει την τρέχουσα περιστροφή του γυροσκοπικού αισθητήρα.
Available Functionsdouble rotation(
rotationUnits units = degrees );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
The unit that represents the rotation value:
|
Returns a double representing the current rotation value of the Gyro Sensor in the specified units, defaulting to degrees.
// Get the current rotation for the Gyro.
double value = GyroA.rotation();
Brain.Screen.print(value);