mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] Getting Started: Change Joystick to XboxController (#4194)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user