当前位置: 首页>>代码示例>>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;未经允许,请勿转载。