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


C++ Timer::Get方法代码示例

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


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

示例1: AcceptableToPrime

	bool AcceptableToPrime()
	{
		if (shootertime.Get() > 5 && shottime.Get() > primewaittime)
			return true;
		else
			return false;
	}
开发者ID:Team537,项目名称:RobotCode,代码行数:7,代码来源:MyRobot.cpp

示例2: grabberPositionTaskFunc

inline void grabberPositionTaskFunc(uint32_t joystickPtr, uint32_t grabTalonPtr, uint32_t grabInnerLimitPtr, uint32_t pdpPtr, uint32_t backOutPtr, uint32_t grabPowerPtr, uint32_t isGrabbingPtr...) {//uint is a pointer and not an integer
	Joystick *joystick = (Joystick *) joystickPtr;//initializes objects from pointers
	Talon *grabTalon = (Talon *) grabTalonPtr;
	Switch *grabInnerLimit = (Switch *) grabInnerLimitPtr;
	PowerDistributionPanel *pdp = (PowerDistributionPanel *) pdpPtr;
	bool *isGrabbing = (bool *) isGrabbingPtr;
	bool *backOut = (bool *) backOutPtr;
	double *grabPower = (double *) grabPowerPtr;
	Timer timer;
	timer.Start();

	*isGrabbing = true;//tells robot.cpp that thread is running

	while (grabInnerLimit->Get() && timer.Get() < Constants::grabDelay) {//starts to spin motor to pass startup current
		grabTalon->Set(1);//move in
	}

	while (pdp->GetCurrent(Constants::grabPdpChannel) < *grabPower && grabInnerLimit->Get() && joystick->GetRawButton(Constants::pickupCancelButton) == false) {//while it hasn't reached the current cutoff, hit a limit switch, or been cancelled
		grabTalon->Set(1);
		SmartDashboard::PutNumber("Current",pdp->GetCurrent(Constants::grabPdpChannel));//displays current on SmartDashboard
	}

	if (*backOut) {
		grabTalon->Set(0);//stop moving
		timer.Reset();
		while (timer.Get() < Constants::liftBackoutTime && joystick->GetRawButton(Constants::pickupCancelButton) == false) {
			grabTalon->Set(-.75);
		}
	}

	grabTalon->Set(0);//stop moving
	timer.Stop();
	*isGrabbing = false;//tells that thread is over
}
开发者ID:Numeri,项目名称:RecycleRush,代码行数:34,代码来源:Pickup.cpp

示例3: AutonomousStateMachine

	void AutonomousStateMachine() {
		pneumaticsControl->initialize();
		shooterControl->initializeAuto();
		driveControl.initializeAuto();
		enum AutoState {
			AutoDrive, AutoSetup, AutoShoot
		};
		AutoState autoState;
		autoState = AutoDrive;

		bool feederState = false;
		bool hasFired = false;
		Timer feeder;

		while (IsAutonomous() && IsEnabled()) {
			GetWatchdog().Feed();
			switch (autoState) {//Start of Case Machine
			case AutoDrive://Drives the robot to set Destination 
				bool atDestination = driveControl.autoPIDDrive2();
				if (atDestination) {//If at Destination, Transition to Shooting Setup
					autoState = AutoSetup;
				}
				break;
			case AutoSetup://Starts the ballgrabber motors to place the ball and extends ballgrabber
				if (!pneumaticsControl->ballGrabberIsExtended()) {//extends ballgrabber if not already extended
					pneumaticsControl->ballGrabberExtend();
				}

				if (!feederState) {//Started the feeder timer once
					feederState = true;
					feeder.Start();
					autoState = AutoShoot;
				}

				break;
			case AutoShoot://Shoots the ball
				if (feeder.Get() < 2.0) {//Runs ballgrabber for 2.0 Seconds at most
					shooterControl->feed(true);
				} else if (feeder.Get() >= 2.0) {//Transition to Shooting
					shooterControl->feed(false);
					feeder.Stop();
				}
				
				if (pneumaticsControl->ballGrabberIsExtended() && !hasFired) {
					shooterControl->autoShoot();
					dsLCD->PrintfLine(DriverStationLCD::kUser_Line1,
							"The robot is(should be) shooting");
					if (shooterControl->doneAutoFire()) {//Returns true only after shoot is done firing
						hasFired = true;
					}
				} else if (hasFired) {//runs only after shoot is done
					dsLCD->PrintfLine(DriverStationLCD::kUser_Line1,
							"AutoMode Finished");
				}
				break;
			}
			dsLCD->UpdateLCD();

		}
	}
