本文整理汇总了C++中Gamepad::GetDPad方法的典型用法代码示例。如果您正苦于以下问题:C++ Gamepad::GetDPad方法的具体用法?C++ Gamepad::GetDPad怎么用?C++ Gamepad::GetDPad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gamepad
的用法示例。
在下文中一共展示了Gamepad::GetDPad方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
//.........这里部分代码省略.........
示例2: 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
{
//.........这里部分代码省略.........
示例3: 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;
}
//.........这里部分代码省略.........