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


Java Timer.delay方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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:RobotCasserole1736,项目名称:CasseroleLib,代码行数:25,代码来源:ADIS16448_IMU.java

示例6: display

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
public void display() {
	NIVision.IMAQdxStartAcquisition(session);

    /**
     * grab an image, draw the circle, and provide it for the camera server
     * which will in turn send it to the dashboard.
     */
    NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);

    //while (teleop && enabled) {
    while(enabled) {
        NIVision.IMAQdxGrab(session, frame, 1);
        NIVision.imaqDrawShapeOnImage(frame, frame, rect,
                DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
        
        CameraServer.getInstance().setImage(frame);

        /** robot code here! **/
        Timer.delay(0.005);		// wait for a motor update time
    }
    NIVision.IMAQdxStopAcquisition(session);
}
 
开发者ID:FRC-Team-3140,项目名称:FRC-2016,代码行数:23,代码来源:DriveCam.java

示例7: 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

示例8: operatorControl

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
public void operatorControl() {
    NIVision.IMAQdxStartAcquisition(session);

    /**
     * grab an image, draw the circle, and provide it for the camera server
     * which will in turn send it to the dashboard.
     */
    NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);

    while (isOperatorControl() && isEnabled()) {

        NIVision.IMAQdxGrab(session, frame, 1);
        NIVision.imaqDrawShapeOnImage(frame, frame, rect,
                DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
        
        CameraServer.getInstance().setImage(frame);

        /** robot code here! **/
        Timer.delay(0.005);		// wait for a motor update time
    }
    NIVision.IMAQdxStopAcquisition(session);
}
 
开发者ID:wjaneal,项目名称:liastem,代码行数:23,代码来源:Robot.java

示例9: autonomous

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的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 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
 * if-else structure below with additional strings. If using the
 * SendableChooser make sure to add them to the chooser code above as well.
 */
@Override
public void autonomous() {
	String autoSelected = chooser.getSelected();
	// String autoSelected = SmartDashboard.getString("Auto Selector",
	// defaultAuto);
	System.out.println("Auto selected: " + autoSelected);

	switch (autoSelected) {
	case customAuto:
		myRobot.setSafetyEnabled(false);
		myRobot.drive(-0.5, 1.0); // spin at half speed
		Timer.delay(2.0); // for 2 seconds
		myRobot.drive(0.0, 0.0); // stop robot
		break;
	case defaultAuto:
	default:
		myRobot.setSafetyEnabled(false);
		myRobot.drive(-0.5, 0.0); // drive forwards half speed
		Timer.delay(2.0); // for 2 seconds
		myRobot.drive(0.0, 0.0); // stop robot
		break;
	}
}
 
开发者ID:wjaneal,项目名称:liastem,代码行数:35,代码来源:Robot.java

示例10: intializeEncoders

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
public static void intializeEncoders()
{
	RobotMap.driveTrainLeftFront.setEncPosition(0);
	RobotMap.driveTrainRightFront.setEncPosition(0);
	RobotMap.driveTrainRightFront.setPosition(0);
   	RobotMap.driveTrainLeftFront.setPosition(0);
   	System.out.println("OLD - RF: " + RobotMap.driveTrainRightFront.getEncPosition() + " LF:" + RobotMap.driveTrainLeftFront.getEncPosition());
   	Timer.delay(0.04);
   	System.out.println("NEW: RF: " + RobotMap.driveTrainRightFront.getEncPosition() + " LF:" + RobotMap.driveTrainLeftFront.getEncPosition());
}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:11,代码来源:DriveEncoders.java

示例11: autonomous

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
public void autonomous() {
	String choose = chooser.getSelected();
	Skylar.setSafetyEnabled(false);
	OptimusPrime.setSafetyEnabled(false);
	switch (choose) {
	case pos1:

	case pos2:
		while (isAutonomous() && isEnabled()) {
			timer = System.currentTimeMillis();
			while (System.currentTimeMillis() - timer <= 3000) {
				adjustedDrive(0.5, 0.5);
			}
			smashDrive(0, 0);
			getSensorData();
			gearBox.set(Value.kReverse);
			Timer.delay(2);
			timer = System.currentTimeMillis();
			while (System.currentTimeMillis() - timer <= 1000) {
				adjustedDrive(-0.5, -0.5);
			}
			smashDrive(0, 0);
			getSensorData();
			gearBox.set(Value.kForward);
			break;
		}
	case pos3:
	}
}
 
开发者ID:TeamAutomatons,项目名称:Steamwork_2017,代码行数:30,代码来源:Robot.java

示例12: operatorControl

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
public void operatorControl() {

		Skylar.setSafetyEnabled(true);
		OptimusPrime.setSafetyEnabled(true);

		while (isOperatorControl() && isEnabled()) {
			climb(); // a to climb, b to release
			slowMode();// x to enter, y to quit // slowMode
			gearBox(); // left bumper to open, right bumper to close
			drive();
			getSensorData();
			Timer.delay(0.001);
		}
	}
 
开发者ID:TeamAutomatons,项目名称:Steamwork_2017,代码行数:15,代码来源:Robot.java

示例13: calibrate

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
/**
 * This is a blocking calibration call. There are also non-blocking options
 * available in this class!
 * 
 * {@inheritDoc}
 */
@Override
public synchronized void calibrate() {
    Timer.delay(0.1);
    startCalibrate();
    System.out.println("Start gyro calibration, waiting");
    Timer.delay(kCalibrationSampleTime);
    System.out.println("Gyro calibrated");
    endCalibrate();
}
 
开发者ID:team8,项目名称:FRC-2017-Public,代码行数:16,代码来源:ADXRS453_Gyro.java

示例14: operatorControl

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
/**
 * Runs the motors with arcade steering.
 */
@Override
public void operatorControl() {
	myRobot.setSafetyEnabled(true);
	while (isOperatorControl() && isEnabled()) {
		myRobot.arcadeDrive(stick); // drive with arcade style (use right
									// stick)
		Timer.delay(0.005); // wait for a motor update time
	}
}
 
开发者ID:wjaneal,项目名称:liastem,代码行数:13,代码来源:Robot.java

示例15: capture

import edu.wpi.first.wpilibj.Timer; //导入方法依赖的package包/类
protected void capture() {
  Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
  while (true) {
    boolean hwClient;
    ByteBuffer dataBuffer = null;
    synchronized (this) {
      hwClient = m_hwClient;
      if (hwClient) {
        dataBuffer = m_imageDataPool.removeLast();
      }
    }

    try {
      if (hwClient && dataBuffer != null) {
        // Reset the image buffer limit
        dataBuffer.limit(dataBuffer.capacity() - 1);
        m_camera.getImageData(dataBuffer);
        setImageData(new RawData(dataBuffer), 0);
      } else {
        m_camera.getImage(frame);
        setImage(frame);
      }
    } catch (VisionException ex) {
      DriverStation.reportError("Error when getting image from the camera: " + ex.getMessage(),
          true);
      if (dataBuffer != null) {
        synchronized (this) {
          m_imageDataPool.addLast(dataBuffer);
          Timer.delay(.1);
        }
      }
    }
  }
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:35,代码来源:CameraServers.java


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