本文整理汇总了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);
}
示例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;
}
}
示例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);
}
示例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");
}
示例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);
}
示例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();
}
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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();
}