From d50d7e85561654f879b63419700420cc23d731bc Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Fri, 22 Jul 2016 16:46:56 -0400 Subject: [PATCH] Possible case issue fix --- .../team2059/robot/subsystems/DriveBase.java | 21 ++++++++++++++ .../robot/subsystems/EncoderBase.java | 29 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java create mode 100644 src/org/usfirst/frc/team2059/robot/subsystems/EncoderBase.java diff --git a/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java b/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java new file mode 100644 index 0000000..722b67d --- /dev/null +++ b/src/org/usfirst/frc/team2059/robot/subsystems/DriveBase.java @@ -0,0 +1,21 @@ +package org.usfirst.frc.team2059.robot.subsystems; +import org.usfirst.frc.team2059.robot.RobotMap; +import org.usfirst.frc.team2059.robot.commands.Drive; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.CANTalon; +public class DriveBase extends Subsystem { + CANTalon leftMotorOne = new CANTalon(RobotMap.driveLeftMotorOne); + CANTalon leftMotorTwo = new CANTalon(RobotMap.driveLeftMotorTwo); + CANTalon rightMotorOne = new CANTalon(RobotMap.driveRightMotorOne); + CANTalon rightMotorTwo = new CANTalon(RobotMap.driveRightMotorOne); + public void initDefaultCommand() { + setDefaultCommand(new Drive()); + } + public void driveArcade(double x, double y, double z, double sensitivity) { + leftMotorOne.set(-y + (x + z)); + leftMotorTwo.set(-y + (x + z)); + rightMotorOne.set(y + (x + z)); + rightMotorTwo.set(y + (x + z)); + } +} +// vim: sw=2:ts=2:sts=2 \ No newline at end of file diff --git a/src/org/usfirst/frc/team2059/robot/subsystems/EncoderBase.java b/src/org/usfirst/frc/team2059/robot/subsystems/EncoderBase.java new file mode 100644 index 0000000..5beb9c7 --- /dev/null +++ b/src/org/usfirst/frc/team2059/robot/subsystems/EncoderBase.java @@ -0,0 +1,29 @@ +package org.usfirst.frc.team2059.robot.subsystems; +import org.usfirst.frc.team2059.robot.RobotMap; +import org.usfirst.frc.team2059.robot.commands.Drive; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.Encoder; +import org.usfirst.frc.team2059.robot.structs.EncoderValues; +public class EncoderBase extends Subsystem { + Encoder enc = new Encoder(0, 1, false, Encoder.EncodingType.k4X); + public void initDefaultCommand() { + //TODO: Not sure if we need a default command, not settingo one + //TODO: These are just defaults, they wil lneed to be changed + enc.setMaxPeriod(.1); + enc.setMinRate(10); + enc.setDistancePerPulse(5); + enc.setReverseDirection(false); + enc.setSamplesToAverage(7); + } + public void resetEncoder() { + enc.reset(); + } + public EncoderValues getValues() { + //TODO: There are two ways to get distance: + //enc.getDistance(); + //enc.getRaw(); + //figure out which to use + return new EncoderValues(enc.get() , enc.getRaw() , enc.getPeriod() , enc.getRate() , enc.getDirection() , enc.getStopped()); + } +} +// vim: sw=2:ts=2:sts=2