本文整理汇总了C++中Gamepad::GetLeftX方法的典型用法代码示例。如果您正苦于以下问题:C++ Gamepad::GetLeftX方法的具体用法?C++ Gamepad::GetLeftX怎么用?C++ Gamepad::GetLeftX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gamepad
的用法示例。
在下文中一共展示了Gamepad::GetLeftX方法的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
}
//.........这里部分代码省略.........
示例2: 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()){
//.........这里部分代码省略.........