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


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

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


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

示例1: TeleopPeriodic

/**
 * 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 RobotDemo::TeleopPeriodic()
{
	drive->TeleopDrive(driverPad->GetLeftY() *DRIVER_LEFT_DIRECTION, driverPad->GetRightY() *DRIVER_RIGHT_DIRECTION);
	shooter->handle();
	shooter->debug();
	
	//shooter->setShooterPower(operatorPad->GetRightY());
	
	if((intakeMode == IN_INTAKE_MANUAL_MODE) && operatorPad->GetNumberedButton(INTAKE_AUTO_MODE_BUTTON))
	{
		intakeMode = IN_INTAKE_AUTO_MODE;
		printf ("set into auto roller mode");
		intake->setExtenderMode(IN_INTAKE_AUTO_MODE);
	}
	//sets intake mode to auto if previously in manual and operator presses auto button
	else if((intakeMode == IN_INTAKE_AUTO_MODE) && operatorPad->GetNumberedButton(INTAKE_MANUAL_MODE_BUTTON))
	{
		intakeMode = IN_INTAKE_MANUAL_MODE;
		printf ("set into manual roller mode");
		intake->setExtenderMode(IN_INTAKE_MANUAL_MODE);
	}
	
	intake->handle();
	
	if(intakeMode == IN_INTAKE_MANUAL_MODE)
	{
		intake->move(operatorPad->GetLeftY()*OPERATOR_LEFT_DIRECTION);
	}
	else
	{
		//Extender DPad control
		curPadDir = operatorPad->GetDPad();
		
		if(lastPadDir != curPadDir)
		{
			switch(curPadDir)
			{
			case Gamepad::kUp:
				intake->setExtenderTarget(FULL_EXTEND_DISTANCE);
				break;
			case Gamepad::kDown:
				intake->setExtenderTarget(FULL_RETRACT_DISTANCE);
				break;
			default:
				break;
			}
		}
		
		lastPadDir = curPadDir;
	}
	
	//intake->spinRoller(operatorPad->GetRightY()*OPERATOR_RIGHT_DIRECTION);
	intake->getCurrentPosition();
	
	
	//if operator taps in button roller continually spins inward
	if(operatorPad->GetNumberedButton(ROLLER_IN_BUTTON))
	{
		intakeCont = INTAKE_ROLLER_IN_STATE;
	}
	//if operator taps stop button roller stops continually
	else if(operatorPad->GetNumberedButton(ROLLER_OFF_BUTTON))
	{
		intakeCont = INTAKE_ROLLER_STOP_STATE;
	}
	
	//if operator holds spit button roller spins backwards no matter what
	if(operatorPad->GetNumberedButton(ROLLER_OUT_BUTTON))
	{
		intake->spinRoller(INTAKE_ROLLER_SPIT_POWER);
	}
	//not holding spit button
	else
	{
		//roller either spins or is stopped depending on previous code
		if(intakeCont)
		{
			intake->spinRoller(INTAKE_ROLLER_IN_POWER);
		}
		else
		{
			intake->spinRoller(INTAKE_ROLLER_STOP_POWER);
		}
	}
		

	
	if(operatorPad->GetNumberedButton(RIGHT_TRIGGER_BUTTON)) // low shot = Right Trigger
	{
		shooter->initShot(SHOT_LOW_ANGLE, SHOT_LOW_SPEED);
		printf("test button 1 is pressed");
	}
	else if(operatorPad->GetNumberedButton(LEFT_TRIGGER_BUTTON)) // pass = Left Trigger
	{
//.........这里部分代码省略.........
开发者ID:Manchester-Central,项目名称:CHAOS-Archived-Code,代码行数:101,代码来源:MyRobot.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::GetRightY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。