Competencia#

Introducción#

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.).

Constructores de clases#

competition();

Instructor de clase#

Destroys the competition object and releases associated resources.

~competition();

Parámetros#

Este constructor no acepta ningún parámetro.

Ejemplos#

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

Funciones de los miembros#

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#

Registra una función que se llamará cuando comience el período autónomo.

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

Parameters

Nombre

Tipo

Descripción

callback

void (*)(void)

Un puntero a una función que no recibe parámetros ni devuelve ningún valor. Esta función se ejecutará al inicio del período autónomo.

Return Values

Esta función no devuelve ningún valor.

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#

Registra una función que se llamará cuando comience el período de control del conductor.

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

Parameters

Parámetro

Tipo

Descripción

callback

void (*)(void)

Un puntero a una función que no recibe parámetros ni devuelve ningún valor. Esta función se ejecutará cuando comience el período de control del conductor.

Return Values

Esta función no devuelve ningún valor.

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#

Devuelve el estado de tu robot cuando está bajo control de competición.

Available Functions
bool isEnabled();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Devuelve un valor booleano que indica si el período de control autónomo o del conductor está activo:

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

  • false – Neither control period is active.

isDriverControl#

Devuelve un valor booleano que indica si el robot está en modo de control del conductor.

Available Functions
bool isDriverControl();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Devuelve un valor booleano que indica si el robot está en modo de control del conductor:

  • true – The robot is in driver control mode.

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

isAutonomous#

Devuelve un valor booleano que indica si el robot está en modo autónomo.

Available Functions
bool isAutonomous();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Devuelve un valor booleano que indica si el robot está en modo autónomo:

  • true – The robot is in autonomous mode.

  • false – The robot is not in autonomous mode.

isCompetitionSwitch#

Devuelve un valor booleano que indica si el interruptor de control de competición está conectado:

Available Functions
bool isCompetitionSwitch();

Parameters

Esta función no acepta ningún parámetro.

Notes
  • Esta función comprueba si el interruptor de control de competición está conectado. El interruptor de control de competición se utiliza antes de que el sistema de control de campo V5 esté instalado.

Return Values

Devuelve un valor booleano que indica si el interruptor de control de competición está conectado:

  • true – The Competition Control Switch is connected.

  • false – The Competition Control Switch is not connected.

isFieldControl#

Devuelve un valor booleano que indica si el controlador de campo está conectado.

Available Functions
bool isFieldControl();

Parameters

Esta función no acepta ningún parámetro.

Return Values

Devuelve un valor booleano que indica si el controlador de campo está conectado:

  • true – The Field Controller is connected.

  • false – The Field Controller is not connected.