当前位置: 首页>>代码示例>>Java>>正文


Java Timer类代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.Timer的典型用法代码示例。如果您正苦于以下问题:Java Timer类的具体用法?Java Timer怎么用?Java Timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Timer类属于edu.wpi.first.wpilibj包,在下文中一共展示了Timer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGyro

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
/**
 * Initialize the gyro. Calibration is handled by calibrate().
 */
public void initGyro() {
  result = new AccumulatorResult();

  m_voltsPerDegreePerSecond = kDefaultVoltsPerDegreePerSecond;
  m_analog.setAverageBits(kAverageBits);
  m_analog.setOversampleBits(kOversampleBits);
  double sampleRate = kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
  AnalogInput.setGlobalSampleRate(sampleRate);
  Timer.delay(0.1);

  setDeadband(0.0);

  setPIDSourceType(PIDSourceType.kDisplacement);

  UsageReporting.report(tResourceType.kResourceType_Gyro, m_analog.getChannel());
  LiveWindow.addSensor("AnalogGyro", m_analog.getChannel(), this);
}
 
开发者ID:FRC4131,项目名称:FRCStronghold2016,代码行数:21,代码来源:CustomGyro.java

示例2: calibrate

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void calibrate() {
  if (m_spi == null) return;

  Timer.delay(0.1);

  synchronized (this) {
    m_accum_count = 0;
    m_accum_gyro_x = 0.0;
    m_accum_gyro_y = 0.0;
    m_accum_gyro_z = 0.0;
  }

  Timer.delay(kCalibrationSampleTime);

  synchronized (this) {
    m_gyro_offset_x = m_accum_gyro_x / m_accum_count;
    m_gyro_offset_y = m_accum_gyro_y / m_accum_count;
    m_gyro_offset_z = m_accum_gyro_z / m_accum_count;
  }
}
 
开发者ID:2141-Spartonics,项目名称:Spartonics-Code,代码行数:25,代码来源:ADIS16448_IMU.java

示例3: isFinished

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
protected boolean isFinished() {
    double wheelSpeedR;
    double wheelSpeedL;
    double elapsedTime;
    wheelSpeedL = RobotMap.driveTrainLeftFront.getSpeed();
    wheelSpeedR = RobotMap.driveTrainRightFront.getSpeed();
    elapsedTime = Timer.getFPGATimestamp() - startTime;
    if (elapsedTime > 1 && (wheelSpeedL <= .001 && wheelSpeedR <= .001))
    {
    	//System.out.println("VISION stop by Speed");
    	return true;
    }
    else if  (elapsedTime > endTime)
    {
    	//System.out.println("VISION Stop by timeout");
    	return true;
    }
    return false;
	//return (elapsedTime > 1 && (wheelSpeedL <= .001 && wheelSpeedR <= .001)) || (elapsedTime > endTime); //|| (NavX.ahrs.getWorldLinearAccelY() < -1); //-0.8);
    
}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:22,代码来源:VisionAimGear.java

示例4: initialize

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
protected void initialize() {
  	RobotMap.driveTrainRightFront.setPosition(0);
  	RobotMap.driveTrainLeftFront.setPosition(0);
RobotMap.driveTrainLeftFront.setEncPosition(0);
RobotMap.driveTrainRightFront.setEncPosition(0);
  	startTime = Timer.getFPGATimestamp();
  	maxAccel = 0;
  	minAccel = 0;
  	dispCount = 0;
  	//initRightEnc = DriveEncoders.getRawRightValue();
  	//initLeftEnc = DriveEncoders.getRawLeftValue();
  	//prevTime = System.currentTimeMillis();
  	//prevRightError = 0;
  	//prevLeftError = 0;
  	//SmartDashboard.putString("Auton Debugging", "DriveForwardInit");
  	}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:17,代码来源:DriveForward.java

