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

Commit 1680ed9

Browse files
committed
set up subsystem interfaces
added some methods and motor controllers to Lift, Climber, and Intake
2 parents fa7085c + 16dd9c3 commit 1680ed9

30 files changed

Lines changed: 1496 additions & 195 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ bin/
22
build/
33
dist/
44
.DS_Store
5+
*auto*
6+
*Auto*

Robot2018/.classpath

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
<classpathentry kind="lib" path="lib/mockito-core-2.13.3.jar"/>
1414
<classpathentry kind="lib" path="lib/byte-buddy-1.7.9.jar"/>
1515
<classpathentry kind="lib" path="lib/objenesis-2.6.jar"/>
16+
<classpathentry kind="lib" path="lib/CTRE_Phoenix-sources.jar"/>
17+
<classpathentry kind="lib" path="lib/CTRE_Phoenix.jar"/>
18+
<classpathentry kind="lib" path="lib/navx_frc.jar"/>
1619
<classpathentry kind="output" path="bin"/>
1720
</classpath>
59.8 KB
Binary file not shown.

Robot2018/lib/CTRE_Phoenix.jar

82.1 KB
Binary file not shown.

Robot2018/lib/navx_frc.jar

107 KB
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package org.usfirst.frc.team199.Robot2018;
2+
3+
import org.usfirst.frc.team199.Robot2018.commands.SetDistancePerPulse;
4+
import org.usfirst.frc.team199.Robot2018.commands.UpdatePIDConstants;
5+
6+
import edu.wpi.first.networktables.EntryListenerFlags;
7+
import edu.wpi.first.networktables.NetworkTable;
8+
import edu.wpi.first.networktables.NetworkTableEntry;
9+
import edu.wpi.first.networktables.NetworkTableValue;
10+
import edu.wpi.first.networktables.TableEntryListener;
11+
import edu.wpi.first.wpilibj.command.Command;
12+
import edu.wpi.first.wpilibj.command.Scheduler;
13+
14+
public class Listener implements TableEntryListener {
15+
16+
private void addCommand(Command com) {
17+
Scheduler.getInstance().add(com);
18+
}
19+
20+
@Override
21+
public void valueChanged(NetworkTable arg0, String arg1, NetworkTableEntry arg2, NetworkTableValue arg3, int arg4) {
22+
if(arg4 == EntryListenerFlags.kNew) return;
23+
switch (arg1) {
24+
case "Const/Distance Per Pulse Left":
25+
addCommand(new SetDistancePerPulse());
26+
break;
27+
case "Const/Distance Per Pulse Right":
28+
addCommand(new SetDistancePerPulse());
29+
break;
30+
case "Const/TurnkP":
31+
addCommand(new UpdatePIDConstants());
32+
break;
33+
case "Const/TurnkI":
34+
addCommand(new UpdatePIDConstants());
35+
break;
36+
case "Const/TurnkD":
37+
addCommand(new UpdatePIDConstants());
38+
break;
39+
case "Const/MovekP":
40+
addCommand(new UpdatePIDConstants());
41+
break;
42+
case "Const/MovekI":
43+
addCommand(new UpdatePIDConstants());
44+
break;
45+
case "Const/MovekD":
46+
addCommand(new UpdatePIDConstants());
47+
break;
48+
49+
}
50+
}
51+
52+
}

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

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
18
package org.usfirst.frc.team199.Robot2018;
29

3-
import edu.wpi.first.wpilibj.buttons.Button;
10+
import org.usfirst.frc.team199.Robot2018.commands.PIDMove;
11+
import org.usfirst.frc.team199.Robot2018.commands.PIDTurn;
12+
import org.usfirst.frc.team199.Robot2018.commands.SetDistancePerPulse;
13+
import org.usfirst.frc.team199.Robot2018.commands.ShiftDriveType;
14+
import org.usfirst.frc.team199.Robot2018.commands.ShiftHighGear;
15+
import org.usfirst.frc.team199.Robot2018.commands.ShiftLowGear;
16+
import org.usfirst.frc.team199.Robot2018.commands.UpdatePIDConstants;
17+
18+
import edu.wpi.first.wpilibj.Joystick;
19+
import edu.wpi.first.wpilibj.buttons.JoystickButton;
20+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
421