开发者ID:2202Programming,项目名称:OldCode,代码行数:60,代码来源:Hohenheim.cpp

示例4:

TEST(TimeUtils, TimerPositive) {
  Timer t;
  t.Start();
  for (int i = 0; i < 10000; i++) {
    t.Get();
  }
  ASSERT_GT(t.Get(), 0 * s);
}
开发者ID:frc1678,项目名称:muan-public,代码行数:8,代码来源:utils_test.cpp

示例5: intelligent_shooter

void RobotDemo::intelligent_shooter()
{
	RPS_control_code(37.5);

	switch (smart_autonomous_state)
	{
	case unstable:
		cout << "State Unstable" << endl;
		printf("%i %i", fabs(error_back) < 4, fabs(error_front) < 4);
		if (fabs(error_back) < 4 || fabs(error_front) < 4)
		{
			smart_autonomous_state = stabilizing;
			stabilizing_timer->Reset();
		}
		if (override_timer->Get() > 4)
		{
			smart_autonomous_state = fire;
		}

		break;
	case stabilizing:
		cout << "State Stabilizing   " << endl;
		if (stabilizing_timer->Get() > 1 || override_timer->Get() > 4)
		{
			smart_autonomous_state = fire;
		}
		if (fabs(error_back) > 4 || fabs(error_front) > 4)
		{
			smart_autonomous_state = unstable;
		}
		break;

	case fire:
		cout << "State Firing   " << endl;
		shooter_fire_piston_A ->Set(false);//piston -->
		shooter_fire_piston_B ->Set(true);
		smart_autonomous_state = retracting;
		retraction_timer->Reset();
		break;
	case retracting:
		cout << "State Retracting   " << endl;
		if (retraction_timer->Get() > 1)
		{
			smart_autonomous_state = retract;
			break;
		}
		break;
	case retract:
		cout << "State Has Retracted   " << endl;
		shooter_fire_piston_A ->Set(true);//piston <--
		shooter_fire_piston_B ->Set(false);
		smart_autonomous_state = unstable;
		override_timer->Reset();
		break;
	}
	printf("%i\n", smart_autonomous_state);
}
开发者ID:2643,项目名称:2013-Code,代码行数:57,代码来源:final-2013botcode_03-18-13.cpp

示例6: AutonomousGyroTurn

	void AutonomousGyroTurn() {
		switch (currentState) {
		case 1:

			timer->Reset();
			timer->Start();
			//State: Stopped
			//Transition: Driving State
			currentState = 2;
			break;
		case 2:
			//State: Driving
			//Stay in State until 2 seconds have passed--`
			//Transition: Gyroturn State
			drive->TankDrive(0.5, 0.5);
			if (timer->Get() >= 1) {
				drive->TankDrive(0.0, 0.0);
				ahrs->ZeroYaw();
				currentState = 3;
				turnController->SetSetpoint(90);
				turnController->Enable();
			}
			break;
		case 3:
			//State: Gyroturn
			//Stay in state until navx yaw has reached 90 degrees
			//Transition: Driving State
			drive->TankDrive(0.5 * rotateRate, -0.5 * rotateRate);
//			if (ahrs->GetYaw() >= 90) {
			if (turnController->OnTarget()) {
				drive->TankDrive(0.0, 0.0);
				currentState = 4;
				timer->Reset();
				timer->Start();
			}
			break;
		case 4:
			//State:Driving
			//Stay in state until 2 seconds have passed
			//Transition: State Stopped
			drive->TankDrive(0.5, 0.5);
			if (timer->Get() >= 1) {
				currentState = 5;
				timer->Stop();
			}
			break;
		case 5:
			//State: Stopped
			drive->TankDrive(0.0, 0.0);
			break;

		}

	}
开发者ID:RoboLoCo-5338,项目名称:BasicDrive,代码行数:54,代码来源:Robot.cpp