示例5: perform

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
@Override
public void perform() {
  terminal.writer().println();
  terminal.writer().println(Messages.bold(NAME));
  terminal.writer().println();
  DigitalOutput digitalOutput = dioSet.getDigitalOutput();
  if (digitalOutput == null) {
    terminal.writer().println(Messages.boldRed("no digital output selected"));
    return;
  }
  digitalOutput.disablePWM();
  digitalOutput.enablePWM(0.25);
  Timer.delay(SLEEP_SEC);
  digitalOutput.updateDutyCycle(0.5);
  Timer.delay(SLEEP_SEC);
  digitalOutput.updateDutyCycle(0.75);
  Timer.delay(SLEEP_SEC);
  digitalOutput.updateDutyCycle(1.0);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:20,代码来源:DemoPwmDigitalOutputCommand.java

示例6: run

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
public void run()
{
	double lastWriteTime = Timer.getFPGATimestamp();
	while (true)
	{
		try
		{
			String msg = logMessages.take();
			writer.write(msg);
			if (Timer.getFPGATimestamp() >= lastWriteTime + WRITE_TIME)
			{
				writer.flush();
				lastWriteTime = Timer.getFPGATimestamp();
			}
		}
		catch (InterruptedException | IOException e)
		{
			((Throwable) e).printStackTrace();
		}
	}
}
 
开发者ID:BytingBulldogs3539,项目名称:BBLIB,代码行数:22,代码来源:Logger.java

示例7: runCrashTracked

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
@Override
public void runCrashTracked() {
	synchronized (mTaskRunningLock) {
		if (mRunning) {
			double now = Timer.getFPGATimestamp();
			Commands commands = Robot.getCommands();
			RobotState robotState = Robot.getRobotState();
			for (SubsystemLoop loop : mLoops) {
				loop.update(commands, robotState);
				Logger.getInstance().logSubsystemThread(loop.getStatus());
			}
			mDt = now - mTimeStamp;
			mTimeStamp = now;
		}
	}
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:17,代码来源:SubsystemLooper.java

示例8: start

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
public synchronized void start() {
	if (!mRunning) {
		System.out.println("Starting loops");
		synchronized (mTaskRunningLock) {
			mTimeStamp = Timer.getFPGATimestamp();
			for (SubsystemLoop loop : mLoops) {
				System.out.println("Starting " + loop.toString());
				loop.start();
			}
			mRunning = true;
		}
		mNotifier.startPeriodic(kPeriod);
	} else {
		System.out.println("SubsystemLooper already running");
	}
	if (!mPrinting) {
		System.out.println("Starting subsystem printer");
		mPrintTimeStamp = Timer.getFPGATimestamp();
		mPrinting = true;
		mPrintNotifier.startPeriodic(kPrintRate);
	}
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:23,代码来源:SubsystemLooper.java

示例9: updateValues

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
public static void updateValues() {
      
  	if (!initialized)
  		return;
  	
  	// Default data if network table data pull fails
double defaultDoubleVal = 0.0;

// Pull data from grip
numTargets = table.getNumber("targets", defaultDoubleVal);
targetX = table.getNumber("targetX", defaultDoubleVal);
targetY = table.getNumber("targetY", defaultDoubleVal);
targetArea = table.getNumber("targetArea",defaultDoubleVal);
targetDistance = table.getNumber("targetDistance",defaultDoubleVal);

Timer.delay(0.02);
  }
 
开发者ID:MTHSRoboticsClub,项目名称:FRC-2017,代码行数:18,代码来源:RPIComm.java

示例10: run

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
@Override
public void run() {
	double current = 0;
	final double filter = 0.1666667;
	final double max = 30; // 30 Amps should not be violated in most cases
	
	boolean isDisabled = false;
	
	while (!Thread.currentThread().isInterrupted()) {
		// Rolling Avg.
		current = filter * getOutputCurrent() + current * (1 - filter);
		if (current > max * 0.9 && !isDisabled) {
			disableControl();
			isDisabled = true;
		}else if (current < max * 0.80 && isDisabled){
			enableControl();
			isDisabled = false;
		}
		Timer.delay(0.1);
	}
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:22,代码来源:CANTalonCurrentSafety.java

示例11: Init

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
public void Init()
{
    Logger.PrintLine("Init 1",Logger.LOGGER_MESSAGE_LEVEL_DEBUG);
    
    m_pidController = new PIDController(10,10,10,m_encoderAverager,m_robotDrivePid);
    m_pidController.setOutputRange(-0.8,0.8);
    //m_pidController.setOutputRange(-0.4,0.4);
    Logger.PrintLine("Init 4",Logger.LOGGER_MESSAGE_LEVEL_ERROR);

    m_currentStateIndex = 0;
    SetCurrentState(m_nextStateArray[m_currentStateIndex]);
    m_disabled = false;
    
    m_shootingBall = false;
    m_driving = false;
    m_braking = false;
    m_detectingImage = false;
    m_currentStateIndex = 0;
    m_loadingBall = false;
    m_shooterPullingBack = false;
    
    m_autonomousStartTime = Timer.getFPGATimestamp();
    
    m_robotDrivePid.resetGyro();
}
 
开发者ID:Dinoyan,项目名称:FRC-2014-robot-project,代码行数:26,代码来源:AutonomousModeHandler.java

示例12: HandleStateRelease

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
private void HandleStateRelease()
{
    if (!m_gearReleased)
    {
        // set the gear in neutral
        m_gearControl.set(DoubleSolenoid.Value.kForward);
        m_gearReleased = true;
    }
    
    if(!m_latchReleased)
    {
        //release the latch
        m_latchReleaseServo.set(1);
        Timer.delay(0.5);
        m_latchReleased = true;
    }
   
    m_isPulledBack = false;
    m_currentState = SHOOTER_CONTROL_STATE_WAIT;
}
 
开发者ID:Dinoyan,项目名称:FRC-2014-robot-project,代码行数:21,代码来源:ShooterControl.java

示例13: calibrate

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void calibrate() {
  if (m_spi == null) return;

  Timer.delay(0.1);

  synchronized (this) {
    m_accum_count = 0;
    m_accum_gyro_x = 0.0;
    m_accum_gyro_y = 0.0;
    m_accum_gyro_z = 0.0;
  }

  Timer.delay(kCalibrationSampleTime);

  synchronized (this) {
    m_gyro_center_x = m_accum_gyro_x / m_accum_count;
    m_gyro_center_y = m_accum_gyro_y / m_accum_count;
    m_gyro_center_z = m_accum_gyro_z / m_accum_count;
  }
}
 
开发者ID:mtmustski,项目名称:FRC-Robotics-2016-Team-2262,代码行数:25,代码来源:ADIS16448_IMU.java

示例14: reset

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
public static void reset()
{
	System.out.println("NavXSensor::reset called!");
	
	if (ahrs != null) 
	{
		ahrs.reset();
		ahrs.resetDisplacement();
		ahrs.zeroYaw();
		
		// allow zeroing to take effect
		Timer.delay(0.1);
		
		// get the absolute angle after reset - Not sure why it is non-zero, but we need to record it to zero it out
		yawOffset = ahrs.getAngle();	
		System.out.println("yawOffset read = " + yawOffset);
	}
}
 
开发者ID:MTHSRoboticsClub,项目名称:FRC-2017,代码行数:19,代码来源:NavXSensor.java

示例15: execute

import edu.wpi.first.wpilibj.Timer; //导入依赖的package包/类
protected void execute() {
		//check to see limit switch 
//		if(direction.equals("in") && Robot.intakeRollerSubsystem.getOverride())
//			Robot.intakeRollerSubsystem.intake();
//		else if(direction.equals("in") && RobotMap.shooterEncoder.getRate() > 0)
//			Robot.intakeRollerSubsystem.intake();
//		else if (direction.equals("in") && buttonsNotPressed())
//			Robot.intakeRollerSubsystem.intake();
		if(direction.equals("in"))
			Robot.intakeRollerSubsystem.intake();
		else if(direction.equalsIgnoreCase("out"))
			Robot.intakeRollerSubsystem.outake();
		else if(direction.equalsIgnoreCase("auton")){
			Robot.intakeRollerSubsystem.outake();
			Timer.delay(1);
		}
		else
			Robot.intakeRollerSubsystem.neutral();
	}
 
开发者ID:Team1923,项目名称:Stronghold_2016,代码行数:20,代码来源:IntakeRollerCommand.java


注:本文中的edu.wpi.first.wpilibj.Timer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。