Ανταγωνισμός#

Εισαγωγή#

The competition class helps you structure a V5 project for official competition control. It lets you register functions to run during Autonomous and Driver Control, and provides simple status checks so your code can respond to match state (enabled/disabled, autonomous/driver, field control, etc.).

Κατασκευαστές κλάσεων#

competition();

Καταστροφέας κλάσης#

Destroys the competition object and releases associated resources.

~competition();

Παράμετροι#

Αυτός ο κατασκευαστής δεν δέχεται καμία παράμετρο.

Παραδείγματα#

// Create the competition instance
competition Competition = competition();

Συναρτήσεις Μελών#

The competition class includes the following member functions:

  • autonomous — Registers a function to be called when the Autonomous period begins.

  • drivercontrol — Registers a function to be called when the Driver Control period begins.

  • isEnabled — Returns the status of your robot when under competition control.

  • isDriverControl — Returns whether the state of the robot is driver control.

  • isAutonomous — Returns whether the state of the robot is autonomous.

  • isCompetitionSwitch — Returns whether the competition switch is connected.

  • isFieldControl — Returns whether the field control is connected.

Before calling any competition member functions, a competition instance must be created, as shown below:

// Create the competition instance
competition Competition = competition();

autonomous#

Καταχωρεί μια συνάρτηση που θα κληθεί όταν ξεκινήσει η Αυτόνομη περίοδος.

Available Functions
void autonomous( void (* callback)(void) );

Parameters

Ονομα

Τύπος

Περιγραφή

callback

void (*)(void)

Ένας δείκτης προς μια συνάρτηση που δεν δέχεται παραμέτρους και δεν επιστρέφει τιμή. Αυτή η συνάρτηση θα εκτελεστεί όταν ξεκινήσει η Αυτόνομη περίοδος.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Examples
void autonomousControl(void) {
  // Place automonous code here.
  Brain.Screen.clearScreen();
  Brain.Screen.print("autonomous");
}

int main(){
    // Create competition instance.
    competition Competition;

    // Set up callback for the autonomous control period.
    Competition.autonomous(autonomousControl);

    // Prevent main from exiting with an infinite loop.
    while (true) {
        wait(100, msec);
    }
}

drivercontrol#

Καταγράφει μια συνάρτηση που θα κληθεί όταν ξεκινήσει η περίοδος Ελέγχου Οδηγού.

Available Functions
void drivercontrol( void (* callback)(void) );

Parameters

Παράμετρος

Τύπος

Περιγραφή

callback

void (*)(void)

Ένας δείκτης προς μια συνάρτηση που δεν δέχεται παραμέτρους και δεν επιστρέφει τιμή. Αυτή η συνάρτηση θα εκτελεστεί όταν ξεκινήσει η περίοδος Ελέγχου Οδηγού.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Examples
void userControl(void) {
  Brain.Screen.clearScreen();
  // place driver control in this while loop
  while (true) {
    wait(20, msec);
  }
}

int main(){
    // Create competition instance.
    competition Competition;

    // Set up callback for the driver control period.
    Competition.drivercontrol(userControl);

    // Prevent main from exiting with an infinite loop.
    while (true) {
        wait(100, msec);
    }
}

isEnabled#

Επιστρέφει την κατάσταση του ρομπότ σας όταν βρίσκεται υπό έλεγχο ανταγωνισμού.

Available Functions
bool isEnabled();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν η περίοδος αυτόνομου ελέγχου ή ελέγχου οδηγού είναι ενεργή:

  • true – The autonomous or driver control period is active.

  • false – Neither control period is active.

isDriverControl#

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε λειτουργία ελέγχου προγράμματος οδήγησης.

Available Functions
bool isDriverControl();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε λειτουργία ελέγχου προγράμματος οδήγησης:

  • true – The robot is in driver control mode.

  • false – The robot is not in driver control mode.

isAutonomous#

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε αυτόνομη λειτουργία.

Available Functions
bool isAutonomous();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε αυτόνομη λειτουργία:

  • true – The robot is in autonomous mode.

  • false – The robot is not in autonomous mode.

isCompetitionSwitch#

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο διακόπτης ελέγχου ανταγωνισμού είναι συνδεδεμένος:

Available Functions
bool isCompetitionSwitch();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Notes
  • Αυτή η λειτουργία ελέγχει εάν είναι συνδεδεμένος ο Διακόπτης Ελέγχου Αγώνα. Ο Διακόπτης Ελέγχου Αγώνα χρησιμοποιείται πριν από την εγκατάσταση του Συστήματος Ελέγχου Πεδίου V5.

Return Values

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο διακόπτης ελέγχου ανταγωνισμού είναι συνδεδεμένος:

  • true – The Competition Control Switch is connected.

  • false – The Competition Control Switch is not connected.

isFieldControl#

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο ελεγκτής πεδίου είναι συνδεδεμένος.

Available Functions
bool isFieldControl();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο Ελεγκτής Πεδίου είναι συνδεδεμένος:

  • true – The Field Controller is connected.

  • false – The Field Controller is not connected.