522
/**
623
* This class is the glue that binds the controls on the physical operator
@@ -34,4 +51,44 @@ public class OI {
3451
// Start the command when the button is released and let it run the command
3552
// until it is finished as determined by it's isFinished method.
3653
// button.whenReleased(new ExampleCommand());
54+
55+
public Joystick leftJoy;
56+
private JoystickButton shiftLowGear;
57+
private JoystickButton shiftHighGear;
58+
private JoystickButton shiftDriveType;
59+
private JoystickButton PIDMove;
60+
private JoystickButton PIDTurn;
61+
public Joystick rightJoy;
62+
private JoystickButton updatePidConstants;
63+
private JoystickButton updateEncoderDPP;
64+
public Joystick manipulator;
65+
66+
public int getButton(String key, int def) {
67+
if (!SmartDashboard.containsKey("Button/" + key)) {
68+
SmartDashboard.putNumber("Button/" + key, def);
69+
}
70+
return (int) SmartDashboard.getNumber("Button/" + key, def);
71+
}
72+
73+
public OI() {
74+
leftJoy = new Joystick(0);
75+
shiftLowGear = new JoystickButton(leftJoy, getButton("Shift Low Gear", 3));
76+
shiftLowGear.whenPressed(new ShiftLowGear());
77+
shiftHighGear = new JoystickButton(leftJoy, getButton("Shift High Gear", 5));
78+
shiftHighGear.whenPressed(new ShiftHighGear());
79+
shiftDriveType = new JoystickButton(leftJoy, getButton("Shift Drive Type", 2));
80+
shiftDriveType.whenPressed(new ShiftDriveType());
81+
PIDMove = new JoystickButton(leftJoy, getButton("PID Move", 7));
82+
PIDMove.whenPressed(new PIDMove(40, Robot.dt));
83+
PIDTurn = new JoystickButton(leftJoy, getButton("PID Turn", 8));
84+
PIDTurn.whenPressed(new PIDTurn(30, Robot.dt));
85+
86+
rightJoy = new Joystick(1);
87+
updatePidConstants = new JoystickButton(rightJoy, getButton("Get PID Constants", 8));
88+
updatePidConstants.whenPressed(new UpdatePIDConstants());
89+
updateEncoderDPP = new JoystickButton(rightJoy, getButton("Get Encoder Dist Per Pulse", 9));
90+
updateEncoderDPP.whenPressed(new SetDistancePerPulse());
91+
92+
manipulator = new Joystick(2);
93+
}
3794
}

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

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import org.usfirst.frc.team199.Robot2018.subsystems.Climber;
55
import org.usfirst.frc.team199.Robot2018.subsystems.ClimberAssist;
6+
import org.usfirst.frc.team199.Robot2018.subsystems.Drivetrain;
67
import org.usfirst.frc.team199.Robot2018.subsystems.IntakeEject;
8+
import org.usfirst.frc.team199.Robot2018.subsystems.LeftDrive;
79
import org.usfirst.frc.team199.Robot2018.subsystems.Lift;
10+
import org.usfirst.frc.team199.Robot2018.subsystems.RightDrive;
811

9-
import edu.wpi.first.wpilibj.IterativeRobot;
1012
import edu.wpi.first.wpilibj.TimedRobot;
1113
import edu.wpi.first.wpilibj.command.Command;
1214
import edu.wpi.first.wpilibj.command.Scheduler;
13-
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
1415
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
1516
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1617

@@ -22,31 +23,60 @@
2223
* directory.
2324
*/
2425
public class Robot extends TimedRobot {
25-
26-
public static final Climber climber = new Climber();
27-
public static final ClimberAssist climberAssist = new ClimberAssist();
28-
public static final IntakeEject intakeEject = new IntakeEject();
29-
public static final Lift lift = new Lift();
26+
27+
public static Climber climber;
28+
public static ClimberAssist climberAssist;
29+
public static IntakeEject intakeEject;
30+
public static Lift lift;
31+
public static RobotMap rmap;
32+
public static Drivetrain dt;
33+
public static LeftDrive ld;
34+
public static RightDrive rd;
35+
public static Listener listen;
36+
3037
public static OI oi;
3138

3239
Command autonomousCommand;
3340
SendableChooser<Command> chooser = new SendableChooser<>();
3441

42+
public static double getConst(String key, double def) {
43+
if (!SmartDashboard.containsKey("Const/" + key)) {
44+
SmartDashboard.putNumber("Const/" + key, def);
45+
}
46+
return SmartDashboard.getNumber("Const/" + key, def);
47+
}
48+
49+
public static boolean getBool(String key, boolean def) {
50+
if (!SmartDashboard.containsKey("Bool/" + key)) {
51+
SmartDashboard.putBoolean("Bool/" + key, def);
52+
}
53+
return SmartDashboard.getBoolean("Bool/" + key, def);
54+
}
55+
3556
/**
36-
* This function is run when the robot is first started up and should be
37-
* used for any initialization code.
57+
* This function is run when the robot is first started up and should be used
58+
* for any initialization code.
3859
*/
3960
@Override
4061
public void robotInit() {
62+
rmap = new RobotMap();
63+
climber = new Climber();
64+
climberAssist = new ClimberAssist();
65+
intakeEject = new IntakeEject();
66+
lift = new Lift();
67+
dt = new Drivetrain();
68+
ld = new LeftDrive();
69+
rd = new RightDrive();
4170
oi = new OI();
71+
listen = new Listener();
4272
// chooser.addObject("My Auto", new MyAutoCommand());
4373
SmartDashboard.putData("Auto mode", chooser);
4474
}
4575

4676
/**
47-
* This function is called once each time the robot enters Disabled mode.
48-
* You can use it to reset any subsystem information you want to clear when
49-
* the robot is disabled.
77+
* This function is called once each time the robot enters Disabled mode. You
78+
* can use it to reset any subsystem information you want to clear when the
79+
* robot is disabled.
5080
*/
5181
@Override
5282
public void disabledInit() {
@@ -60,24 +90,24 @@ public void disabledPeriodic() {
6090

6191
/**
6292
* This autonomous (along with the chooser code above) shows how to select
63-
* between different autonomous modes using the dashboard. The sendable
64-
* chooser code works with the Java SmartDashboard. If you prefer the
65-
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
66-
* getString code to get the auto name from the text box below the Gyro
93+
* between different autonomous modes using the dashboard. The sendable chooser
94+
* code works with the Java SmartDashboard. If you prefer the LabVIEW Dashboard,
95+
* remove all of the chooser code and uncomment the getString code to get the
96+
* auto name from the text box below the Gyro
6797
*
6898
* You can add additional auto modes by adding additional commands to the
69-
* chooser code above (like the commented example) or additional comparisons
70-
* to the switch structure below with additional strings & commands.
99+
* chooser code above (like the commented example) or additional comparisons to
100+
* the switch structure below with additional strings & commands.
71101
*/
72102
@Override
73103
public void autonomousInit() {
74104
autonomousCommand = chooser.getSelected();
75105

76106
/*
77-
* String autoSelected = SmartDashboard.getString("Auto Selector",
78-
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
79-
* = new MyAutoCommand(); break; case "Default Auto": default:
80-
* autonomousCommand = new ExampleCommand(); break; }
107+
* String autoSelected = SmartDashboard.getString("Auto Selector", "Default");
108+
* switch(autoSelected) { case "My Auto": autonomousCommand = new
109+
* MyAutoCommand(); break; case "Default Auto": default: autonomousCommand = new
110+
* ExampleCommand(); break; }
81111
*/
82112

83113
// schedule the autonomous command (example)

0 commit comments

Comments
 (0)