示例7: DriveThenShootAuto

	void DriveThenShootAuto() {
		//initizlizes all parts of robot
		pneumaticsControl->initialize();
		shooterControl->initializeAuto();
		driveControl.initializeAuto();
		bool destinationPrevious = false;
		bool autoShot = false; //true if autoShoot

		//creates a timer for the ball grabber motors
		Timer feeding;
		bool started = false;
		while (IsAutonomous() && IsEnabled()) {
			//GetWatchdog().Feed();
			//drives forward to shooting point
			bool atDestination = destinationPrevious || driveControl.autoPIDDrive2(); //autoDrive returns true when robot reached it's goal
			if (atDestination) {
				// The robot has reached the destination on the floor and is now ready to open and shoot
				if (!started) {
					started = true;
					destinationPrevious = true;
					//starts feeding-timer controls feeder motors so the ball doesn't get stuck
					feeding.Start();
				}

				pneumaticsControl->ballGrabberExtend();
				//waits for feeding to be done
				if (feeding.Get() < 2.0) {//3.0 was 
					shooterControl->feed(true);
				} else if (feeding.Get() >= 2.0) { // 3.0 was 
					shooterControl->feed(false);
					feeding.Stop();
				}

				if (pneumaticsControl->ballGrabberIsExtended() && !autoShot) {
					shooterControl->autoShoot();
					//TODO dsLCD->PrintfLine(DriverStationLCD::kUser_Line1,
							//"The robot is(should be) shooting");
					if (shooterControl->doneAutoFire()) {//works only after shoot is done firing
						autoShot = true;
					}
				} else if (autoShot) {//runs only after shoot is done
					//tODO dsLCD->PrintfLine(DriverStationLCD::kUser_Line1,
							//"AutoMode Finished");
				}

			}
			//TODO dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Feeder Time: %f",
					//feeding.Get());
			//TODO dsLCD->UpdateLCD();
		}

	}
开发者ID:2202Programming,项目名称:Hoenheim-Reborn,代码行数:52,代码来源:Hohenheim.cpp

示例8: AutonomousPeriodic

	void AutonomousPeriodic()
	{
		Scheduler::GetInstance()->Run(); // Was in default code don't know what it does

		if (autoTimer.Get() > 0.0 ) { // If timer is greater then zero
			if (autoTimer.Get() < 1.5 ) { // If the timer is less then 2.5
				myDrive_all->TankDrive(0.8,0.8); // Make all motors go backwards
			} else {// If the timer is greater then 2.5
				myDrive_all->TankDrive(0.0,0.0); // Make all motors stop
			}
		} else { // If the timer is less then zero
			autoTimer.Start(); // Starts timer
		}
	}
开发者ID:Crowbotics5934,项目名称:2016-Stronghold-Robot,代码行数:14,代码来源:Robot.cpp

示例9: vision_entry

int vision::vision_entry() {
	AxisCamera* camera=&(AxisCamera::GetInstance("10.6.12.11"));
	while(true) {
		Timer timer;
		timer.Start();
		std::printf("==== BEGIN VISION ITERATION ====\n");
		ColorImage* image=camera->GetImage();
		BinaryImage* binImage=image->ThresholdHSL(100,120,200,255,5,140);
		BinaryImage* convexImage=binImage->ConvexHull(false);
		ParticleFilterCriteria2 criteria[]={{IMAQ_MT_AREA,500,65535,false,false}};
		BinaryImage* filteredImage=binImage->ParticleFilter(criteria,1);
		int numParticles=filteredImage->GetNumberParticles();
		std::printf("Number of particles: %d\n",numParticles);
		for(int i=0;i<numParticles;i++) {
			ParticleAnalysisReport report=filteredImage->GetParticleAnalysisReport(i);
			std::printf("Area for particle %d: %f\n",i,report.particleArea);
		}
		delete image;
		delete binImage;
		delete convexImage;
		delete filteredImage;
		double timeElapsed=timer.Get();
		std::printf("---- TIME TAKEN: %f ----\n",timeElapsed);
	}
}
开发者ID:JeffTolbert,项目名称:612-2013,代码行数:25,代码来源:vision.cpp

示例10: GetRate

	double GetRate() {
		int dist = Get();
		double rate = (double)(dist - lastDistance) / timer.Get();
		lastDistance = dist;
		timer.Reset();
		return rate;
	}
开发者ID:Dagwaging,项目名称:metrobots,代码行数:7,代码来源:MyRobot.cpp

示例11: timeExpired

	bool timeExpired()
	{
		if((arm->Get())>waitTill)
			return true;
		else
			return false;
	}
开发者ID:The-Charge,项目名称:2011_TubeBot,代码行数:7,代码来源:TubeBot.cpp

