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

Commit 507e4e7

Browse files
committed
2 parents 645330d + a6a1bc6 commit 507e4e7

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

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

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
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+
/*----------------------------------------------------------------------------*/
17

28
package org.usfirst.frc.team199.Robot2018;
39

@@ -41,13 +47,13 @@ public class Robot extends TimedRobot {
4147
public static Listener listen;
4248

4349
public static OI oi;
44-
50+
4551
public static Map<String, ArrayList<String[]>> autoScripts;
4652

4753
Command autonomousCommand;
4854
SendableChooser<Position> posChooser = new SendableChooser<Position>();
4955
Map<String, SendableChooser<Strategy>> stratChoosers = new HashMap<String, SendableChooser<Strategy>>();
50-
String[] fmsPossibilities = {"LL", "LR", "RL", "RR"};
56+
String[] fmsPossibilities = { "LL", "LR", "RL", "RR" };
5157

5258
public static double getConst(String key, double def) {
5359
if (!SmartDashboard.containsKey("Const/" + key)) {
@@ -64,8 +70,8 @@ public static boolean getBool(String key, boolean def) {
6470
}
6571

6672
/**
67-
* This function is run when the robot is first started up and should be used
68-
* for any initialization code.
73+
* This function is run when the robot is first started up and should be
74+
* used for any initialization code.
6975
*/
7076
@Override
7177
public void robotInit() {
@@ -76,13 +82,13 @@ public void robotInit() {
7682
lift = new Lift();
7783
dt = new Drivetrain();
7884
oi = new OI();
79-
85+
8086
// auto position chooser
8187
for (Position p : Position.values()) {
8288
posChooser.addObject(p.getSDName(), p);
8389
}
8490
SmartDashboard.putData("Starting Position", posChooser);
85-
91+
8692
// auto strategy choosers
8793
for (String input : fmsPossibilities) {
8894
SendableChooser<Strategy> chooser = new SendableChooser<Strategy>();
@@ -92,20 +98,21 @@ public void robotInit() {
9298
SmartDashboard.putData(input, chooser);
9399
stratChoosers.put(input, chooser);
94100
}
95-
101+
96102
// auto delay chooser
97103
SmartDashboard.putNumber("Auto Delay", 0);
98-
99-
// parse scripts from Preferences, which maintains values throughout reboots
104+
105+
// parse scripts from Preferences, which maintains values throughout
106+
// reboots
100107
autoScripts = AutoUtils.parseScriptFile(Preferences.getInstance().getString("autoscripts", ""));
101108

102109
listen = new Listener();
103110
}
104111

105112
/**
106-
* This function is called once each time the robot enters Disabled mode. You
107-
* can use it to reset any subsystem information you want to clear when the
108-
* robot is disabled.
113+
* This function is called once each time the robot enters Disabled mode.
114+
* You can use it to reset any subsystem information you want to clear when
115+
* the robot is disabled.
109116
*/
110117
@Override
111118
public void disabledInit() {
@@ -118,7 +125,7 @@ public void disabledPeriodic() {
118125
}
119126

120127
/**
121-
* This function is called once during the start of autonomous in order to
128+
* This function is called once during the start of autonomous in order to
122129
* grab values from SmartDashboard and the FMS and call the Autonomous
123130
* command with those values.
124131
*/
@@ -127,14 +134,14 @@ public void autonomousInit() {
127134
String fmsInput = DriverStation.getInstance().getGameSpecificMessage();
128135
Position startPos = posChooser.getSelected();
129136
double autoDelay = SmartDashboard.getNumber("Auto Delay", 0);
130-
137+
131138
Map<String, Strategy> strategies = new HashMap<String, Strategy>();
132139
for (Map.Entry<String, SendableChooser<Strategy>> entry : stratChoosers.entrySet()) {
133-
String key = entry.getKey();
134-
SendableChooser<Strategy> chooser = entry.getValue();
135-
strategies.put(key, chooser.getSelected());
140+
String key = entry.getKey();
141+
SendableChooser<Strategy> chooser = entry.getValue();
142+
strategies.put(key, chooser.getSelected());
136143
}
137-
144+
138145
Autonomous auto = new Autonomous(startPos, strategies, autoDelay, fmsInput, false);
139146
auto.start();
140147
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,20 @@ public class RobotMap {
6868
* the TalonSRX to configure
6969
*/
7070
private void configSRX(WPI_TalonSRX mc) {
71+
// stuff cole said to put
7172
int kTimeout = (int) Robot.getConst("kTimeoutMs", 10);
7273
mc.configNominalOutputForward(0, kTimeout);
7374
mc.configNominalOutputReverse(0, kTimeout);
7475
mc.configPeakOutputForward(1, kTimeout);
7576
mc.configPeakOutputReverse(-1, kTimeout);
77+
78+
// current limiting stuff cole said to put
79+
mc.configPeakCurrentLimit(0, 0);
80+
mc.configPeakCurrentDuration(0, 0);
81+
// 40 amps is the amp limit of a CIM. also, the PDP has 40 amp circuit breakers,
82+
// so if we went above 40, the motors would stop completely.
83+
mc.configContinuousCurrentLimit(40, 0);
84+
mc.enableCurrentLimit(true);
7685
}
7786

7887
/**
@@ -83,6 +92,7 @@ private void configSRX(WPI_TalonSRX mc) {
8392
* the VictorSPX to configure
8493
*/
8594
private void configSPX(WPI_VictorSPX mc) {
95+
// stuff cole said to put
8696
int kTimeout = (int) Robot.getConst("kTimeoutMs", 10);
8797
mc.configNominalOutputForward(0, kTimeout);
8898
mc.configNominalOutputReverse(0, kTimeout);

Robot2018/test/org/usfirst/frc/team199/Robot2018/ParseScriptFileTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ void test8() {
108108
@Test
109109
void test9() {
110110
String input = "RRxx:\n"
111-
+ "moveto (42,56) 45\n"
111+
+ "moveto (42,56) 45 # Trailing comment should not break anything \n"
112112
+ "scale\n"
113-
+ "move 46\n"
113+
+ "#move 10\n" // For testing that commented lines are ignored
114+
+ "move 46\n"
114115
+ "LRxx:\n"
115116
+ "intake\n"
116117
+ "turn (32,5)\n";

0 commit comments

Comments
 (0)