Habilitar el modo de prueba (LiveWindow)

Usted puede añadir código a su programa para mostrar los valores de sus sensores y actuadores mientras se encuentra en modo de prueba. Este modo puede seleccionarse desde la Driver Station cada vez que el robot se encuentre fuera de la cancha. El código para mostrar estos valores es generado automáticamente por RobotBuilder y se describe en el siguiente artículo. El modo de prueba está diseñado para verificar el correcto funcionamiento de los sensores y actuadores en el robot. Además, se puede utilizar para obtener los puntos de control de sensores tales como el potenciómetro, y para sintonizar lazos PID en el código.

Configurar el modo de prueba con la Driver Station

Selecting the "Test" button on the Driver Station and then "Enable".

Para habilitar el modo de prueba en la Driver Station dé click en el botón “Test” y presione “Enable” en el robot. Así la SmartDashboard cambiará al modo de prueba (LiveWindow) y mostrará los estatus de todos los sensores y actuadores en su código.

Modo de prueba explícito vs implícito

PWMSparkMax leftDrive;
PWMSparkMax rightDrive;
PWMVictorSPX arm;
BuiltInAccelerometer accel;

@Override
public void robotInit() {
  leftDrive = new PWMSparkMax(0);
  rightDrive = new PWMSparkMax(1);
  arm = new PWMVictorSPX(2);
  accel = new BuiltInAccelerometer();
  SendableRegistry.setName(arm, "SomeSubsystem", "Arm");
  SendableRegistry.setName(accel, "SomeSubsystem", "Accelerometer");
}

All sensors and actuators will automatically be displayed on the SmartDashboard in test mode and will be named using the object type (such as PWMSparkMax, PWMVictorSPX, BuiltInAccelerometer, etc.) with channel number with which the object was created. In addition, the program can explicitly add sensors and actuators to the test mode display, in which case programmer-defined subsystem and object names can be specified making the program clearer. This example illustrates explicitly defining those sensors and actuators.

Entender qué se muestra en el modo de prueba

Highlights both ungrouped and subsystem motors displayed in test mode.

This is the output in the SmartDashboard display when the robot is placed into test mode. In the display shown above the objects listed as Ungrouped were implicitly created by WPILib when the corresponding objects were created. These objects are contained in a subsystem group called «Ungrouped» (1) and are named with the device type (PWMSparkMax in this case), and the channel numbers. The objects shown in the «SomeSubsystem» (2) group are explicitly created by the programmer from the code example in the previous section. These are named in the calls to SendableRegistry.setName(). Explicitly created sensors and actuators will be grouped by the specified subsystem.