當前位置: 首頁>>代碼示例>>Java>>正文


Java Command類代碼示例

本文整理匯總了Java中edu.wpi.first.wpilibj.command.Command的典型用法代碼示例。如果您正苦於以下問題:Java Command類的具體用法?Java Command怎麽用?Java Command使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Command類屬於edu.wpi.first.wpilibj.command包,在下文中一共展示了Command類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: robotInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit() {


	chooser = new SendableChooser<Command>();
	chassis = new Chassis();
	intake = new Intake();
	winch = new Winch();
//	shooter = new Shooter();
	
	oi = new OI();
	imu = new ADIS16448_IMU(ADIS16448_IMU.Axis.kX);
	pdp = new PowerDistributionPanel();
	
	chooser.addDefault("Drive Straight", new DriveStraight(73, 0.5));
	//chooser.addObject("Left Gear Curve", new LeftGearCurve());
	chooser.addObject("Left Gear Turn", new LeftGearTurn());
	//chooser.addObject("Right Gear Curve", new RightGearCurve());
	chooser.addObject("Right Gear Turn", new RightGearTurn());
	chooser.addObject("Middle Gear", new StraightGear());
	chooser.addObject("Turn in place", new TurnDegrees(60, .2));
	SmartDashboard.putData("Autonomous Chooser", chooser);
}
 
開發者ID:2141-Spartonics,項目名稱:Spartonics-Code,代碼行數:27,代碼來源:Robot.java

示例2: autonomousInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * This autonomous (along with the chooser code above) shows how to select
 * between different autonomous modes using the dashboard. The sendable
 * chooser code works with the Java SmartDashboard. If you prefer the
 * LabVIEW Dashboard, remove all of the chooser code and uncomment the
 * getString code to get the auto name from the text box below the Gyro
 *
 * You can add additional auto modes by adding additional commands to the
 * chooser code above (like the commented example) or additional comparisons
 * to the switch structure below with additional strings & commands.
 */
@Override
public void autonomousInit() {
	mAutonomousCommand = (Command) autoChooser.getSelected();
	//mAutonomousCommand.start();
	if (mAutonomousCommand != null)
		mAutonomousCommand.start();
	/*
	 * String autoSelected = SmartDashboard.getString("Auto Selector",
	 * "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
	 * = new MyAutoCommand(); break; case "Default Auto": default:
	 * autonomousCommand = new ExampleCommand(); break; }
	 */

	/*
	// schedule the autonomous command (example)
	if (autonomousCommand != null)
		autonomousCommand.start();
	*/
}
 
開發者ID:FRC6706,項目名稱:FRC6706_JAVA2017,代碼行數:31,代碼來源:Robot.java

示例3: robotInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
public void robotInit() {
		
	RobotMap.init();
	
	drivetrain = new Drivetrain();
	climber = new Climber();
	// fuel = new Fuel();
	gear = new Gear();
	
	oi = new OI();
	
	// initializes camera server
	server = CameraServer.getInstance();
	// cameraInit();
	// server.startAutomaticCapture(0);
	
	// autonomousCommand = (Command) new AutoMiddleHook();
	autonomousCommand = (Command) new AutoBaseline();
	
	// resets all sensors
	resetAllSensors();

	if (RobotConstants.isTestingEnvironment) updateTestingEnvironment();
	updateSensorDisplay();
}
 
開發者ID:Team4914,項目名稱:2017-emmet,代碼行數:26,代碼來源:Robot.java

示例4: autonomousInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * This autonomous (along with the chooser code above) shows how to select
 * between different autonomous modes using the dashboard. The sendable
 * chooser code works with the Java SmartDashboard. If you prefer the
 * LabVIEW Dashboard, remove all of the chooser code and uncomment the
 * getString code to get the auto name from the text box below the Gyro
 *
 * You can add additional auto modes by adding additional commands to the
 * chooser code above (like the commented example) or additional comparisons
 * to the switch structure below with additional strings & commands.
 */
// @Override
public void autonomousInit() {

	// DEBUG \\
	if (RobotConstants.isTestingEnvironment) readTestingEnvironment();
	
	// resets sensors
	resetAllSensors();
	
	autonomousCommand = (Command) autoChooser.getSelected();

	// schedule the autonomous command (example)
	if (autonomousCommand != null)
		autonomousCommand.start();
}
 
