From f0fdfabc2eff9dc10427ff06bc81b8cb5f9ec4cf Mon Sep 17 00:00:00 2001 From: mayabartels Date: Mon, 21 Jan 2019 13:07:41 -0800 Subject: [PATCH] Created Wrist Subsystem Created the wrist subsystem, commented out compile pathfinder in build.gradle. Edited Robot Map by changing carriage to wrist motors --- 2019robot/build.gradle | 2 +- .../java/org/usfirst/frc4388/robot/Robot.java | 3 +- .../org/usfirst/frc4388/robot/RobotMap.java | 4 +- .../frc4388/robot/subsystems/Wrist.java | 54 +++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Wrist.java diff --git a/2019robot/build.gradle b/2019robot/build.gradle index f15e84c..01830a7 100644 --- a/2019robot/build.gradle +++ b/2019robot/build.gradle @@ -50,7 +50,7 @@ dependencies { nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio) nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop) testCompile 'junit:junit:4.12' - compile pathfinder() + //compile pathfinder() } // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java index 36fea3e..befa07b 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/Robot.java @@ -37,7 +37,8 @@ public class Robot extends IterativeRobot public static final Climber climber = new Climber(); - public static final Pnumatics pnumatics = new Pnumatics(); + public static final Pnumatics pnumatics = new Pnumatics(); + public static final Wrist wrist = new Wrist(); public static final long periodMS = 10; public static final ControlLooper controlLoop = new ControlLooper("Main control loop", periodMS); diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/RobotMap.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/RobotMap.java index 64e015f..8f33251 100644 --- a/2019robot/src/main/java/org/usfirst/frc4388/robot/RobotMap.java +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/RobotMap.java @@ -18,8 +18,8 @@ public class RobotMap { public static final int DRIVETRAIN_RIGHT_MOTOR2_CAN_ID = 5; //carriage motors - public static final int CARRIAGE_LEFT_MOTOR_CAN_ID = 8; - public static final int CARRIAGE_RIGHT_MOTOR_CAN_ID = 9; + public static final int WRIST_LEFT_MOTOR_CAN_ID = 8; + public static final int WRITST_RIGHT_MOTOR_CAN_ID = 9; //Elevator Motors public static final int ELEVATOR_MOTOR1_ID = 6; diff --git a/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Wrist.java b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Wrist.java new file mode 100644 index 0000000..c0c1b17 --- /dev/null +++ b/2019robot/src/main/java/org/usfirst/frc4388/robot/subsystems/Wrist.java @@ -0,0 +1,54 @@ +package org.usfirst.frc4388.robot.subsystems; + +import edu.wpi.first.wpilibj.command.Subsystem; + +import org.usfirst.frc4388.controller.XboxController; +import org.usfirst.frc4388.robot.Constants; +import org.usfirst.frc4388.robot.Robot; +import org.usfirst.frc4388.robot.RobotMap; +import org.usfirst.frc4388.robot.commands.*; +import org.usfirst.frc4388.robot.subsystems.Drive.DriveControlMode; +import org.usfirst.frc4388.utility.CANTalonEncoder; +import org.usfirst.frc4388.utility.ControlLoopable; +import org.usfirst.frc4388.utility.PIDParams; +import org.usfirst.frc4388.utility.SoftwarePIDPositionController; + +import com.ctre.phoenix.motorcontrol.FeedbackDevice; +import com.ctre.phoenix.motorcontrol.LimitSwitchNormal; +import com.ctre.phoenix.motorcontrol.RemoteLimitSwitchSource; +import com.ctre.phoenix.motorcontrol.LimitSwitchSource; +import com.ctre.phoenix.motorcontrol.NeutralMode; +import com.ctre.phoenix.motorcontrol.SensorCollection; +import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; + +/** + * Add your docs here. + */ +public class Wrist extends Subsystem +{ + //PID encoder and motor + private CANTalonEncoder wristRight; + private WPI_TalonSRX wristLeft; + + //Encoder ticks to inches for encoders + public static final double ENCODER_TICKS_TO_INCHES = Constants.kElevatorEncoderTicksPerInch; + + public Wrist() + { + try + { + //PID wrist encoder and talon + wristRight = new CANTalonEncoder(RobotMap.WRIST_LEFT_MOTOR_CAN_ID, ENCODER_TICKS_TO_INCHES, FeedbackDevice.QuadEncoder); + wristLeft = new WPI_TalonSRX(RobotMap.WRITST_RIGHT_MOTOR_CAN_ID); + } + catch(Exception e) + { + System.err.println("You thought the code would work, but it was me, error. An error occurred in the Wrist Construtor"); + } + } + + @Override + public void initDefaultCommand() + { + } +}