Skip to content

Commit ad72b1f

Browse files
committed
Resolve merge conflict in OI.java using the auto-importer
2 parents ca26712 + b1a6e3f commit ad72b1f

8 files changed

Lines changed: 113 additions & 22 deletions

File tree

Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import java.io.IOException;
88
import java.io.Reader;
99
import java.util.ArrayList;
10+
import java.util.Arrays;
1011
import java.util.List;
1112

1213
import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
14+
import org.apache.commons.math3.linear.SingularMatrixException;
1315
import org.apache.commons.lang3.ArrayUtils;
1416
import org.apache.commons.csv.CSVRecord;
1517
import org.apache.commons.csv.CSVFormat;
@@ -64,9 +66,14 @@ public static void ordinaryLeastSquares(String file1, String file2, String outfi
6466
ys[i] = voltages[i];
6567
}
6668

67-
algorithm = new OLSMultipleLinearRegression();
68-
algorithm.newSampleData(ys, xs);
69-
params = algorithm.estimateRegressionParameters();
69+
try {
70+
algorithm = new OLSMultipleLinearRegression();
71+
algorithm.newSampleData(ys, xs);
72+
params = algorithm.estimateRegressionParameters();
73+
} catch (SingularMatrixException e) {
74+
System.out.println(Arrays.deepToString(xs));
75+
System.out.println(Arrays.toString(ys));
76+
}
7077
// System.out.println(params.length);
7178
rightKv = params[1];
7279
rightKa = params[2];