開發者ID:Team4914,項目名稱:2017-emmet,代碼行數:27,代碼來源:Robot.java

示例5: autonomousInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * This autonomous (along with the chooser code above) shows how to select
 * between different autonomous modes using the dashboard. The sendable
 * chooser code works with the Java CustomDashboard. If you prefer the
 * LabVIEW Dashboard, remove all of the chooser code and uncomment the
 * getString line to get the auto name from the text box below the Gyro
 *
 * You can add additional auto modes by adding additional comparisons to the
 * switch structure below with additional strings. If using the
 * SendableChooser make sure to add them to the chooser code above as well.
 */
@Override
public void autonomousInit() {
	driveTrain.resetEncoders();
	driveTrain.resetGyro();
	
	autoSelected = (Command) chooser.getSelected();
	if(autoSelected instanceof Initializer) {
		((Initializer)autoSelected).init();
	}
	autoSelected.start();
	// autoSelected = CustomDashboard.getString("Auto Selector",
	// defaultAuto);
	System.out.println("Auto selected: " + autoSelected);
	pollPreferences();
}
 
開發者ID:Team997Coders,項目名稱:2017SteamBot2,代碼行數:27,代碼來源:Robot.java

示例6: takeInput

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
public static ArrayList<Command> takeInput(String movement, boolean isRev, int shooting)
{
	auto_Commands = new ArrayList<Command>(0);
	if(movement.charAt(0) == 'f')
		auto_Commands.add(new MoveForward(Double.valueOf(movement.substring(1))));
	else if(movement.charAt(0) == 'r')
		auto_Commands.add(new RotateAngle(Double.valueOf(movement.substring(1))));
	else if(movement.charAt(0) == 's')
		auto_Commands.add(new SpyBot(shooting));
	//else if(movement.charAt(0) == 'l')
	//	auto_Commands.add(new CrossLowbar());
	
	if(isRev == true && movement.charAt(0) == 'f')
		auto_Commands.add(new MoveForward(-0.65*Double.valueOf(movement.substring(1)))); //This has the 0.65 because we don't want to accidentially cross the autoline when we go back
	
		
	return auto_Commands; //an arraylist of the commands to be executed in autonomous
}
 
開發者ID:FRC2832,項目名稱:Robot_2016,代碼行數:19,代碼來源:ParseInput.java

示例7: teleopInit

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
public void teleopInit() {
	// This makes sure that the autonomous stops running when
	// teleop starts running. If you want the autonomous to
	// continue until interrupted by another command, remove
	// this line or comment it out.
	if (autonomousCommand != null) {
		autonomousCommand.cancel();
	}
	if (Robot.catapult.getPreviousShooterState() != 0) {
		Robot.catapult.setShooterState(Robot.catapult.getPreviousShooterState());
		Command cmd1 = new Shoot();
		cmd1.start();
		
	}
	Robot.robotDrive.setIsInAuto(false);
}
 
開發者ID:Woodland4678,項目名稱:Cybercavs2016Code,代碼行數:17,代碼來源:Robot.java

示例8: RobotMap

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Default constructor.
 *
 * @param buttons              The buttons for controlling this robot. Can be null for an empty list.
 * @param logger               The logger for recording events and telemetry data.
 * @param updater              A runnable that updates cached variables.
 * @param defaultCommands      The default commands for various subsystems.
 * @param autoStartupCommand   The command to be run when first enabled in autonomous mode.
 * @param teleopStartupCommand The command to be run when first enabled in teleoperated mode.
 * @param startupCommand       The command to be run when first enabled.
 */
@JsonCreator
public RobotMap(@Nullable List<CommandButton> buttons,
                @NotNull @JsonProperty(required = true) Logger logger,
                @NotNull @JsonProperty(required = true) MappedRunnable updater,
                @Nullable List<DefaultCommand> defaultCommands,
                @Nullable Command autoStartupCommand,
                @Nullable Command teleopStartupCommand,
                @Nullable Command startupCommand) {
    this.buttons = buttons != null ? buttons : new ArrayList<>();
    this.logger = logger;
    this.updater = updater;
    this.defaultCommands = defaultCommands;
    this.autoStartupCommand = autoStartupCommand;
    this.teleopStartupCommand = teleopStartupCommand;
    this.startupCommand = startupCommand;
}
 
開發者ID:blair-robot-project,項目名稱:449-central-repo,代碼行數:28,代碼來源:RobotMap.java

