本文整理汇总了Java中edu.wpi.first.wpilibj.command.InstantCommand类的典型用法代码示例。如果您正苦于以下问题:Java InstantCommand类的具体用法?Java InstantCommand怎么用?Java InstantCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstantCommand类属于edu.wpi.first.wpilibj.command包,在下文中一共展示了InstantCommand类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: robotInit
import edu.wpi.first.wpilibj.command.InstantCommand; //导入依赖的package包/类
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
// Initialize all subsystems
drivetrain = new Drivetrain();
lift = new Lift();
imu = new IMU();
oi = new OI();
System.out.println("Loaded " + name + " v" + version);
chooser.addDefault("Auto 3", new PlayMacro("AutoRecord3"));
chooser.addObject("Auto 4", new PlayMacro("AutoRecord4"));
chooser.addObject("Auto 5", new PlayMacro("AutoRecord5"));
chooser.addObject("Auto 6", new PlayMacro("AutoRecord6"));
chooser.addObject("No Auto", new InstantCommand());
SmartDashboard.putData("Auto mode", chooser);
}
示例2: Shooter
import edu.wpi.first.wpilibj.command.InstantCommand; //导入依赖的package包/类
/**
* Create the instance of Shooter.
*/
public Shooter() {
logger.info("Initialize");
if (RobotMap.IS_ROADKILL) {
return;
}
// account for missing Talons
if (Robot.deviceFinder.isTalonAvailable(RobotMap.CT_ID_SHOOTER_MASTER)) {
masterId = RobotMap.CT_ID_SHOOTER_MASTER;
slaveId = RobotMap.CT_ID_SHOOTER_SLAVE;
} else {
logger.warn("Master talon is missing");
masterId = RobotMap.CT_ID_SHOOTER_SLAVE;
// in case it comes back
slaveId = RobotMap.CT_ID_SHOOTER_MASTER;
}
shooterMaster = new CANTalon(masterId);
// basic setup
shooterMaster.changeControlMode(CANTalon.TalonControlMode.Speed);
shooterMaster.enableBrakeMode(false); // probably bad for 775pros
shooterMaster.setFeedbackDevice(CANTalon.FeedbackDevice.CtreMagEncoder_Relative);
shooterMaster.reverseSensor(false);
// the Talon needs peak and nominal output values
shooterMaster.configNominalOutputVoltage(+0.0f, -0.0f);
shooterMaster.configPeakOutputVoltage(+12.0f, -12.0f);
// configure PID
shooterMaster.setProfile(0);
shooterMaster.setF(0);
shooterMaster.setP(0.12);
shooterMaster.setI(0.00012);
shooterMaster.setD(0.5);
// add to LiveWindow for easy testing
LiveWindow.addActuator("Shooter", "Master", shooterMaster);
shooterSlave = new CANTalon(slaveId);
shooterSlave.changeControlMode(CANTalon.TalonControlMode.Follower);
shooterSlave.enableBrakeMode(false);
shooterSlave.set(masterId);
LiveWindow.addActuator("Shooter", "Slave", shooterSlave);
Thread shooterWatchdog = new Thread(this::shooterWatchdogThread);
// allow JVM to exit
shooterWatchdog.setDaemon(true);
// in the debugger, we'd like to know what this is
shooterWatchdog.setName("Shooter Watchdog Thread");
shooterWatchdog.start();
SmartDashboard.putData(new InstantCommand("ForceOverrideShooterFault") {
@Override
public void execute() {
shooterFault = false;
}
});
}