Skip to content

Commit

Permalink
Added navx
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercury 1089 authored and Mercury 1089 committed Jan 20, 2017
1 parent ad86882 commit e3c2379
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Project specific information
package=com.mercury1089.main
package=org.usfirst.frc.team1089.robot
robot.class=${package}.Robot
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
6 changes: 3 additions & 3 deletions src/org/usfirst/frc/team1089/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class OI {

public OI() {

leftStick = new Joystick(RobotMap.USB.LEFT_STICK);
rightStick = new Joystick(RobotMap.USB.RIGHT_STICK);
gamePad = new Joystick(RobotMap.USB.GAMEPAD);
leftStick = new Joystick(RobotMap.DS_USB.LEFT_STICK);
rightStick = new Joystick(RobotMap.DS_USB.RIGHT_STICK);
gamePad = new Joystick(RobotMap.DS_USB.GAMEPAD);

//// TRIGGERING COMMANDS WITH BUTTONS
// Once you have a button, it's trivial to bind it to a button in one of
Expand Down
2 changes: 1 addition & 1 deletion src/org/usfirst/frc/team1089/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Robot extends IterativeRobot {
*/
@Override
public void robotInit() {
// Instantiate the sybsystems
// Instantiate the subsystems
exampleSubsystem = new ExampleSubsystem();
driveTrain = new DriveTrain();

Expand Down
2 changes: 1 addition & 1 deletion src/org/usfirst/frc/team1089/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class CAN {
* The {@code USB} subclass contains all the ports for anything using the USB interface.
* This only contains the joysticks.
*/
public static class USB {
public static class DS_USB {
public static final int LEFT_STICK = 1;
public static final int RIGHT_STICK = 0;
public static final int GAMEPAD = 2;
Expand Down
14 changes: 8 additions & 6 deletions src/org/usfirst/frc/team1089/robot/subsystems/DriveTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import com.ctre.CANTalon;
import com.ctre.CANTalon.FeedbackDevice;

import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.SerialPort;
import edu.wpi.first.wpilibj.AnalogGyro;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
Expand All @@ -19,20 +20,20 @@
*/
public class DriveTrain extends Subsystem {

private OI oi;

private AnalogGyro gyro;
private CANTalon leftBack;
private CANTalon rightBack;
private CANTalon leftFront;
private CANTalon rightFront;
private RobotDrive robotDrive;
private AHRS navx;

public DriveTrain() {
oi = Robot.oi;

gyro = new AnalogGyro(RobotMap.Analog.GYRO);
gyro.setSensitivity(0.007); // TODO Move this to Config

navx = new AHRS(SerialPort.Port.kUSB1);

leftBack = new CANTalon(RobotMap.CAN.LEFT_BACK_TALON_ID);
leftFront = new CANTalon(RobotMap.CAN.LEFT_FRONT_TALON_ID);
Expand Down Expand Up @@ -62,6 +63,7 @@ public DriveTrain() {
robotDrive.setInvertedMotor(RobotDrive.MotorType.kRearLeft, true);

LiveWindow.addSensor("DriveTrain", "Gyro", gyro);
LiveWindow.addSensor("DriveTrain", "Nav-X", navx);
LiveWindow.addActuator("DriveTrain", "LeftFront", leftFront);
LiveWindow.addActuator("DriveTrain", "RightFront", rightFront);

Expand All @@ -84,8 +86,8 @@ public void initDefaultCommand() {
*/
public void joystickDrive(Joystick leftStick, Joystick rightStick) {
// Apply the joystick deadzones to the move and rotate values
double moveValue = oi.applyDeadzone(leftStick.getX(), oi.JS_DEADZONE_LIMIT);
double rotateValue = oi.applyDeadzone(rightStick.getY(), oi.JS_DEADZONE_LIMIT);
double moveValue = Robot.oi.applyDeadzone(rightStick.getX(), Robot.oi.JS_DEADZONE_LIMIT);
double rotateValue = Robot.oi.applyDeadzone(leftStick.getY(), Robot.oi.JS_DEADZONE_LIMIT);
robotDrive.arcadeDrive(moveValue, rotateValue);
}

Expand Down

0 comments on commit e3c2379

Please sign in to comment.