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


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

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


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

示例1: TeleopPeriodic

	void TeleopPeriodic(void) {
		float x = gamepad->GetLeftX();
		float y = gamepad->GetLeftY();
		float rot = gamepad->GetRightX();
		
		//small gamepad values are ignored
		if (x < 0.1f && x > -0.1f)
			{
				x = 0;
			}
		if (y < 0.1f && y > -0.1f)
			{
				y = 0;
			}
		
		if (rot < 0.1f && rot > -0.1f)
			{
				rot = 0;
			}
		
		drive->MecanumDrive_Cartesian(SPEED_LIMIT * x, SPEED_LIMIT * y, SPEED_LIMIT * rot);
		
		//shoot smoke if button is pressed
		if (gamepad2->GetNumberedButton(FIRE_SMOKE_BUTTON)){
			//SHOOT SMOKE!
			//makingSmoke = !makingSmoke;
			smoke_cannon->Set(SMOKE_CANNON_SPEED);
			lcd->PrintfLine(DriverStationLCD::kUser_Line5, "Shooting");
				
			firing_smoke_timer->Start(); //measure how long we've fired smoke, so we know if it's ok to make more
			
		}
		else
		{
			smoke_cannon->Set(0.0f);
			lcd->PrintfLine(DriverStationLCD::kUser_Line5, "Not shooting");
			firing_smoke_timer->Stop(); //stop the timer, since we're not firing smoke.
										//don't reset, cuz we need to how much smoke we've fired.

		}
		//Eye Code
		
//		float eye_pos = gamepad2->GetLeftX();
//		
//		right_eye_x->Set((eye_pos * 60) + default_eye_position);
//		left_eye_x->Set((eye_pos * 60) + default_eye_position - LEFT_EYE_OFFSET);
//		
//		//button lock code
//		if(gamepad2->GetNumberedButtonPressed(EYE_LOCK_BUTTON)){
//			default_eye_position = eye_pos;
//		}
//		
		
		
		//left eye control
		//If A isn't pressed the value should stay the same as before
		if (!gamepad2->GetNumberedButton(1)){
			float left_joystick_x = gamepad2->GetLeftX();
			float left_eye_x_axis = (1 - left_joystick_x)*60;
			left_eye_val = left_eye_x_axis + 50;
			
			float right_joystick_x = gamepad2->GetRawAxis(4);//right x axis
			float right_eye_x_axis = (1-right_joystick_x)*60;
			right_eye_val = right_eye_x_axis+20;
		}
		left_eye_x->SetAngle(left_eye_val);		
		right_eye_x->SetAngle(right_eye_val);
		
		//float right_joystick_y = gamepad2->GetRawAxis(4);
		//float right_eye_y_axis = (right_joystick_y+1)*60;
		//right_eye_y->SetAngle(right_eye_y_axis);

		/*
		bool rbutton = gamepad2->GetNumberedButton(HEAD_UP_BUTTON);
		bool lbutton = gamepad2->Ge tNumberedButton(HEAD_DOWN_BUTTON);
		if (rbutton){
			lcd->PrintfLine(DriverStationLCD::kUser_Line6, "rb pressed");
			jaw_motor->Set(0.2f);
		}else if(lbutton){
			lcd->PrintfLine(DriverStationLCD::kUser_Line6, "lb pressed");
			jaw_motor->Set(-0.15f);
		}else{
			lcd->PrintfLine(DriverStationLCD::kUser_Line6, "no buttons");
			jaw_motor->Set(0.0f);
		}
		*/

		//REAL head & jaw code
		//move head down
		if(gamepad2->GetRightX()<=-0.5f && can_move_head_down() && can_move_jaw_down()){
			head_motor->Set(-0.3f);
			jaw_motor->Set(0.3f);
		}
		//move head up
		else if(gamepad2->GetNumberedButton(HEAD_UP_BUTTON) && can_move_head_up()){
			head_motor->Set(0.3f);
			jaw_motor->Set(-0.3f);
		}
		//move jaw down
		else if(gamepad2->GetRightX()>=0.5f && can_move_jaw_down()){
//.........这里部分代码省略.........
开发者ID:kscottz,项目名称:DragonBot,代码行数:101,代码来源:DragonBotDriveTrain.cpp

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

示例3: if


//.........这里部分代码省略.........
			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;
		}
		
		if(DriverGamepad->GetB())
		{
			armPosition = -1;
			rollerPosition = 1;
		}

		spinSpeed *= rollerPosition;
		myCollection->SpinMotor(spinSpeed);

		if (armPosition > 0)
			myCollection->ExtendArm();
		else if (armPosition < 0)
			myCollection->RetractArm();
		//End Ball Collection

		//Fire Control

#ifndef DISABLE_SHOOTER
		myCam->Process(ShouldFireButton, (OperatorGamepad->GetX() || DriverGamepad->GetX() ), DriverGamepad->GetB());
		//myCam->Debug(cout);
#endif //Ends DISABLE_SHOOTER
		
		//End Fire Control


		//Ring Light
		if (RingLightButton) {
			RingLightButtonRecentlyPressed = true;
		}

		if (!RingLightButton && RingLightButtonRecentlyPressed) {
			if (myCamera->Get() == Relay::kOff)
				myCamera->Set(Relay::kForward);
			else
				myCamera->Set(Relay::kOff);

			RingLightButtonRecentlyPressed = false;
		}
		//End Ring Light


		//Drive Processing
		if(DriverDPad == Gamepad::kUp)
		{
			cout << "Forward" << endl;
			myDrive->reverseDirectionForward();
		}
		else if(DriverDPad == Gamepad::kDown)
		{
			cout << "Backward"<<endl;
			myDrive->reverseDirectionReverse();
		}
		
		if (DriverLeftBumper) {
			myDrive->ShiftUp();
		} else if (DriverRightBumper) {
			myDrive->ShiftDown();
		}

		//myDrive->Drive(DriverLeftY, DriverRightY);
		myDrive->DriveArcade(DriverGamepad->GetRightX(), DriverGamepad->GetRightY());
		myDrive->Debug(cout);
		//End Drive Processing


		EndOfCycleMaintenance();
	}
开发者ID:RAR1741,项目名称:RA14_RobotCode,代码行数:101,代码来源:RobotMain.cpp


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