Ανταγωνισμός#
Εισαγωγή#
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 Functionsvoid autonomous( void (* callback)(void) );
Ονομα |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Ένας δείκτης προς μια συνάρτηση που δεν δέχεται παραμέτρους και δεν επιστρέφει τιμή. Αυτή η συνάρτηση θα εκτελεστεί όταν ξεκινήσει η Αυτόνομη περίοδος. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Examplesvoid 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 Functionsvoid drivercontrol( void (* callback)(void) );
Παράμετρος |
Τύπος |
Περιγραφή |
|---|---|---|
|
|
Ένας δείκτης προς μια συνάρτηση που δεν δέχεται παραμέτρους και δεν επιστρέφει τιμή. Αυτή η συνάρτηση θα εκτελεστεί όταν ξεκινήσει η περίοδος Ελέγχου Οδηγού. |
Αυτή η συνάρτηση δεν επιστρέφει τιμή.
Examplesvoid 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 Functionsbool isEnabled();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει μια λογική τιμή που υποδεικνύει εάν η περίοδος αυτόνομου ελέγχου ή ελέγχου οδηγού είναι ενεργή:
true– The autonomous or driver control period is active.false– Neither control period is active.
isDriverControl#
Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε λειτουργία ελέγχου προγράμματος οδήγησης.
Available Functionsbool isDriverControl();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε λειτουργία ελέγχου προγράμματος οδήγησης:
true– The robot is in driver control mode.false– The robot is not in driver control mode.
isAutonomous#
Επιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε αυτόνομη λειτουργία.
Available Functionsbool isAutonomous();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει μια λογική τιμή που υποδεικνύει εάν το ρομπότ βρίσκεται σε αυτόνομη λειτουργία:
true– The robot is in autonomous mode.false– The robot is not in autonomous mode.
isCompetitionSwitch#
Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο διακόπτης ελέγχου ανταγωνισμού είναι συνδεδεμένος:
Available Functionsbool isCompetitionSwitch();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
NotesΑυτή η λειτουργία ελέγχει εάν είναι συνδεδεμένος ο Διακόπτης Ελέγχου Αγώνα. Ο Διακόπτης Ελέγχου Αγώνα χρησιμοποιείται πριν από την εγκατάσταση του Συστήματος Ελέγχου Πεδίου V5.
Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο διακόπτης ελέγχου ανταγωνισμού είναι συνδεδεμένος:
true– The Competition Control Switch is connected.false– The Competition Control Switch is not connected.
isFieldControl#
Επιστρέφει μια λογική τιμή που υποδεικνύει εάν ο ελεγκτής πεδίου είναι συνδεδεμένος.
Available Functionsbool isFieldControl();
Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.
Return ValuesΕπιστρέφει μια λογική τιμή που υποδεικνύει εάν ο Ελεγκτής Πεδίου είναι συνδεδεμένος:
true– The Field Controller is connected.false– The Field Controller is not connected.