Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit b17b748

Browse files
committed
Subsystem interfaces + methods
added some methods and motor controllers to Lift, Intake, and Climber
1 parent 1680ed9 commit b17b748

7 files changed

Lines changed: 58 additions & 87 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/RobotMap.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public class RobotMap {
4141
// public static int rangefinderPort = 1;
4242
// public static int rangefinderModule = 1;
4343

44-
public static SpeedController intakeMotors;
45-
public static SpeedController liftMotors;
46-
public static SpeedController climberMotors;
44+
public static WPI_TalonSRX intakeMotor;
45+
public static WPI_TalonSRX liftMotor;
46+
public static WPI_TalonSRX climberMotor;
4747

4848
public static Encoder leftEnc;
4949
public static WPI_TalonSRX dtLeftDrive;
@@ -96,12 +96,12 @@ private void configSPX(WPI_VictorSPX mc) {
9696

9797
public RobotMap() {
9898

99-
intakeMotors = new WPI_TalonSRX(getPort("IntakeTalonSRX", 4));
100-
configSRX((WPI_TalonSRX) intakeMotors);
101-
liftMotors = new WPI_TalonSRX(getPort("LiftTalonSRX", 5));
102-
configSRX((WPI_TalonSRX) liftMotors);
103-
climberMotors = new WPI_TalonSRX(getPort("ClimberTalonSRX", 6));
104-
configSRX((WPI_TalonSRX) climberMotors);
99+
intakeMotor = new WPI_TalonSRX(getPort("IntakeTalonSRX", 4));
100+
configSRX(intakeMotor);
101+
liftMotor = new WPI_TalonSRX(getPort("LiftTalonSRX", 5));
102+
configSRX(liftMotor);
103+
climberMotor = new WPI_TalonSRX(getPort("ClimberTalonSRX", 6));
104+
configSRX(climberMotor);
105105

106106
leftEnc = new Encoder(getPort("1LeftEnc", 0), getPort("2LeftEnc", 1));
107107
dtLeftDrive = new WPI_TalonSRX(getPort("LeftTalonSRXDrive", 0));

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/Climber.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
import org.usfirst.frc.team199.Robot2018.RobotMap;
66

7-
import edu.wpi.first.wpilibj.SpeedController;
7+
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
8+
89
/**
910
*
1011
*/
1112
public class Climber extends Subsystem implements ClimberInterface {
1213

13-
private final SpeedController climberMotors = RobotMap.climberMotors;
14+
private final WPI_TalonSRX climberMotor = RobotMap.climberMotor;
1415

1516

1617
/**
@@ -25,12 +26,10 @@ public void initDefaultCommand() {
2526

2627

2728
/**
29+
* runs the motors
2830
*
2931
*/
30-
public void runClimber() {
31-
attachToLift();
32-
attachToBar();
33-
goUp();
32+
public void runClimber(double speed) {
3433

3534
}
3635

@@ -42,13 +41,6 @@ public void attachToLift() {
4241

4342
}
4443

45-
/**
46-
* winches upwards
47-
*/
48-
public void goUp() {
49-
50-
}
51-
5244
/**
5345
* attaches hook to bar and releases it from the lift
5446
*/
@@ -60,7 +52,7 @@ public void attachToBar() {
6052
* stops the climber
6153
*/
6254
public void stopClimber() {
63-
climberMotors.stopMotor();
55+
climberMotor.stopMotor();
6456
}
6557

6658

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/ClimberInterface.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@ public interface ClimberInterface {
88
public void initDefaultCommand();
99

1010
/**
11-
*
11+
* runs the motors
1212
*/
13-
public void runClimber();
13+
public void runClimber(double speed);
1414

1515
/**
1616
* attaches the climber hook to the lift.
1717
* Requires that Lift is on the ground
1818
*/
1919
public void attachToLift();
2020

21-
/**
22-
* winches upwards
23-
*/
24-
public void goUp();
25-
2621
/**
2722
* attaches hook to bar and releases it from the lift
2823
*/

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEject.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import org.usfirst.frc.team199.Robot2018.RobotMap;
44

5-
import edu.wpi.first.wpilibj.SpeedController;
5+
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
6+
67
import edu.wpi.first.wpilibj.command.Subsystem;
78

89
/**
910
*
1011
*/
1112
public class IntakeEject extends Subsystem implements IntakeEjectInterface {
1213

13-
private final SpeedController intakeMotors = RobotMap.intakeMotors;
14+
private final WPI_TalonSRX intakeMotor = RobotMap.intakeMotor;
1415

1516

1617

@@ -25,15 +26,15 @@ public void initDefaultCommand() {
2526
/**
2627
* returns current motor value
2728
*/
28-
public double getIntake() {
29-
return intakeMotors.get();
29+
public double getIntakeSpeed() {
30+
return intakeMotor.get();
3031
}
3132

3233
/**
3334
* Uses (insert sensor here) to detect
3435
* a cube in front of the robot.
3536
*/
36-
public boolean detectCube() {
37+
public boolean seeCube() {
3738
return false;
3839
}
3940

@@ -51,7 +52,7 @@ public boolean hasCube() {
5152
*
5253
*/
5354
public void stopIntake() {
54-
intakeMotors.stopMotor();
55+
intakeMotor.stopMotor();
5556
}
5657

5758
/**

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEjectInterface.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public interface IntakeEjectInterface {
1010
/**
1111
* returns current motor value
1212
*/
13-
public double getIntake();
13+
public double getIntakeSpeed();
1414

1515
/**
1616
* Uses (insert sensor here) to detect
1717
* a cube in front of the robot.
1818
*/
19-
public boolean detectCube();
19+
public boolean seeCube();
2020

2121
/**
2222
* Uses (insert sensor here) to detect if

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/Lift.java

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import org.usfirst.frc.team199.Robot2018.RobotMap;
44

5-
import edu.wpi.first.wpilibj.SpeedController;
5+
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
6+
67
import edu.wpi.first.wpilibj.command.Subsystem;
78

89
/**
910
*
1011
*/
1112
public class Lift extends Subsystem implements LiftInterface {
1213

13-
private final SpeedController liftMotors = RobotMap.liftMotors;
14+
private final WPI_TalonSRX liftMotor = RobotMap.liftMotor;
15+
16+
private Position targetPosition = Position.GROUND;
1417

1518
/**
1619
* Set the default command for a subsystem here.
@@ -19,56 +22,41 @@ public void initDefaultCommand() {
1922
// Set the default command for a subsystem here.
2023
//setDefaultCommand(new MySpecialCommand());
2124
}
25+
26+
public void setTargetPosition(Position newPosition) {
27+
targetPosition = newPosition;
28+
}
2229

2330
/**
24-
* Uses (insert sensor here) to detect the distance above the ground
31+
* Uses (insert sensor here) to detect the current lift position
2532
*/
26-
public double getDistance() {
33+
public double getHeight() {
2734
return -1;
2835
}
2936

3037
/**
3138
* stops the lift
3239
*/
3340
public void stopLift() {
34-
liftMotors.stopMotor();
41+
liftMotor.stopMotor();
3542
}
3643

3744
/**
3845
* gets current motor values
3946
*/
40-
public double getLift() {
41-
return liftMotors.get();
47+
public double getLiftSpeed() {
48+
return liftMotor.get();
4249
}
4350

4451
/**
45-
* goes to the bottom
52+
* Goes to specified height
53+
* @param position - ground, switch, scale, bar
54+
* @param offset - distance up or down from the position
4655
*/
47-
public void goToGround() {
56+
public void goToPosition(Position position, double offset) {
4857

4958
}
5059

51-
/**
52-
* goes to switch height
53-
*/
54-
public void goToSwitch() {
55-
56-
}
57-
58-
/**
59-
* goes to scale height
60-
* @param offset - the distance up or down from standard scale height
61-
*/
62-
public void goToScale(double offset) {
63-
64-
}
65-
66-
/**
67-
* goes to bar height
68-
*/
69-
public void goToBar() {
70-
71-
}
7260

7361
}
7462

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/LiftInterface.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ public interface LiftInterface {
77
* */
88
public void initDefaultCommand();
99

10+
public enum Position {
11+
GROUND,
12+
SWITCH,
13+
SCALE,
14+
BAR
15+
}
16+
1017
/**
11-
* Uses (insert sensor here) to detect the distance above the ground
18+
* Uses (insert sensor here) to detect the current lift position
1219
*/
13-
public double getDistance();
20+
public double getHeight();
1421

1522
/**
1623
* stops the lift
@@ -20,27 +27,15 @@ public interface LiftInterface {
2027
/**
2128
* gets current motor values
2229
*/
23-
public double getLift();
24-
25-
/**
26-
* goes to the bottom
27-
*/
28-
public void goToGround();
30+
public double getLiftSpeed();
2931

30-
/**
31-
* goes to switch height
32-
*/
33-
public void goToSwitch();
3432

3533
/**
36-
* goes to scale height
37-
* @param offset - the distance up or down from standard scale height
34+
* Goes to specified height
35+
* @param position - ground, switch, scale, bar
36+
* @param offset - distance up or down from position
3837
*/
39-
public void goToScale(double offset);
38+
public void goToPosition(Position position, double offset);
4039

41-
/**
42-
* goes to bar height
43-
*/
44-
public void goToBar();
4540

4641
}

0 commit comments

Comments
 (0)