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


Java Clock.currentTimeMillis方法代码示例

本文整理汇总了Java中org.usfirst.frc.team449.robot.other.Clock.currentTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java Clock.currentTimeMillis方法的具体用法?Java Clock.currentTimeMillis怎么用?Java Clock.currentTimeMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.usfirst.frc.team449.robot.other.Clock的用法示例。


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

示例1: shouldDownshift

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Determine whether the robot should downshift.
 *
 * @param forwardThrottle The forwards throttle, on [-1, 1].
 * @param leftVel         The velocity of the left side of the drive.
 * @param rightVel        The velocity of the right side of the drive.
 * @return True if the drive should downshift, false otherwise.
 */
private boolean shouldDownshift(double forwardThrottle, double leftVel, double rightVel) {
    //We should shift if we're going slower than the downshift speed
    okayToDownshift = Math.max(Math.abs(leftVel), Math.abs(rightVel)) < downshiftSpeed;
    //Or if we're just turning in place.
    okayToDownshift = okayToDownshift || (forwardThrottle == 0);
    //Or commanding a low speed.
    okayToDownshift = okayToDownshift || (Math.abs(forwardThrottle) < upshiftFwdThresh);
    //But we can only shift if we're out of the cooldown period.
    okayToDownshift = okayToDownshift && Clock.currentTimeMillis() - timeLastUpshifted > cooldownAfterUpshift;

    if (downshiftDebouncer != null) {
        //We use a BufferTimer so we only shift if the conditions are met for a specific continuous interval.
        // This avoids brief blips causing shifting.
        okayToDownshift = downshiftDebouncer.get(okayToDownshift);
    }

    //Record the time if we do decide to shift.
    if (okayToDownshift) {
        timeLastDownshifted = Clock.currentTimeMillis();
    }
    return okayToDownshift;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:31,代码来源:AutoshiftComponent.java

示例2: shouldUpshift

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Determine whether the robot should upshift.
 *
 * @param forwardThrottle The forwards throttle, on [-1, 1].
 * @param leftVel         The velocity of the left side of the drive.
 * @param rightVel        The velocity of the right side of the drive.
 * @return True if the drive should upshift, false otherwise.
 */
private boolean shouldUpshift(double forwardThrottle, double leftVel, double rightVel) {
    //We should shift if we're going faster than the upshift speed...
    okayToUpshift = Math.min(Math.abs(leftVel), Math.abs(rightVel)) > upshiftSpeed;
    //AND the driver's trying to go forward fast.
    okayToUpshift = okayToUpshift && Math.abs(forwardThrottle) > upshiftFwdThresh;
    //But we can only shift if we're out of the cooldown period.
    okayToUpshift = okayToUpshift && Clock.currentTimeMillis() - timeLastDownshifted > cooldownAfterDownshift;

    if (upshiftDebouncer != null) {
        //We use a BufferTimer so we only shift if the conditions are met for a specific continuous interval.
        // This avoids brief blips causing shifting.
        okayToUpshift = upshiftDebouncer.get(okayToUpshift);
    }

    if (okayToUpshift) {
        timeLastUpshifted = Clock.currentTimeMillis();
    }
    return okayToUpshift;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:28,代码来源:AutoshiftComponent.java

示例3: updateMotionProfileStatus

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * A private utility method for updating motionProfileStatus with the current motion profile status. Makes sure that
 * the status is only gotten once per tic, to avoid CAN traffic overload.
 */
private void updateMotionProfileStatus() {
    if (timeMPStatusLastRead < Clock.currentTimeMillis()) {
        canTalon.getMotionProfileStatus(motionProfileStatus);
        timeMPStatusLastRead = Clock.currentTimeMillis();
    }
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:11,代码来源:FPSTalon.java

示例4: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Set up the start time and setpoint.
 */
@Override
protected void initialize() {
    //Setup start time
    this.startTime = Clock.currentTimeMillis();
    Logger.addEvent("NavXRelativeTurnToAngle init.", this.getClass());
    //Do math to setup the setpoint.
    this.setSetpoint(clipTo180(((SubsystemAHRS) subsystem).getHeadingCached() + setpoint));
    //Make sure to enable the controller!
    this.getPIDController().enable();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:14,代码来源:NavXTurnToAngleRelative.java

示例5: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Set up the start time and setpoint.
 */
@Override
protected void initialize() {
    //Set up start time
    this.startTime = Clock.currentTimeMillis();
    this.setSetpoint(setpoint);
    //Make sure to enable the controller!
    this.getPIDController().enable();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:12,代码来源:NavXTurnToAngle.java

示例6: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Record the start time.
 */
@Override
protected void initialize() {
    //Record the start time.
    startTime = Clock.currentTimeMillis();
    Logger.addEvent("RunLoadedProfile init", this.getClass());
    runningProfile = false;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:11,代码来源:RunLoadedProfile.java

示例7: isFinished

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Finish when the profile finishes or the timeout is reached.
 *
 * @return true if the profile is finished or the timeout has been exceeded, false otherwise.
 */
@Override
protected boolean isFinished() {
    if (Clock.currentTimeMillis() - startTime > timeout) {
        Logger.addEvent("Command timed out", this.getClass());
        System.out.println("RunLoadedProfile timed out!");
        return true;
    }
    return runningProfile && subsystem.profileFinished();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:15,代码来源:RunLoadedProfile.java

示例8: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Set up start time.
 */
@Override
protected void initialize() {
    //Set up start time
    startTime = Clock.currentTimeMillis();
    //Reset drive velocity (for safety reasons)
    subsystem.fullStop();
    Logger.addEvent("DriveAtSpeed init", this.getClass());
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:12,代码来源:DriveAtSpeed.java

示例9: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Reset the output
 */
@Override
protected void initialize() {
    Logger.addEvent("VoltageRamp init.", this.getClass());
    lastTime = Clock.currentTimeMillis();
    output = 0;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:10,代码来源:VoltageRamp.java

示例10: execute

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Update the output based on how long it's been since execute() was last run.
 */
@Override
protected void execute() {
    output += percentPerMillis * (Clock.currentTimeMillis() - lastTime);
    subsystem.setOutput(output, output);
    lastTime = Clock.currentTimeMillis();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:10,代码来源:VoltageRamp.java

示例11: run

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Read the NavX jerk data and rumble the joysticks based off of it.
 */
@Override
public void run() {
    if (yIsFrontBack) {
        //Put an abs() here because we can't differentiate front vs back when rumbling, so we only care about magnitude.
        frontBack = Math.abs(ahrs.getYAccel());
        leftRight = ahrs.getXAccel() * (invertLeftRight ? -1 : 1);
    } else {
        frontBack = Math.abs(ahrs.getYAccel());
        leftRight = ahrs.getXAccel() * (invertLeftRight ? -1 : 1);
    }

    //Left is negative jerk, so we subtract it from left so that when we're going left, left is bigger and vice versa
    left = ((frontBack - lastFrontBackAccel) - (leftRight - lastLeftRightAccel)) / (Clock.currentTimeMillis() - timeLastCalled);
    right = ((frontBack - lastFrontBackAccel) + (leftRight - lastLeftRightAccel)) / (Clock.currentTimeMillis() - timeLastCalled);

    if (left > minJerk) {
        left = (left - minJerk) / maxJerk;
    } else {
        left = 0;
    }

    if (right > minJerk) {
        right = (right - minJerk) / maxJerk;
    } else {
        right = 0;
    }

    for (Rumbleable rumbleable : rumbleables) {
        rumbleable.rumble(left, right);
    }

    lastLeftRightAccel = leftRight;
    lastFrontBackAccel = frontBack;
    timeLastCalled = Clock.currentTimeMillis();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:39,代码来源:AHRSRumbleComponent.java

示例12: isFinished

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Exit when the robot reaches the setpoint or enough time has passed.
 *
 * @return True if timeout seconds have passed or the robot is on target, false otherwise.
 */
@Override
protected boolean isFinished() {
    //The PIDController onTarget() is crap and sometimes never returns true because of floating point errors, so we need a timeout
    return this.getPIDController().onTarget() || Clock.currentTimeMillis() - startTime > timeout;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:11,代码来源:NavXTurnToAngle.java

示例13: initialize

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Store the start time.
 */
@Override
protected void initialize() {
    startTime = Clock.currentTimeMillis();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:8,代码来源:WaitForMillis.java

示例14: isFinished

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Finish if the specified amount of time has passed.
 *
 * @return true if the specified number of milliseconds have passed since this command started, false otherwise.
 */
@Override
protected boolean isFinished() {
    return Clock.currentTimeMillis() - startTime >= timeout;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:10,代码来源:WaitForMillis.java

示例15: isFinished

import org.usfirst.frc.team449.robot.other.Clock; //导入方法依赖的package包/类
/**
 * Exit after the command's been running for long enough
 *
 * @return True if timeout has been reached, false otherwise
 */
@Override
protected boolean isFinished() {
    return (Clock.currentTimeMillis() - startTime) * 1e-3 > seconds;
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:10,代码来源:DriveAtSpeed.java


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