mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Rename Gyro to AnalogGyro and make Gyro an interface.
Refactor common implementation parts of AnalogGyro into GyroBase. This will make it possible to add digital gyros in a similar way to how digital accelerometers were added. Change-Id: I437ef259e9ecb81f18a91a95c5a58b6607db5e15
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
DriveTrain::DriveTrain()
|
||||
: Subsystem("DriveTrain"), left_encoder(new Encoder(1, 2)),
|
||||
right_encoder(new Encoder(3, 4)), rangefinder(new AnalogInput(6)),
|
||||
gyro(new Gyro(1)) {
|
||||
gyro(new AnalogGyro(1)) {
|
||||
drive = new RobotDrive(new Talon(1), new Talon(2),
|
||||
new Talon(3), new Talon(4));
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ private:
|
||||
RobotDrive* drive;
|
||||
std::shared_ptr<Encoder> left_encoder, right_encoder;
|
||||
std::shared_ptr<AnalogInput> rangefinder;
|
||||
std::shared_ptr<Gyro> gyro;
|
||||
std::shared_ptr<AnalogGyro> gyro;
|
||||
|
||||
public:
|
||||
DriveTrain();
|
||||
|
||||
@@ -27,7 +27,7 @@ class Robot: public SampleRobot {
|
||||
const double voltsPerDegreePerSecond = .0128;
|
||||
|
||||
RobotDrive myRobot;
|
||||
Gyro gyro;
|
||||
AnalogGyro gyro;
|
||||
Joystick joystick;
|
||||
|
||||
public:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
class Robot: public SampleRobot {
|
||||
Joystick joystick;
|
||||
RobotDrive myRobot;
|
||||
Gyro gyro;
|
||||
AnalogGyro gyro;
|
||||
|
||||
//channels for motors
|
||||
const int leftMotorChannel = 1;
|
||||
|
||||
@@ -13,7 +13,7 @@ DriveTrain::DriveTrain()
|
||||
drive(frontRightCIM, backLeftCIM, frontRightCIM, backRightCIM),
|
||||
rightEncoder(new Encoder(1, 2, true, Encoder::k4X)),
|
||||
leftEncoder(new Encoder(3, 4, false, Encoder::k4X)),
|
||||
gyro(new Gyro(0)) {
|
||||
gyro(new AnalogGyro(0)) {
|
||||
// XXX: LiveWindow::GetInstance()->AddActuator("DriveTrain", "Front Left CIM", (Victor) frontLeftCIM);
|
||||
// XXX: LiveWindow::GetInstance()->AddActuator("DriveTrain", "Front Right CIM", (Victor) frontRightCIM);
|
||||
// XXX: LiveWindow::GetInstance()->AddActuator("DriveTrain", "Back Left CIM", (Victor) backLeftCIM);
|
||||
|
||||
@@ -16,7 +16,7 @@ private:
|
||||
std::shared_ptr<SpeedController> backLeftCIM, backRightCIM;
|
||||
RobotDrive drive;
|
||||
std::shared_ptr<Encoder> rightEncoder, leftEncoder;
|
||||
std::shared_ptr<Gyro> gyro;
|
||||
std::shared_ptr<AnalogGyro> gyro;
|
||||
|
||||
public:
|
||||
DriveTrain();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package $package.subsystems;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.AnalogInput;
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.Joystick.AxisType;
|
||||
import edu.wpi.first.wpilibj.Gyro;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.RobotDrive;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
@@ -25,7 +25,7 @@ public class DriveTrain extends Subsystem {
|
||||
private RobotDrive drive;
|
||||
private Encoder left_encoder, right_encoder;
|
||||
private AnalogInput rangefinder;
|
||||
private Gyro gyro;
|
||||
private AnalogGyro gyro;
|
||||
|
||||
public DriveTrain() {
|
||||
super();
|
||||
@@ -53,7 +53,7 @@ public class DriveTrain extends Subsystem {
|
||||
}
|
||||
|
||||
rangefinder = new AnalogInput(6);
|
||||
gyro = new Gyro(1);
|
||||
gyro = new AnalogGyro(1);
|
||||
|
||||
// Let's show everything on the LiveWindow
|
||||
LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
package $package;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.CANTalon;
|
||||
import edu.wpi.first.wpilibj.Gyro;
|
||||
import edu.wpi.first.wpilibj.SampleRobot;
|
||||
import edu.wpi.first.wpilibj.RobotDrive;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
@@ -35,7 +35,7 @@ public class Robot extends SampleRobot {
|
||||
final double voltsPerDegreePerSecond = .0128;
|
||||
|
||||
RobotDrive myRobot;
|
||||
Gyro gyro;
|
||||
AnalogGyro gyro;
|
||||
Joystick joystick;
|
||||
|
||||
public Robot()
|
||||
@@ -44,7 +44,7 @@ public class Robot extends SampleRobot {
|
||||
myRobot = new RobotDrive(new CANTalon(leftMotorChannel), new CANTalon(
|
||||
leftRearMotorChannel), new CANTalon(rightMotorChannel),
|
||||
new CANTalon(rightRearMotorChannel));
|
||||
gyro = new Gyro(gyroChannel);
|
||||
gyro = new AnalogGyro(gyroChannel);
|
||||
joystick = new Joystick(joystickChannel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
package $package;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.CANTalon;
|
||||
import edu.wpi.first.wpilibj.Gyro;
|
||||
import edu.wpi.first.wpilibj.SampleRobot;
|
||||
import edu.wpi.first.wpilibj.RobotDrive;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
@@ -20,7 +20,7 @@ import edu.wpi.first.wpilibj.RobotDrive.MotorType;
|
||||
public class Robot extends SampleRobot {
|
||||
RobotDrive myRobot;
|
||||
Joystick joystick;
|
||||
Gyro gyro;
|
||||
AnalogGyro gyro;
|
||||
|
||||
//channels for motors
|
||||
final int leftMotorChannel = 1;
|
||||
@@ -42,7 +42,7 @@ public class Robot extends SampleRobot {
|
||||
myRobot.setInvertedMotor(MotorType.kRearLeft, true); // you may need to change or remove this to match your robot
|
||||
|
||||
joystick = new Joystick(0);
|
||||
gyro = new Gyro(gyroChannel);
|
||||
gyro = new AnalogGyro(gyroChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,9 @@ package $package.subsystems;
|
||||
import $package.Robot;
|
||||
import $package.commands.DriveWithJoystick;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogGyro;
|
||||
import edu.wpi.first.wpilibj.CounterBase.EncodingType;
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.Gyro;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.PIDSource.PIDSourceParameter;
|
||||
import edu.wpi.first.wpilibj.RobotDrive;
|
||||
@@ -24,7 +24,7 @@ public class DriveTrain extends Subsystem {
|
||||
private SpeedController backLeftCIM, backRightCIM;
|
||||
private RobotDrive drive;
|
||||
private Encoder rightEncoder, leftEncoder;
|
||||
private Gyro gyro;
|
||||
private AnalogGyro gyro;
|
||||
|
||||
public DriveTrain() {
|
||||
// Configure drive motors
|
||||
@@ -67,7 +67,7 @@ public class DriveTrain extends Subsystem {
|
||||
LiveWindow.addSensor("DriveTrain", "Left Encoder", leftEncoder);
|
||||
|
||||
// Configure gyro
|
||||
gyro = new Gyro(2);
|
||||
gyro = new AnalogGyro(2);
|
||||
if (Robot.isReal()) {
|
||||
gyro.setSensitivity(0.007); // TODO: Handle more gracefully?
|
||||
}
|
||||
@@ -124,4 +124,4 @@ public class DriveTrain extends Subsystem {
|
||||
public double getAngle() {
|
||||
return gyro.getAngle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user