Java 类edu.wpi.first.wpilibj.DriverStation 实例源码

项目:2017    文件:ErrorMessage.java   
/**
 * Prints error to specified devices
 *
 * @param errorMessage
 *            the message to be printed.
 * @param attatchTimeStamp
 *            whether or not to include a time stamp.
 */
public void printError (String errorMessage,
        boolean attatchTimeStamp)
{
    String appendedErrorMessage;
    rioTime = getDate();
    matchTime = Hardware.driverStation.getMatchTime();

    if (appendTimeStamp == true)
        appendedErrorMessage = appendErrorMessage(errorMessage);
    else
        appendedErrorMessage = errorMessage;

    // if the error must print to the Drivers' Station
    if (defaultPrintDevice == PrintsTo.driverStation ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        {
        final String dsReport = appendErrorMessage(errorMessage);
        DriverStation.reportError(dsReport, false);
        }
    // if the error must print to the errorlog on the rio.
    if (defaultPrintDevice == PrintsTo.roboRIO ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        PrintsToRIO(appendedErrorMessage);
}
项目:2017    文件:ErrorMessage.java   
/**
 * Prints the error to the specified devices.
 *
 * @param errorMessage
 *            is the message to be printed.
 * @param PrintsTo
 *            determines where to send the debug message to
 */
public void printError (String errorMessage, PrintsTo PrintsTo)
{
    rioTime = "";// getDate();
    matchTime = Hardware.driverStation.getMatchTime();

    // if the error must print to the Drivers' Station
    if (PrintsTo == ErrorMessage.PrintsTo.driverStation ||
            PrintsTo == ErrorMessage.PrintsTo.driverStationAndRoboRIO)
        {
        final String dsReport = appendErrorMessage(errorMessage);
        DriverStation.reportError(dsReport, false);
        }
    // if the error must print to the errorlog on the rio.
    if (PrintsTo == ErrorMessage.PrintsTo.roboRIO ||
            PrintsTo == ErrorMessage.PrintsTo.driverStationAndRoboRIO)
        PrintsToRIO(errorMessage);
}
项目:Robot_2017    文件:NavX.java   
public NavX() {
    try {
    /***********************************************************************
     * navX-MXP: 
     * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
     * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
     * 
     * navX-Micro:
     * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
     * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
     * 
     * Multiple navX-model devices on a single robot are supported.
     ************************************************************************/

        ahrs = new AHRS(SerialPort.Port.kUSB);
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }

}
项目:RA17_RobotCode    文件:JsonAutonomous.java   
/**
 * Creates a JsonAutonomous from the specified file
 * @param file The location of the file to parse
 */
public JsonAutonomous(String file)
{
    ap_ds = DriverStation.getInstance();
    turn = new PIDController(0.02, 0, 0, Robot.navx, this);
    turn.setInputRange(-180, 180);
    turn.setOutputRange(-0.7, 0.7);
    turn.setAbsoluteTolerance(0.5);
    turn.setContinuous(true);

    straighten = new PIDController(0.01, 0, 0, Robot.navx, this);
    straighten.setInputRange(-180, 180);
    straighten.setOutputRange(-0.7, 0.7);
    straighten.setAbsoluteTolerance(0);
    straighten.setContinuous(true);

    turn.setPID(Config.getSetting("auto_turn_p", 0.02), 
            Config.getSetting("auto_turn_i", 0.00001),
            Config.getSetting("auto_turn_d", 0));
    straighten.setPID(Config.getSetting("auto_straight_p", 0.2), 
            Config.getSetting("auto_straight_i", 0),
            Config.getSetting("auto_straight_d", 0));
    parseFile(file);
}
项目:STEAMworks    文件:NavX.java   
public NavX() {
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); // Use SPI!!!
         //ahrs = new AHRS(I2C.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:2017-newcomen    文件:IMU.java   
public IMU() {
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:FRC-2017-Public    文件:Robot.java   
private void logPeriodic() {
        mLogger.logRobotThread("Match time", DriverStation.getInstance().getMatchTime());
        mLogger.logRobotThread("DS Connected", DriverStation.getInstance().isDSAttached());
        mLogger.logRobotThread("DS Voltage", DriverStation.getInstance().getBatteryVoltage());
//      mLogger.logRobotThread("Battery current", HardwareAdapter.getInstance().kPDP.getTotalCurrent());
//      mLogger.logRobotThread("Battery watts drawn", HardwareAdapter.getInstance().kPDP.getTotalPower());
        mLogger.logRobotThread("Outputs disabled", DriverStation.getInstance().isSysActive());
        mLogger.logRobotThread("FMS connected: "+DriverStation.getInstance().isFMSAttached());
        if (DriverStation.getInstance().isAutonomous()) {
            mLogger.logRobotThread("Game period: Auto");
        } else if (DriverStation.getInstance().isDisabled()) {
            mLogger.logRobotThread("Game period: Disabled");
        } else if (DriverStation.getInstance().isOperatorControl()) {
            mLogger.logRobotThread("Game period: Teleop");
        } else if (DriverStation.getInstance().isTest()) {
            mLogger.logRobotThread("Game period: Test");
        }
        if (DriverStation.getInstance().isBrownedOut()) mLogger.logRobotThread("Browned out");
        if (!DriverStation.getInstance().isNewControlData()) mLogger.logRobotThread("Didn't receive new control packet!");
    }
项目:FRC-2017-Public    文件:ADXRS453_Gyro.java   
/**
 * Constructor.
 *
 * @param port
 *            (the SPI port that the gyro is connected to)
 */
public ADXRS453_Gyro(SPI.Port port) {
    m_spi = new SPI(port);
    m_spi.setClockRate(3000000);
    m_spi.setMSBFirst();
    m_spi.setSampleDataOnRising();
    m_spi.setClockActiveHigh();
    m_spi.setChipSelectActiveLow();

    /** Validate the part ID */
    if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
        m_spi.free();
        m_spi = null;
        DriverStation.reportError("Could not find ADXRS453 gyro on SPI port " + port.value, false);
        return;
    }

    m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000E, 0x04000000, 10, 16, true, true);

    calibrate();

    LiveWindow.addSensor("ADXRS453_Gyro", port.value, this);
}
项目:Robot_2016    文件:Robot.java   
public void disabledPeriodic() {
    RobotMap.lightRing.set(Relay.Value.kOff);
    Scheduler.getInstance().run();

    recordedID = (String) (oi.index.getSelected());
    recordedAuton = SmartDashboard.getBoolean("Use Recorded Autonomous");

    Aimer.toPositionMode();
    RobotMap.winchMotor.setEncPosition(0);
    RobotMap.winchMotor.setPosition(0);
    RobotMap.winchMotor.set(0);
    DashboardOutput.putPeriodicData();

    isBlue = (DriverStation.getInstance().getAlliance() == Alliance.Blue);

    sendStateToLights(false, false);
}
项目:CasseroleLib    文件:CsvLogger.java   
/**
 * Clears the IO buffer in memory and forces things to file. Generally a good idea to use this
 * as infrequently as possible (because it increases logging overhead), but definitely use it
 * before the roboRIO might crash without a proper call to the close() method (ie, during
 * brownout)
 * 
 * @return 0 on flush success or -1 on failure.
 */
public static int forceSync() {
    if (log_open == false) {
        DriverStation.reportError("Error - Log is not yet opened, cannot sync!", false);
        return -1;
    }
    try {
        log_file.flush();
    }
    // Catch ALL the errors!!!
    catch (IOException e) {
        DriverStation.reportError("Error flushing IO stream file: " + e.getMessage(), false);
        return -1;
    }

    return 0;

}
项目:CasseroleLib    文件:CsvLogger.java   
/**
 * Closes the log file and ensures everything is written to disk. init() must be called again in
 * order to write to the file.
 * 
 * @return -1 on failure to close, 0 on success
 */
public static int close() {

    if (log_open == false) {
        return 0;
    }

    try {
        log_file.close();
        log_open = false;
    }
    // Catch ALL the errors!!!
    catch (IOException e) {
        DriverStation.reportError("Error Closing Log File: " + e.getMessage(), false);
        return -1;
    }
    return 0;

}
项目:CasseroleLib    文件:CsvLogger.java   
/**
 * Logs data for all stored method handles. Methods that are not considered "simple" should be
 * handled accordingly within this method. This method should be called once per loop.
 * 
 * @param forceSync set true if a forced write is desired (i.e. brownout conditions)
 * @return 0 if log successful, -1 if log is not open, and -2 on other errors
 */
public static int logData(boolean forceSync) {
    if (!log_open) {
        //System.out.println("ERROR - Log is not yet opened, cannot write!");
        return -1;
    }

    if (forceSync)
        forceSync();

    try {
        for (int i = 0; i < methodHandles.size(); i++) {
            MethodHandle mh = methodHandles.get(i);
            String fieldName = dataFieldNames.get(i);
            Vector<Object> mhArgs = mhReferenceObjects.get(i);
            log_file.write(getStandardLogData(mh, mhArgs,fieldName) + ", ");
        }
        log_file.write("\n");
    } catch (Exception ex) {
        DriverStation.reportError("Error writing to log file: " + ex.getMessage(), false);
        return -2;
    }

    return 0;
}
项目:CasseroleLib    文件:ADXRS453_Gyro.java   
/**
 * Constructor.
 *
 * @param port
 *            (the SPI port that the gyro is connected to)
 */
public ADXRS453_Gyro(SPI.Port port) {
    m_spi = new SPI(port);
    m_spi.setClockRate(3000000);
    m_spi.setMSBFirst();
    m_spi.setSampleDataOnRising();
    m_spi.setClockActiveHigh();
    m_spi.setChipSelectActiveLow();

    /** Validate the part ID */
    if ((readRegister(kPIDRegister) & 0xff00) != 0x5200) {
        m_spi.free();
        m_spi = null;
        DriverStation.reportError("Could not find ADXRS453 gyro on SPI port " + port.name(), false);
        return;
    }

    m_spi.initAccumulator(kSamplePeriod, 0x20000000, 4, 0x0c00000E, 0x04000000, 10, 16, true, true);

    calibrate();


}
项目:2016    文件:ErrorMessage.java   
/**
 * Prints error to specified devices.
 *
 * @param errorMessage
 *            to be printed
 */
public void printError (String errorMessage)
{
    String appendedErrorMessage;
    rioTime = getDate();
    matchTime = Hardware.driverStation.getMatchTime();

    if (appendTimeStamp == true)
        appendedErrorMessage = appendErrorMessage(errorMessage);
    else
        appendedErrorMessage = errorMessage;

    // if the error must print to the Drivers' Station
    if (defaultPrintDevice == PrintsTo.driverStation ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        {
        final String dsReport = appendErrorMessage(errorMessage);
        DriverStation.reportError(dsReport, false);
        }
    // if the error must print to the errorlog on the rio.
    if (defaultPrintDevice == PrintsTo.roboRIO ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        PrintsToRIO(appendedErrorMessage);
}
项目:2016    文件:ErrorMessage.java   
/**
 * Prints error to specified devices
 *
 * @param errorMessage
 *            the message to be printed.
 * @param attatchTimeStamp
 *            whether or not to include a time stamp.
 */
public void printError (String errorMessage,
        boolean attatchTimeStamp)
{
    String appendedErrorMessage;
    rioTime = getDate();
    matchTime = Hardware.driverStation.getMatchTime();

    if (appendTimeStamp == true)
        appendedErrorMessage = appendErrorMessage(errorMessage);
    else
        appendedErrorMessage = errorMessage;

    // if the error must print to the Drivers' Station
    if (defaultPrintDevice == PrintsTo.driverStation ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        {
        final String dsReport = appendErrorMessage(errorMessage);
        DriverStation.reportError(dsReport, false);
        }
    // if the error must print to the errorlog on the rio.
    if (defaultPrintDevice == PrintsTo.roboRIO ||
            defaultPrintDevice == PrintsTo.driverStationAndRoboRIO)
        PrintsToRIO(appendedErrorMessage);
}
项目:2016    文件:ErrorMessage.java   
/**
 * Prints the error to the specified devices.
 *
 * @param errorMessage
 *            is the message to be printed.
 * @param PrintsTo
 *            determines where to send the debug message to
 */
public void printError (String errorMessage, PrintsTo PrintsTo)
{
    rioTime = "";// getDate();
    matchTime = Hardware.driverStation.getMatchTime();

    // if the error must print to the Drivers' Station
    if (PrintsTo == ErrorMessage.PrintsTo.driverStation ||
            PrintsTo == ErrorMessage.PrintsTo.driverStationAndRoboRIO)
        {
        final String dsReport = appendErrorMessage(errorMessage);
        DriverStation.reportError(dsReport, false);
        }
    // if the error must print to the errorlog on the rio.
    if (PrintsTo == ErrorMessage.PrintsTo.roboRIO ||
            PrintsTo == ErrorMessage.PrintsTo.driverStationAndRoboRIO)
        PrintsToRIO(errorMessage);
}
项目:snobot-2017    文件:VisionRunner.java   
/**
 * Runs the pipeline one time, giving it the next image from the video source specified
 * in the constructor. This will block until the source either has an image or throws an error.
 * If the source successfully supplied a frame, the pipeline's image input will be set,
 * the pipeline will run, and the listener specified in the constructor will be called to notify
 * it that the pipeline ran.
 *
 * <p>This method is exposed to allow teams to add additional functionality or have their own
 * ways to run the pipeline. Most teams, however, should just use {@link #runForever} in its own
 * thread using a {@link VisionThread}.</p>
 */
public void runOnce() {
  if (Thread.currentThread().getId() == RobotBase.MAIN_THREAD_ID) {
    throw new IllegalStateException(
        "VisionRunner.runOnce() cannot be called from the main robot thread");
  }
  long frameTime = m_cvSink.grabFrame(m_image);
  if (frameTime == 0) {
    // There was an error, report it
    String error = m_cvSink.getError();
    DriverStation.reportError(error, true);
  } else {
    // No errors, process the image
    m_pipeline.process(m_image);
    m_listener.copyPipelineOutputs(m_pipeline);
  }
}
项目:FRC2016    文件:Robot.java   
@Override
public void autonomousInit() {

    System.out.println("Auto INIT");

    Auto am = (Auto) a.getSelected();
    Auto bm = (Auto) b.getSelected();
    Auto cm = (Auto) c.getSelected();
    String picked = "We picked: ";
    picked += am.getClass().getName() + ", ";
    picked += bm.getClass().getName() + ", ";
    picked += cm.getClass().getName();
    DriverStation.reportError(picked, false);
    Auto[] m = { am, bm, cm };

    RobotMap.arm1.setSetpoint(RobotMap.arm1.getPosition());

    move = new ConfigMove(m);
    //move = new TimedStraightMove(0.3, 10);
    move.init();
}
项目:FRC2016    文件:ButtonTracker.java   
public ButtonTracker(Joystick Joystick, int Channel) {
    mChannel = Channel;
    mJoystick = Joystick;

    if (!usedNumbers.containsKey(Joystick)) {
        usedNumbers.put(Joystick, new ButtonTracker[17]);
    }

    if (usedNumbers.get(Joystick)[Channel] != null) {
        // SmartDashboard.putBoolean("ERROR", true);
        System.out.println("MORE THAN ONE BUTTON TRACKER PER BUTTON.");
        DriverStation.reportError("MORE THAN ONE BUTTON TRACKER PER BUTTON!", false);
    }

    usedNumbers.get(Joystick)[Channel] = this;
}
项目:Frc2016FirstStronghold    文件:FrcJoystick.java   
public FrcJoystick(
        final String instanceName,
        final int port,
        ButtonHandler buttonHandler)
{
    super(port);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(
                moduleName + "." + instanceName,
                false,
                TrcDbgTrace.TraceLevel.API,
                TrcDbgTrace.MsgLevel.INFO);
    }

    this.port = port;
    this.buttonHandler = buttonHandler;
    ds = DriverStation.getInstance();
    prevButtons = ds.getStickButtons(port);
    ySign = 1;
    TrcTaskMgr.getInstance().registerTask(
            instanceName,
            this,
            TrcTaskMgr.TaskType.PREPERIODIC_TASK);
}
项目:FRC-2017    文件:NavXSensor.java   
public static void initialize()
{
    if (!initialized) {

        System.out.println("NavXSensor::initialize() called...");

        try {
            ahrs = new AHRS(SPI.Port.kMXP);     
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }

        reset();

        initialized = true;
    }
}
项目:FRC-2017    文件:NavXSensor.java   
public static void initialize()
{
    if (!initialized) {

        System.out.println("NavXSensor::initialize() called...");

        try {
            ahrs = new AHRS(SPI.Port.kMXP);     
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }

        reset();

        initialized = true;
    }
}
项目:FRC-2017    文件:NavXSensor.java   
public static void initialize()
{
    if (!initialized) {

        System.out.println("NavXSensor::initialize() called...");

        try {
            ahrs = new AHRS(SPI.Port.kMXP);     
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }

        reset();

        initialized = true;
    }
}
项目:FRC-2017    文件:NavXSensor.java   
public static void initialize()
{
    if (!initialized) {

        System.out.println("NavXSensor::initialize() called...");

        try {
            ahrs = new AHRS(SPI.Port.kMXP);     
        } catch (RuntimeException ex ) {
            DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
        }

        reset();

        initialized = true;
    }
}
项目:FRC2017    文件:ButtonTracker.java   
public ButtonTracker(Joystick Joystick, int Channel)
{
    mChannel = Channel;
    mJoystick = Joystick;

    if (!usedNumbers.containsKey(Joystick))
        {
            usedNumbers.put(Joystick, new ButtonTracker[17]);
        }

    if (usedNumbers.get(Joystick)[Channel] != null)
        {
            // SmartDashboard.putBoolean("ERROR", true);
            // System.out.println("MORE THAN ONE BUTTON TRACKER PER BUTTON.");
            DriverStation.reportError("MORE THAN ONE BUTTON TRACKER PER BUTTON!", false);
        }

    usedNumbers.get(Joystick)[Channel] = this;
}
项目:Frc2017FirstSteamWorks    文件:FrcJoystick.java   
/**
 * Constructor: Create an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the joystick port ID.
 * @param buttonHandler specifies the object that will handle the button events. If none provided, it is set to
 *        null.
 */
public FrcJoystick(final String instanceName, final int port, ButtonHandler buttonHandler)
{
    super(port);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    this.instanceName = instanceName;
    this.port = port;
    this.buttonHandler = buttonHandler;
    ds = DriverStation.getInstance();
    prevButtons = ds.getStickButtons(port);
    ySign = 1;
    TrcTaskMgr.getInstance().registerTask(instanceName, this, TrcTaskMgr.TaskType.PREPERIODIC_TASK);
}
项目:SparkFun6Dof    文件:GyroITG3200.java   
public boolean writeI2CBuffer(int registerAddress, int data)
{
    boolean retVal = false;
    try
    {
        retVal = m_i2c.write( registerAddress, data );
        if ( DEBUG )
        {
            byte[] buf = new byte[1];
            ReadI2CBuffer( registerAddress, 1, buf);
            if ( data != buf[0] )
            {
                DriverStation.reportError( "Expected " + data + "\nseeing " + buf[0] + "\n", false );
            }
        }
    }
    catch (Throwable t) 
    {
        DriverStation.reportError("ERROR Unhandled exception: " + t.toString() + " at " + Arrays.toString(t.getStackTrace()), false);
    } 
    return retVal;
}
项目:Robot2015    文件:DefaultToteElevatorCommand.java   
@Override
protected void execute() {

    releaseToggle.update(Robot.oi.getElevatorArmReleaseButton());

    if(Robot.oi.getElevatorDecrementButton()) {
        Scheduler.getInstance().add(new DriveToteElevatorCommand(decrementLevel(Robot.toteElevatorSubsystem.getLevel()), false));
    }

    if(Robot.oi.getElevatorArmButton() && Robot.toteElevatorSubsystem.getLevel() == ToteElevatorLevel.ARM_LEVEL) {
        if(Robot.toteIntakeSubsystem.getCurrentCommand() instanceof TeleopPickupCommand) {
            ((TeleopPickupCommand)Robot.toteIntakeSubsystem.getCurrentCommand()).overrideDeploy();
        }
        Robot.toteElevatorSubsystem.setArm(true);

    } else if (Robot.oi.getElevatorArmButton() && Robot.toteElevatorSubsystem.getLevel() != ToteElevatorLevel.ARM_LEVEL) {
        if(Robot.toteIntakeSubsystem.getCurrentCommand() instanceof TeleopPickupCommand) {
            ((TeleopPickupCommand)Robot.toteIntakeSubsystem.getCurrentCommand()).overrideDeploy();
        }
        Scheduler.getInstance().add(new DriveToteElevatorCommand(ToteElevatorLevel.ARM_LEVEL, false));
    } else if(releaseToggle.getState() && !DriverStation.getInstance().isAutonomous()) { 
        Robot.toteElevatorSubsystem.setArm(true);
    } else if(!DriverStation.getInstance().isAutonomous()) {
        Robot.toteElevatorSubsystem.setArm(false);
    }
}
项目:Robot2015    文件:ToteElevatorSubsystem.java   
public void initDriveToLevel(ToteElevatorLevel level) {

        mode = ElevatorMode.AUTOMATIC;

        double difference = encoder.getDistance() - level.encoderSetpoint;

        driveSpeed = 0;

        if(DriverStation.getInstance().isAutonomous()) {
            driveSpeed = 1.0;
        } else if(DriverStation.getInstance().isOperatorControl()) {
            driveSpeed = 1.0;
        }

        if (difference > 0) {
            direction = -1;
        } else {
            direction = 1;
        }
        this.prevLevel = this.level;
        this.level = level;
        elevatorDistanceRampDownPID.setSetpoint(level.encoderSetpoint);

        enableSubsystem();
    }
项目:Robot2015    文件:CopyOfToteElevatorSubsystem.java   
public void initDriveToLevel(ToteElevatorLevel level) {

        mode = ElevatorMode.AUTOMATIC;

        double difference = encoder.getDistance() - level.encoderSetpoint;

        double driveSpeed = 0;

        if(DriverStation.getInstance().isAutonomous()) {
            driveSpeed = 1.0;
        } else if(DriverStation.getInstance().isOperatorControl()) {
            driveSpeed = 0.75;
        }

        if (difference > 0) {
            elevatorRatePIDSetpoint = -driveSpeed;
        } else {
            elevatorRatePIDSetpoint = driveSpeed*0.75;
        }

        this.level = level;

        enableSubsystem();
    }
项目:turtleshell    文件:Robot.java   
public Robot() {
     myRobot = new RobotDrive(0, 1);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:turtleshell    文件:Robot.java   
public Robot() {
     myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
            frontRightChannel, rearRightChannel);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:turtleshell    文件:Robot.java   
/**
 * Runs the motors with arcade steering.
 */
public void operatorControl() {
    myRobot.setSafetyEnabled(true);
    while (isOperatorControl() && isEnabled()) {
        if ( stick.getRawButton(1)) {
            ahrs.reset();
        }
        try {
            /* Use the joystick X axis for lateral movement,            */
            /* Y axis for forward movement, and Z axis for rotation.    */
            /* Use navX MXP yaw angle to define Field-centric transform */
            myRobot.mecanumDrive_Cartesian(stick.getX(), stick.getY(), 
                                           stick.getTwist(), ahrs.getAngle());
        } catch( RuntimeException ex ) {
            DriverStation.reportError("Error communicating with chassis system:  " + ex.getMessage(), true);
        }
        Timer.delay(0.005);     // wait for a motor update time
    }
}
项目:turtleshell    文件:Robot.java   
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
            frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
      ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
项目:turtleshell    文件:Robot.java   
/**
 * Runs the motors with arcade steering.
 */

public void operatorControl() {
    myRobot.setSafetyEnabled(true);
    while (isOperatorControl() && isEnabled()) {

        boolean motionDetected = ahrs.isMoving();
        SmartDashboard.putBoolean("MotionDetected", motionDetected);

        try {
            myRobot.mecanumDrive_Cartesian(stick.getX(), stick.getY(), stick.getTwist(),0);
        } catch( RuntimeException ex ) {
            String err_string = "Drive system error:  " + ex.getMessage();
            DriverStation.reportError(err_string, true);
        }
        Timer.delay(0.005);     // wait for a motor update time
    }
}
项目:turtleshell    文件:Robot.java   
public Robot() {
    myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel, 
         frontRightChannel, rearRightChannel);
    myRobot.setExpiration(0.1);
    stick = new Joystick(0);
    try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
        ahrs = new AHRS(SPI.Port.kMXP); 
    } catch (RuntimeException ex ) {
        DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
    }
}
项目:turtleshell    文件:Robot.java   
public Robot() {
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP);
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:turtleshell    文件:Robot.java   
public Robot() {
     myRobot = new RobotDrive(0, 1);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:turtleshell    文件:Robot.java   
public Robot() {
     myRobot = new RobotDrive(frontLeftChannel, rearLeftChannel,
            frontRightChannel, rearRightChannel);
     myRobot.setExpiration(0.1);
     stick = new Joystick(0);
     try {
/***********************************************************************
 * navX-MXP:
 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
 * 
 * navX-Micro:
 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
 * 
 * Multiple navX-model devices on a single robot are supported.
 ************************************************************************/
         ahrs = new AHRS(SPI.Port.kMXP); 
     } catch (RuntimeException ex ) {
         DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
     }
 }
项目:turtleshell    文件:Robot.java   
/**
 * Runs the motors with arcade steering.
 */
public void operatorControl() {
    myRobot.setSafetyEnabled(true);
    while (isOperatorControl() && isEnabled()) {
        if ( stick.getRawButton(1)) {
            ahrs.reset();
        }
        try {
            /* Use the joystick X axis for lateral movement,            */
            /* Y axis for forward movement, and Z axis for rotation.    */
            /* Use navX MXP yaw angle to define Field-centric transform */
            myRobot.mecanumDrive_Cartesian(stick.getX(), stick.getY(), 
                                           stick.getTwist(), ahrs.getAngle());
        } catch( RuntimeException ex ) {
            DriverStation.reportError("Error communicating with drive system:  " + ex.getMessage(), true);
        }
        Timer.delay(0.005);     // wait for a motor update time
    }
}