Robot2019/src/main/java/frc/robot/OI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import frc.robot.commands.EjectCargo;
1717
import frc.robot.commands.IntakeOnlyCargo;
1818
import frc.robot.commands.NormalDrive;
19+
import frc.robot.commands.ResetWobble;
1920
import frc.robot.commands.SetArcadeOrTank;
2021
import frc.robot.commands.SlowDrive;
2122
import frc.robot.commands.ToggleCamera;
@@ -57,7 +58,8 @@ public class OI {
5758
rightSlowBtn = new JoystickButton(rightJoy, 1);
5859
rightSlowBtn.whileHeld(new SlowDrive(SlowDrive.Side.RIGHT));
5960
wobbleDriveBtn = new JoystickButton(rightJoy, 4); // TODO: confirm button with drivers
60-
wobbleDriveBtn.whileHeld(new WobbleDrive(dt));
61+
wobbleDriveBtn.whenPressed(new WobbleDrive(dt));
62+
wobbleDriveBtn.whenReleased(new ResetWobble(dt));
6163

6264
arcadeOrTankBtn = new JoystickButton(leftJoy, 4);
6365
arcadeOrTankBtn.whenPressed(new SetArcadeOrTank());

Robot2019/src/main/java/frc/robot/RobotMap.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ private static WPI_TalonSRX createConfiguredTalon(int port) {
124124
catchError(tsrx.configNeutralDeadband(0.001, 10));
125125
tsrx.setNeutralMode(NeutralMode.Brake);
126126

127-
ecDeadband = tsrx.configNeutralDeadband(0.001, 10);
128-
if (!ecDeadband.equals(ErrorCode.OK)) {
129-
throw new RuntimeException(ecDeadband.toString());
130-
}
131-
132127
return tsrx;
133128
}
134129

@@ -144,11 +139,6 @@ private static WPI_VictorSPX createConfiguredVictor(int port) {
144139
catchError(vspx.configNeutralDeadband(0.001, 10));
145140
vspx.setNeutralMode(NeutralMode.Brake);
146141

147-
ecDeadband = vspx.configNeutralDeadband(0.001, 10);
148-
if (!ecDeadband.equals(ErrorCode.OK)) {
149-
throw new RuntimeException(ecDeadband.toString());
150-
}
151-
152142
return vspx;
153143
}
154144

Robot2019/src/main/java/frc/robot/commands/Climb.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ public class Climb extends Command {
1919
private State state;
2020

2121
private final double backDrive = -0.5; // TODO: Set this to reasonable/tested value;
22-
private final double climbUp = 0.5; // TODO: Set this to reasonable/tested value;
23-
private final double climbDown = -0.5; // TODO: Set this to reasonable/tested value;
24-
private final double retract = -0.5; // TODO: Set this to reasonable/tested value;
22+
private final double climbUp = 1;
23+
private final double climbDown = -1;
24+
private final double retract = -1;
2525
private final double overrideThreshold = 0.1; // TODO: Set this to reasonable/tested value;
2626
private final double retractGoal = 0; // TODO: Set this to reasonable/tested value;
27+
private final double offGroundHeight = 10; // TODO: Set this to reasonable/tested value;
2728

2829
public Climb(Climber climber, Drivetrain dt, Joystick joy) {
2930
// Use requires() here to declare subsystem dependencies
@@ -102,7 +103,7 @@ protected void interrupted() {
102103
* overriding the climb
103104
*/
104105
private boolean robotOnPlatform() {
105-
return dt.isStalled() || Math.abs(dtJoy.getY()) > overrideThreshold;
106+
return (dt.isStalled() && climber.getEncDistance() > offGroundHeight) || Math.abs(dtJoy.getY()) > overrideThreshold;
106107
}
107108

108109
private enum State {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 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+
8+
package frc.robot.commands;
9+
10+
import edu.wpi.first.wpilibj.command.InstantCommand;
11+
import frc.robot.subsystems.Drivetrain;
12+
13+
/**
14+
* Add your docs here.
15+
*/
16+
public class ResetWobble extends InstantCommand {
17+
/**
18+
* Add your docs here.
19+
*/
20+
Drivetrain dt;
21+
public ResetWobble(Drivetrain dt) {
22+
super();
23+
// Use requires() here to declare subsystem dependencies
24+
// eg. requires(chassis);
25+
this.dt = dt;
26+
}
27+
28+
// Called once when the command executes
29+
@Override
30+
protected void initialize() {
31+
dt.setWobbleDone(true);
32+
}
33+
34+
}

Robot2019/src/main/java/frc/robot/commands/SetArcadeOrTank.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public SetArcadeOrTank() {
88

99
}
1010

11+
@Override
1112
protected void initialize() {
1213
if (SmartDashboard.getBoolean("Arcade Drive", true)) {
1314
SmartDashboard.putBoolean("Arcade Drive", false);

Robot2019/src/main/java/frc/robot/commands/WobbleDrive.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99

1010
import edu.wpi.first.wpilibj.Timer;
1111
import edu.wpi.first.wpilibj.command.Command;
12+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1213
import frc.robot.subsystems.Drivetrain;
1314
import frc.robot.subsystems.Drivetrain.Side;
1415

1516
public class WobbleDrive extends Command {
1617
Drivetrain dt;
1718
Side side = Side.LEFT; // We start with left side. TODO: confirm this
1819
Timer tim;
19-
private final double wobbleTime = 0.75; // TODO: Set to actual number
20-
private final double driveSpeed = 0.5; // TODO: Set to actual number
20+
boolean leftSideDone;
21+
boolean rightSideDone;
22+
private final double minTime = 0.2;
23+
private final double wobbleTime = 0.3; // TODO: Set to actual number
24+
private final double driveSpeed = 0.3; // TODO: Set to actual number
25+
private final double encRateTolerance = 1; // TODO: Set to actual number
2126

2227
public WobbleDrive(Drivetrain dt) {
2328
// Use requires() here to declare subsystem dependencies
@@ -32,12 +37,35 @@ protected void initialize() {
3237
tim = new Timer();
3338
tim.reset();
3439
tim.start();
40+
dt.setWobbleDone(false);
41+
leftSideDone = false;
42+
rightSideDone = false;
43+
SmartDashboard.putBoolean("Wobble drive done", false);
3544
}
3645

3746
// Called repeatedly when this Command is scheduled to run
3847
@Override
3948
protected void execute() {
40-
if (tim.get() > wobbleTime) {
49+
boolean done = dt.getEncRate(Side.LEFT) < encRateTolerance && dt.getEncRate(Side.RIGHT) < encRateTolerance;
50+
if (tim.get() > minTime) {
51+
if (side == Side.LEFT) {
52+
leftSideDone = done;
53+
} else {
54+
rightSideDone = done;
55+
}
56+
}
57+
if (leftSideDone) {
58+
tim.reset();
59+
tim.start();
60+
side = Side.RIGHT;
61+
}
62+
if (rightSideDone) {
63+
tim.reset();
64+
tim.start();
65+
side = Side.LEFT;
66+
}
67+
68+
if (tim.get() > wobbleTime && (!leftSideDone && !rightSideDone)) {
4169
if (side == Side.LEFT) {
4270
side = Side.RIGHT;
4371
} else {
@@ -54,13 +82,14 @@ protected void execute() {
5482
// Make this return true when this Command no longer needs to run execute()
5583
@Override
5684
protected boolean isFinished() {
57-
return false;
85+
return dt.wobbleDone() || (leftSideDone && rightSideDone);
5886
}
5987

6088
// Called once after isFinished returns true
6189
@Override
6290
protected void end() {
6391
dt.stop();
92+
SmartDashboard.putBoolean("Wobble drive done", true);
6493
}
6594

6695
// Called when another command which requires one or more of the same

Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public enum Direction {
4040
private double blKV, blKA, blVI;
4141
private double brKV, brKA, brVI;
4242

43+
private boolean wobbleDone;
44+
4345
public Drivetrain(WPI_TalonSRX leftMaster, BaseMotorController leftSlave1, BaseMotorController leftSlave2,
4446
WPI_TalonSRX rightMaster, BaseMotorController rightSlave1, BaseMotorController rightSlave2, Encoder leftEnc,
4547
Encoder rightEnc, AHRS ahrs) {
@@ -71,6 +73,7 @@ public Drivetrain(WPI_TalonSRX leftMaster, BaseMotorController leftSlave1, BaseM
7173
updateDrivetrainParameters();
7274

7375
maxVoltage = 12.0;
76+
wobbleDone = false;
7477
}
7578

7679
/**
@@ -125,6 +128,14 @@ public double getGyroAngle() {
125128
return ahrs.getYaw();
126129
}
127130

131+
public void setWobbleDone(boolean set) {
132+
wobbleDone = set;
133+
}
134+
135+
public boolean wobbleDone() {
136+
return wobbleDone;
137+
}
138+
128139
public double getMaxSpeed() { // Return must be adjusted in the future;
129140
return 13 * 12;
130141
}
@@ -198,6 +209,22 @@ public void updateDrivetrainParameters() {
198209
blKA = avg;
199210
brKA = avg;
200211
} catch (FileNotFoundException e) {
212+
flKV = 0.06369046755507658;
213+
flKA = 0.0215894793277297;
214+
flVI = 0.8403701236277824;
215+
216+
frKV = 0.0619423013628032;
217+
frKA = 0.04044703465602449;
218+
frVI = 0.810212379284332;
219+
220+
blKV = 0.06388520699977113;
221+
blKA = 0.025492804438184545;
222+
blVI = 0.8071078220643216;
223+
224+
brKV = 0.06140765089854154;
225+
brKA = 0.042046502553651215;
226+
brVI = 0.7929289166816246;
227+
201228
e.printStackTrace();
202229
}
203230
}

0 commit comments

Comments
 (0)