示例9: CommandButton

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Default constructor.
 *
 * @param button  The button that triggers the command.
 * @param command The command to run or cancel.
 * @param action  The action to do to the command.
 */
@JsonCreator
public CommandButton(@NotNull @JsonProperty(required = true) MappedButton button,
                     @NotNull @JsonProperty(required = true) Command command,
                     @NotNull @JsonProperty(required = true) Action action) {
    switch (action) {
        case WHILE_HELD:
            button.whileHeld(command);
            break;
        case WHEN_PRESSED:
            button.whenPressed(command);
            break;
        case WHEN_RELEASED:
            button.whenReleased(command);
            break;
        case CANCEL_WHEN_PRESSED:
            button.cancelWhenPressed(command);
            break;
        case TOGGLE_WHEN_PRESSED:
            button.toggleWhenPressed(command);
            break;
    }
}
 
開發者ID:blair-robot-project,項目名稱:449-central-repo,代碼行數:30,代碼來源:CommandButton.java

示例10: whenActive

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Starts the given command whenever the trigger just becomes active.
 *
 * @param command the command to start
 */
public void whenActive(final Command command) {
  new ButtonScheduler() {

    private boolean m_pressedLast = grab();

    @Override
    public void execute() {
      if (grab()) {
        if (!m_pressedLast) {
          m_pressedLast = true;
          command.start();
        }
      } else {
        m_pressedLast = false;
      }
    }
  }.start();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:24,代碼來源:Trigger.java

示例11: whileActive

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Constantly starts the given command while the button is held.
 *
 * {@link Command#start()} will be called repeatedly while the trigger is active, and will be
 * canceled when the trigger becomes inactive.
 *
 * @param command the command to start
 */
public void whileActive(final Command command) {
  new ButtonScheduler() {

    private boolean m_pressedLast = grab();

    @Override
    public void execute() {
      if (grab()) {
        m_pressedLast = true;
        command.start();
      } else {
        if (m_pressedLast) {
          m_pressedLast = false;
          command.cancel();
        }
      }
    }
  }.start();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:28,代碼來源:Trigger.java

示例12: whenInactive

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Starts the command when the trigger becomes inactive.
 *
 * @param command the command to start
 */
public void whenInactive(final Command command) {
  new ButtonScheduler() {

    private boolean m_pressedLast = grab();

    @Override
    public void execute() {
      if (grab()) {
        m_pressedLast = true;
      } else {
        if (m_pressedLast) {
          m_pressedLast = false;
          command.start();
        }
      }
    }
  }.start();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:24,代碼來源:Trigger.java

示例13: toggleWhenActive

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Toggles a command when the trigger becomes active.
 *
 * @param command the command to toggle
 */
public void toggleWhenActive(final Command command) {
  new ButtonScheduler() {

    private boolean m_pressedLast = grab();

    @Override
    public void execute() {
      if (grab()) {
        if (!m_pressedLast) {
          m_pressedLast = true;
          if (command.isRunning()) {
            command.cancel();
          } else {
            command.start();
          }
        }
      } else {
        m_pressedLast = false;
      }
    }
  }.start();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:28,代碼來源:Trigger.java

示例14: cancelWhenActive

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
/**
 * Cancels a command when the trigger becomes active.
 *
 * @param command the command to cancel
 */
public void cancelWhenActive(final Command command) {
  new ButtonScheduler() {

    private boolean m_pressedLast = grab();

    @Override
    public void execute() {
      if (grab()) {
        if (!m_pressedLast) {
          m_pressedLast = true;
          command.cancel();
        }
      } else {
        m_pressedLast = false;
      }
    }
  }.start();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:24,代碼來源:Trigger.java

示例15: parseDriveToPegUsingVisionCommand

import edu.wpi.first.wpilibj.command.Command; //導入依賴的package包/類
private Command parseDriveToPegUsingVisionCommand(List<String> args)
{
    double timeout = 4;
    double deadband = 6;

    if (args.size() >= 2)
    {
        timeout = Double.parseDouble(args.get(1));
    }

    if (args.size() >= 3)
    {
        deadband = Double.parseDouble(args.get(2));
    }

    return new DriveToPegUsingVision(mSnobot.getVisionManager(), mSnobot.getSnobotActor(), deadband, timeout);
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:18,代碼來源:CommandParser.java


注:本文中的edu.wpi.first.wpilibj.command.Command類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。