java类edu.wpi.first.wpilibj.command.Command的实例源码

Robot.java 文件源码 项目:robot15 阅读 24 收藏 0 点赞 0 评论 0
public void autonomousInit() {

    toteCollectTime = prefs.getDouble("toteTimeout", 1.0);
    driveToAutoTime = prefs.getDouble("timeToAutozone", 4.0);
    driveToAutoSpeed = prefs.getFloat("driveSpeedToScore", -0.8f);
    driveToBinTime = prefs.getDouble("timeToBin", 1.0);
    driveToBinSpeed = prefs.getFloat("driveToBinSpeed", -0.5f);
    elevateToteTime = prefs.getDouble("timeToElevateTote", 1.0);
    rollersEjectTime = prefs.getDouble("timeForRollersToEject", 1.0);
    timeToGroundLevel = prefs.getDouble("timeToGroundLevel", 1.0);
    turnToAutoTime = prefs.getDouble("timeToTurnToAutoZone", 1.0);
    turnToAutoSpeed = prefs.getFloat("speedToTurnToAutoZone", 0.5f);
    binLiftTime = prefs.getDouble("timeToLiftBin", 1.0);
    clawOpenOnElevMove = prefs.getBoolean("clawOpenALot", true);
    clawCloseOnElevMove = prefs.getBoolean("clawCloseALot", true);
    prefs.save();

    // schedule the autonomous command (example)
    autonomousCommand = (Command) chooser.getSelected();
    if (autonomousCommand != null) autonomousCommand.start();
}
Robot.java 文件源码 项目:Robot_2015 阅读 22 收藏 0 点赞 0 评论 0
public void autonomousInit() {
    // schedule the autonomous command
    //RobotMap.forkliftMotor.enableBrakeMode(true);  //TODO: verify that this is how you do it 

    /*
     * RobotMap.driveBaseLeftFrontMotor.enableBrakeMode(true);
     * RobotMap.driveBaseRightFrontMotor.enableBrakeMode(true);
    RobotMap.driveBaseLeftRearMotor.enableBrakeMode(true);
    RobotMap.driveBaseRightRearMotor.enableBrakeMode(true);
     */

    RobotMap.imu.zeroYaw();

    RobotMap.driveBaseLeftFrontMotor.enableBrakeMode(false);
    RobotMap.driveBaseRightFrontMotor.enableBrakeMode(false);
    RobotMap.driveBaseLeftRearMotor.enableBrakeMode(false);
    RobotMap.driveBaseRightRearMotor.enableBrakeMode(false);

    Scheduler.getInstance().add((Command) oi.pattern.getSelected());
}
Trigger.java 文件源码 项目:wpilibj 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Starts the given command whenever the trigger just becomes active.
 * @param command the command to start
 */
public void whenActive(final Command command) {
    new ButtonScheduler() {

        boolean pressedLast = grab();

        public void execute() {
            if (grab()) {
                if (!pressedLast) {
                    pressedLast = true;
                    command.start();
                }
            } else {
                pressedLast = false;
            }
        }
    }.start();
}
Trigger.java 文件源码 项目:wpilibj 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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() {

        boolean pressedLast = grab();

        public void execute() {
            if (grab()) {
                pressedLast = true;
                command.start();
            } else {
                if (pressedLast) {
                    pressedLast = false;
                    command.cancel();
                }
            }
        }
    }.start();
}
Trigger.java 文件源码 项目:wpilibj 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Starts the command when the trigger becomes inactive
 * @param command the command to start
 */
public void whenInactive(final Command command) {
    new ButtonScheduler() {

        boolean pressedLast = grab();

        public void execute() {
            if (grab()) {
                pressedLast = true;
            } else {
                if (pressedLast) {
                    pressedLast = false;
                    command.start();
                }
            }
        }
    }.start();
}
Trigger.java 文件源码 项目:wpilibj 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Toggles a command when the trigger becomes active
 * @param command the command to toggle
 */
public void toggleWhenActive(final Command command) {
     new ButtonScheduler() {

        boolean pressedLast = grab();

        public void execute() {
            if (grab()) {
                if (!pressedLast) {
                    pressedLast = true;
                    if (command.isRunning()){
                        command.cancel();
                    } else{
                        command.start();
                    }
                }
            } else {
                pressedLast = false;
            }
        }
    }.start();
}
Trigger.java 文件源码 项目:wpilibj 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Cancels a command when the trigger becomes active
 * @param command the command to cancel
 */
public void cancelWhenActive(final Command command) {
     new ButtonScheduler() {

        boolean pressedLast = grab();

        public void execute() {
            if (grab()) {
                if (!pressedLast) {
                    pressedLast = true;
                    command.cancel();
                }
            } else {
                pressedLast = false;
            }
        }
    }.start();
}
Robot.java 文件源码 项目:CMonster2014 阅读 31 收藏 0 点赞 0 评论 0
public void autonomousInit() {
//        // Last ditch effort to bring the camera up on the DS laptop, probably
//        // is too late.
//        TargetTrackingCommunication.setCameraEnabled(true);
//        // Tell the DS laptop to starting detecting the hot target
//        TargetTrackingCommunication.setAutonomousVisionRunning(true);
//        Removed this and put it in the autonomous command
//        Robot.driveSubsystem.getRobotDrive().resetGyro();

        // Pick which autonomous mode to use.
        Object selection = autonomousChooser.getSelected();
        if (selection != null && selection instanceof Command) {
            autonomousCommand = (Command) selection;
            autonomousCommand.start();
        } else {
            System.out.println("No autonomous mode selected.");
        }
    }
OI.java 文件源码 项目:Storm2014 阅读 23 收藏 0 点赞 0 评论 0
private Command _changeIntake(final int diff) {
    return new DoNothing() {
        protected void initialize() {
            _intake += diff;
            if(_intake >= 1) {
                Robot.intake.spinIn();
            } else if(_intake <= -1) {
                Robot.intake.spinOut();
            } else {
                Robot.intake.stop();
            }
        }
        protected boolean isFinished() {
            return true;
        }
    };
}
Conditional.java 文件源码 项目:Storm2014 阅读 22 收藏 0 点赞 0 评论 0
public Conditional(final Command ifTrue,final Command ifFalse) {
    super("Condition?" + (ifTrue  == null ? "" : ifTrue .getName()) +
                   ":" + (ifFalse == null ? "" : ifFalse.getName()));
    // Wrap the Commands to expose protected methods
    if(ifTrue != null) {
        _ifTrue  = new PublicCommand(ifTrue);
        for(Enumeration e = _ifTrue.getRequirements();e.hasMoreElements();) {
            requires((Subsystem) e.nextElement());
        }
    } else {
        _ifTrue = null;
    }
    if(ifFalse != null) {
        _ifFalse  = new PublicCommand(ifFalse);
        for(Enumeration e = _ifFalse.getRequirements();e.hasMoreElements();) {
            requires((Subsystem) e.nextElement());
        }
    } else {
        _ifFalse = null;
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号