001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj2.command.button; 006 007import edu.wpi.first.wpilibj.DriverStation; 008 009/** 010 * A class containing static {@link Trigger} factories for running callbacks when the robot mode 011 * changes. 012 */ 013public final class RobotModeTriggers { 014 // Utility class 015 private RobotModeTriggers() {} 016 017 /** 018 * Returns a trigger that is true when the robot is enabled in autonomous mode. 019 * 020 * @return A trigger that is true when the robot is enabled in autonomous mode. 021 */ 022 public static Trigger autonomous() { 023 return new Trigger(DriverStation::isAutonomousEnabled); 024 } 025 026 /** 027 * Returns a trigger that is true when the robot is enabled in teleop mode. 028 * 029 * @return A trigger that is true when the robot is enabled in teleop mode. 030 */ 031 public static Trigger teleop() { 032 return new Trigger(DriverStation::isTeleopEnabled); 033 } 034 035 /** 036 * Returns a trigger that is true when the robot is disabled. 037 * 038 * @return A trigger that is true when the robot is disabled. 039 */ 040 public static Trigger disabled() { 041 return new Trigger(DriverStation::isDisabled); 042 } 043 044 /** 045 * Returns a trigger that is true when the robot is enabled in test mode. 046 * 047 * @return A trigger that is true when the robot is enabled in test mode. 048 */ 049 public static Trigger test() { 050 return new Trigger(DriverStation::isTestEnabled); 051 } 052}