[examples] Getting Started: Change Joystick to XboxController (#4194)

This commit is contained in:
DeltaDizzy
2022-06-09 00:20:33 -05:00
committed by GitHub
parent a99c11c14c
commit f7b3f4b90e
2 changed files with 8 additions and 7 deletions

View File

@@ -2,9 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <frc/Joystick.h>
#include <frc/TimedRobot.h>
#include <frc/Timer.h>
#include <frc/XboxController.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc/motorcontrol/PWMSparkMax.h>
@@ -38,8 +38,9 @@ class Robot : public frc::TimedRobot {
void TeleopInit() override {}
void TeleopPeriodic() override {
// Drive with arcade style (use right stick)
m_robotDrive.ArcadeDrive(-m_stick.GetY(), m_stick.GetX());
// Drive with arcade style (use right stick to steer)
m_robotDrive.ArcadeDrive(-m_controller.GetLeftY(),
m_controller.GetRightX());
}
void TestInit() override {}
@@ -52,7 +53,7 @@ class Robot : public frc::TimedRobot {
frc::PWMSparkMax m_right{1};
frc::DifferentialDrive m_robotDrive{m_left, m_right};
frc::Joystick m_stick{0};
frc::XboxController m_controller{0};
frc::Timer m_timer;
};