mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
C++ examples no longer use deprecated APIs (#703)
This commit is contained in:
committed by
Peter Johnson
parent
c24e755409
commit
faf134a674
@@ -5,16 +5,19 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <WPILib.h>
|
||||
#include <Drive/DifferentialDrive.h>
|
||||
#include <IterativeRobot.h>
|
||||
#include <Joystick.h>
|
||||
#include <Spark.h>
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of the RobotDrive class.
|
||||
* This is a demo program showing the use of the DifferentialDrive class.
|
||||
* Runs the motors with arcade steering.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
frc::Spark m_left{0};
|
||||
frc::Spark m_right{1};
|
||||
frc::RobotDrive m_robotDrive{m_left, m_right};
|
||||
frc::Spark m_leftMotor{0};
|
||||
frc::Spark m_rightMotor{1};
|
||||
frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};
|
||||
frc::Joystick m_stick{0};
|
||||
|
||||
public:
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a gyro sensor to make a
|
||||
* robot drive
|
||||
* straight. This program uses a joystick to drive forwards and backwards while
|
||||
* the gyro
|
||||
* is used for direction keeping.
|
||||
* robot drive straight. This program uses a joystick to drive forwards and
|
||||
* backwards while the gyro is used for direction keeping.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
public:
|
||||
@@ -27,9 +25,9 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* The motor speed is set from the joystick while the RobotDrive turning
|
||||
* value is assigned from the error between the setpoint and the gyro
|
||||
* angle.
|
||||
* The motor speed is set from the joystick while the DifferentialDrive
|
||||
* turning value is assigned from the error between the setpoint and the
|
||||
* gyro angle.
|
||||
*/
|
||||
void TeleopPeriodic() override {
|
||||
double turningValue = (kAngleSetpoint - m_gyro.GetAngle()) * kP;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <Spark.h>
|
||||
|
||||
/**
|
||||
* This is a demo program showing how to use Mecanum control with the RobotDrive
|
||||
* class.
|
||||
* This is a demo program showing how to use Mecanum control with the
|
||||
* MecanumDrive class.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
public:
|
||||
|
||||
@@ -25,8 +25,8 @@ DriveTrain::DriveTrain()
|
||||
// frc::LiveWindow::GetInstance()->AddActuator("DriveTrain", "Back Right
|
||||
// CIM", &m_backRightCIM);
|
||||
|
||||
// Configure the RobotDrive to reflect the fact that all our motors are
|
||||
// wired backwards and our drivers sensitivity preferences.
|
||||
// Configure the DifferentialDrive to reflect the fact that all our
|
||||
// motors are wired backwards and our drivers sensitivity preferences.
|
||||
m_robotDrive.SetSafetyEnabled(false);
|
||||
m_robotDrive.SetExpiration(0.1);
|
||||
m_robotDrive.SetMaxOutput(1.0);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <Timer.h>
|
||||
|
||||
/**
|
||||
* This is a demo program showing the use of the RobotDrive class.
|
||||
* This is a demo program showing the use of the DifferentialDrive class.
|
||||
* The SampleRobot class is the base of a robot application that will
|
||||
* automatically call your Autonomous and OperatorControl methods at the right
|
||||
* time as controlled by the switches on the driver station or the field
|
||||
|
||||
Reference in New Issue
Block a user