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


C++ Gamepad::GetX方法代码示例

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


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

示例1: TeleopPeriodic

    void TeleopPeriodic() {
    	//Target * target = GetLatestTarget();
    	//Begin DRIVER input section
    	if(driverGamepad->GetDPad()==Gamepad::kUp)
    		lc->setMode(1);
    	else if(driverGamepad->GetDPad()==Gamepad::kDown)
    		lc->setMode(6);
    	else
    		lc->setMode(0);
    	if(driverGamepad->GetDPad() == Gamepad::kRight)
    	{
    		cameraLight->Set(Relay::kOff);
    	}
    	else if(driverGamepad->GetDPad() == Gamepad::kLeft)
    	{
    		cameraLight->Set(Relay::kOn);
    	}
    	
    	if(driverGamepad->GetB())
    	{
    		cout << "Resetting the gyro! :D" << endl;
    		//driveGyro->Reset();
    		magicBox->resetGyro();
   		}
    	
    	bool modifySpeed = driverGamepad->GetRightBumper();
    	bool halfSpeed = driverGamepad->GetLeftBumper();
    	
    	/*
    	try {
    		std::string temp = SmartDashboard::GetString("TargetInfo");
    		cout << "temp: " << endl;
    	} catch (exception ex) {
    		cout << "bah! " << ex.what() << endl;
    	}*/
    	
    	//Target t = GetLatestTarget();
    	
    	/*
    	if (t.IsValid()) {
    		cout << "Valid target (" << (t.IsCenter() ? "center" : "side") << "):" << t.Distance() << " ft, " << t.X() << "," << t.Y() << endl;
    	} else {
    		//cout << "No valid target." << endl;
    	} */
    		
    	if(driverGamepad->GetBack())
    	{
    		cout << "Now driving in relation to the robot" << endl;
    			myDrive->setGyroDrive(false);
    	}
    	if(driverGamepad->GetStart())
    	{
    		cout << "Now driving in relation to the field (gyro)" << endl;
    		myDrive->setGyroDrive(true);
    	}
    	
    	// If the driver is holding the X button 
    	/*
    	if (driverGamepad->GetX()) {
    		// Stop using the joysticks to drive the robot, and let this function do it
    	    PointAtTarget(t);
    	} else { */
    		// We aren't auto-targeting. Reset the sequence.
    		target_state = RA13Robot::READY;
    		// Drive based on joysticks.
    		myDrive->Drive(driverGamepad->GetLeftX(), driverGamepad->GetLeftY(), 
    		    			driverGamepad->GetRightX(), magicBox->getGyroAngle(), modifySpeed,halfSpeed);
    	//}
    	//End DRIVER input section
    	
    	Gamepad::DPadDirection dir = operatorGamepad->GetDPad();
    	
    	if (dir != lastdir) {
    		switch(dir) {
    		case Gamepad::kUp:
    			manualAngle += 1;
    			break;
    		case Gamepad::kDown:
    			manualAngle -= 1;
    			break;
    		case Gamepad::kRight:
    			manualAngle += 0.25;
    			break;
    		case Gamepad::kLeft:
    			manualAngle -= 0.25;
    			break;
    		default:
    			break;
    		}
    	}
    	
    	//cout << "Current target angle: " << manualAngle << endl;
    	
    	//Begin OPERATOR input section
    		
    	if(operatorGamepad->GetBack())
    	{
    		myShooter->ResetShooterProcess(); // Re-homes the shooter
    	}
    	
//.........这里部分代码省略.........
开发者ID:RAR1741,项目名称:RA13_RobotCode,代码行数:101,代码来源:RobotMain.cpp

示例2: if

	/**
	 * Periodic code for teleop mode should go here.
	 *
	 * Use this method for code which will be called periodically at a regular
	 * rate while the robot is in teleop mode.
	 */
	void RA14Robot::TeleopPeriodic() {
		StartOfCycleMaintenance();

		//Input Acquisition
		DriverLeftY = DriverGamepad->GetLeftY();
		DriverRightY = DriverGamepad->GetRightY();
		DriverLeftBumper = DriverGamepad->GetLeftBumper(); // Reads state of left bumper 
		DriverRightBumper = DriverGamepad->GetRightBumper(); // Gets state of right bumper
		RingLightButton = OperatorGamepad->GetY();
		ShouldFireButton = DriverGamepad->GetRightTrigger();
		BallCollectPickupButton = DriverGamepad->GetBack();
		DriverDPad = DriverGamepad->GetDPad();
		OperatorDPad = OperatorGamepad->GetDPad();
		//End Input Acquisition


		//Current Sensing
		//myCurrentSensor->Toggle(DriverGamepad->GetStart());
		//End Current Sensing


		//Target Processing
		target->Parse(server->GetLatestPacket());

		/*
		 if (target->IsValid()) {
		 cout << "\tx = " << target->GetX() << ", y = " << target->GetY() << ", distance = " << target->GetDistance() << "ft";
		 cout << "\tside = " << (target->IsLeft() ? "LEFT" : "RIGHT") << ", hot = " << (target->IsHot() ? "HOT" : "NOT") << endl;
		 }
		 else {
		 cout << "No Target Received..." << endl;
		 }
		 */

		//End Target Processing


		//Ball Collection

		/*
		 if(BallCollectPickupButton)
		 {
		 myCollection->Collect();
		 }
		 else
		 {
		 myCollection->ResetPosition();
		 }
		 */

		float spinSpeed = Config::GetSetting("intake_roller_speed", 1);
		int armPosition = 0;
		int rollerPosition = 0;

		switch (OperatorDPad) {
		case Gamepad::kCenter:
			armPosition = 0;
			rollerPosition = 0;
			break;
		case Gamepad::kUp:
			armPosition = -1;
			break;
		case Gamepad::kUpLeft:
			armPosition = -1;
			rollerPosition = -1;
			break;
		case Gamepad::kUpRight:
			armPosition = -1;
			rollerPosition = 1;
			break;
		case Gamepad::kDown:
			armPosition = 1;
			break;
		case Gamepad::kDownLeft:
			armPosition = 1;
			rollerPosition = -1;
			break;
		case Gamepad::kDownRight:
			armPosition = 1;
			rollerPosition = 1;
			break;
		case Gamepad::kLeft:
			rollerPosition = -1;
			break;
		case Gamepad::kRight:
			rollerPosition = 1;
			break;
		}

		if (DriverGamepad->GetLeftTrigger()) {
			armPosition = 0;
			rollerPosition = -1;
		}
		
//.........这里部分代码省略.........
开发者ID:RAR1741,项目名称:RA14_RobotCode,代码行数:101,代码来源:RobotMain.cpp


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