示例12: pneumatic_feeder_code

void RobotDemo::pneumatic_feeder_code()
{
	if (operator_stick ->GetRawButton(shooter_piston_button)) //Button 1                                
	{
		if (kicker_button_on == false)
		{
			shooter_reset ->Reset();
			kicker_button_on = true;
			//kicker_piston_on = false;
			shooter_piston_timer->Start();

			shooter_fire_piston_A ->Set(false);//pushes
			shooter_fire_piston_B ->Set(true);

			cout << "out" << endl;
		}
	}
	else
	{
		kicker_button_on = false;
	}
	if (shooter_piston_timer->Get() >= shooter_piston_delay)
	{
		shooter_fire_piston_A ->Set(true);//retracts
		shooter_fire_piston_B ->Set(false);

		shooter_piston_timer ->Reset();
		shooter_piston_timer ->Stop();

		cout << "back" << endl;
	}
}
开发者ID:2643,项目名称:2013-Code,代码行数:32,代码来源:final-2013botcode_03-18-13.cpp

示例13: AcceptableToFire

	bool AcceptableToFire()
	{
		if (shottime.Get() > shootwaittime)
			return true;
		else
			return false;
	}
开发者ID:Team537,项目名称:RobotCode,代码行数:7,代码来源:MyRobot.cpp

示例14: Main

/**
 * @brief Main thread function for Proxy166.
 * Runs forever, until MyTaskInitialized is false. 
 * 
 * @todo Update DS switch array
 */
int Proxy::Main(	int a2, int a3, int a4, int a5,
					int a6, int a7, int a8, int a9, int a10) {
	
	Robot *lHandle = NULL;
	WaitForGoAhead();
	
	lHandle = Robot::getInstance();
	Timer matchTimer;
	
	while(MyTaskInitialized) {
		setNewpress();
		if(lHandle->IsOperatorControl() && lHandle->IsEnabled()) {
			if(manualDSIO) {
				SetEnhancedIO();	
			} 
			if(manualJoystick[0]) {
				SetJoystick(1, stick1);
			}
			if(manualJoystick[1]) {
				SetJoystick(2, stick2);
			}
			if(manualJoystick[2]) {
				SetJoystick(3, stick3);
			}
			if(manualJoystick[3]) {
				SetJoystick(4, stick4);
			}
		}
		if(!lHandle->IsEnabled()) {
			matchTimer.Reset();
			// It became disabled
			matchTimer.Stop();
			set("matchtimer",0);
		} else {
			// It became enabled
			matchTimer.Start();
			if(lHandle->IsAutonomous()) {
				set("matchtimer",max( 15 - matchTimer.Get(),0));
			} else {
				set("matchtimer",max(120 - matchTimer.Get(),0));
			}
		}
		// The task ends if it's not initialized
		WaitForNextLoop();
	}
	return 0;
}
开发者ID:chopshop-166,项目名称:framework166,代码行数:53,代码来源:Proxy.cpp

示例15: AutonomousLowBar

	void AutonomousLowBar() {
//		Strategy 2 - start in a normal position lined up with low bar, go through low bars and score boulder in lower goal.
//		-------------------------------------------------------------------------------------------------------------------
// 		backUp straight for a little bit
//      drop arm
//   	backup more under lowbar
//      stop (we might add going to lowgoal later)
		switch(currentState)
		{
		case 1:
			timer->Reset();
			timer->Start();
			currentState = 2;
			break;
		case 2:
			drive->TankDrive(autoSpeed,autoSpeed);
			if(timer->Get() >= .4)
			{
				drive->TankDrive(0.0,0.0);
				currentState = 3;
				timer->Reset();
				timer->Start();
			}
			break;
		case 3:
			intakeLever->Set(autoIntakeSpeed);
			if(timer->Get() >= .5)
			{
				intakeLever->Set(0.0);
				currentState = 4;
				timer->Reset();
				timer->Start();
			}
			break;
		case 4:
			drive->TankDrive(autoSpeed,autoSpeed);
			if(timer->Get() >= autoLength)
			{
				drive->TankDrive(0.0,0.0);
				currentState = 5;
				timer->Reset();
				timer->Stop();
			}
			break;
		}
	}
开发者ID:RoboLoCo-5338,项目名称:BasicDrive,代码行数:46,代码来源:Robot.cpp


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