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


Java Clock类代码示例

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


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

示例1: teleopInit

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Run when we first enable in teleop.
 */
@Override
public void teleopInit() {
    //Refresh the current time.
    Clock.updateTime();

    //Read sensors
    this.robotMap.getUpdater().run();

    //Run startup command if we start in teleop.
    if (!enabled) {
        if (robotMap.getStartupCommand() != null) {
            robotMap.getStartupCommand().start();
        }
        enabled = true;
    }

    //Run the teleop startup command
    if (robotMap.getTeleopStartupCommand() != null) {
        robotMap.getTeleopStartupCommand().start();
    }

    //Log
    loggerNotifier.startSingle(0);
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:28,代码来源:Robot.java

示例2: autonomousInit

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Run when we first enable in autonomous
 */
@Override
public void autonomousInit() {
    //Refresh the current time.
    Clock.updateTime();

    //Read sensors
    this.robotMap.getUpdater().run();

    //Run startup command if we start in auto.
    if (!enabled) {
        if (robotMap.getStartupCommand() != null) {
            robotMap.getStartupCommand().start();
        }
        enabled = true;
    }

    //Run the auto startup command
    if (robotMap.getAutoStartupCommand() != null) {
        robotMap.getAutoStartupCommand().start();
    }

    //Log
    loggerNotifier.startSingle(0);
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:28,代码来源:Robot.java

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

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

示例5: robotInit

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * The method that runs when the robot is turned on. Initializes all subsystems from the map.
 */
public void robotInit() {
	//Set up start time
	Clock.setStartTime();
	Clock.updateTime();

	enabled = false;

	//Yes this should be a print statement, it's useful to know that robotInit started.
	System.out.println("Started robotInit.");
	Yaml yaml = new Yaml();
	try {
		Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH+"ballbasaur_map.yml"));
		YAMLMapper mapper = new YAMLMapper();
		String fixed = mapper.writeValueAsString(normalized);
		mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
		robotMap = mapper.readValue(fixed, RobotMap.class);
	} catch (IOException e) {
		System.out.println("Config file is bad/nonexistent!");
		e.printStackTrace();
	}

	//Read sensors
	this.robotMap.getUpdater().run();

	this.loggerNotifier = new Notifier(robotMap.getLogger());
	this.driveSubsystem = robotMap.getDrive();

	//Run the logger to write all the events that happened during initialization to a file.
	robotMap.getLogger().run();
	Clock.updateTime();
}
 
开发者ID:PB020,项目名称:Ballbasaur-Code-Rewrite,代码行数:35,代码来源:Robot.java

示例6: teleopPeriodic

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Run every tick in teleop.
 */
@Override
public void teleopPeriodic() {
	//Refresh the current time.
	Clock.updateTime();
	//Read sensors
	this.robotMap.getUpdater().run();
	//Run all commands. This is a WPILib thing you don't really have to worry about.
	Scheduler.getInstance().run();
}
 
开发者ID:PB020,项目名称:Ballbasaur-Code-Rewrite,代码行数:13,代码来源:Robot.java

示例7: doStartupTasks

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
private void doStartupTasks() {
	//Refresh the current time.
	Clock.updateTime();

	//Start running the logger
	loggerNotifier.startPeriodic(robotMap.getLogger().getLoopTimeSecs());
	System.out.println("Started logger!");
}
 
开发者ID:PB020,项目名称:Ballbasaur-Code-Rewrite,代码行数:9,代码来源:Robot.java

示例8: teleopPeriodic

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Run every tick in teleop.
 */
@Override
public void teleopPeriodic() {
	//Refresh the current time.
	Clock.updateTime();

	//Read sensors
	this.robotMap.getUpdater().run();

	//Run all commands. This is a WPILib thing you don't really have to worry about.
	Scheduler.getInstance().run();
}
 
开发者ID:blair-robot-project,项目名称:robot2017,代码行数:15,代码来源:Robot.java

示例9: autonomousPeriodic

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Runs every tick in autonomous.
 */
@Override
public void autonomousPeriodic() {
	//Update the current time
	Clock.updateTime();
	//Read sensors
	this.robotMap.getUpdater().run();
	//Run all commands. This is a WPILib thing you don't really have to worry about.
	Scheduler.getInstance().run();
}
 
开发者ID:blair-robot-project,项目名称:robot2017,代码行数:13,代码来源:Robot.java

示例10: disabledPeriodic

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Run every tic while disabled
 */
@Override
public void disabledPeriodic() {
	Clock.updateTime();
	//Read sensors
	this.robotMap.getUpdater().run();
}
 
开发者ID:blair-robot-project,项目名称:robot2017,代码行数:10,代码来源:Robot.java

示例11: doStartupTasks

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * Do tasks that should be done when we first enable, in both auto and teleop.
 */
private void doStartupTasks() {
	//Refresh the current time.
	Clock.updateTime();

	//Start running the logger
	loggerNotifier.startPeriodic(robotMap.getLogger().getLoopTimeSecs());
}
 
开发者ID:blair-robot-project,项目名称:robot2017,代码行数:11,代码来源:Robot.java

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

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

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

示例15: robotInit

import org.usfirst.frc.team449.robot.other.Clock; //导入依赖的package包/类
/**
 * The method that runs when the robot is turned on. Initializes all subsystems from the map.
 */
public void robotInit() {
    //Set up start time
    Clock.setStartTime();
    Clock.updateTime();

    enabled = false;

    //Yes this should be a print statement, it's useful to know that robotInit started.
    System.out.println("Started robotInit.");

    Yaml yaml = new Yaml();
    try {
        //Read the yaml file with SnakeYaml so we can use anchors and merge syntax.
        Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + mapName));
        YAMLMapper mapper = new YAMLMapper();
        //Turn the Map read by SnakeYaml into a String so Jackson can read it.
        String fixed = mapper.writeValueAsString(normalized);
        //Use a parameter name module so we don't have to specify name for every field.
        mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
        //Add mix-ins
        mapper.registerModule(new WPIModule());
        //Deserialize the map into an object.
        robotMap = mapper.readValue(fixed, RobotMap.class);
    } catch (IOException e) {
        //This is either the map file not being in the file system OR it being improperly formatted.
        System.out.println("Config file is bad/nonexistent!");
        e.printStackTrace();
    }

    //Read sensors
    this.robotMap.getUpdater().run();

    //Set fields from the map.
    this.loggerNotifier = new Notifier(robotMap.getLogger());

    //Run the logger to write all the events that happened during initialization to a file.
    robotMap.getLogger().run();
    Clock.updateTime();
}
 
开发者ID:blair-robot-project,项目名称:449-central-repo,代码行数:43,代码来源:Robot.java


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