Create Autonomous#22
Conversation
I don't actually really know what the actual specs of the shooter are. This was mostly made as a tutorial to git for the rest of the SPEC team.
Codecov Report
@@ Coverage Diff @@
## master #22 +/- ##
===========================================
- Coverage 9.74% 7.42% -2.33%
Complexity 17 17
===========================================
Files 18 22 +4
Lines 677 889 +212
Branches 44 80 +36
===========================================
Hits 66 66
- Misses 611 823 +212
|
| } | ||
| } else if(u.equals(AutoInstruction.Unit.CURRENT)) { | ||
| //amount: motor current to stop at | ||
| if(driveCurrent(ai.args.get(0), ai.args.get(0), ai.amount)) { |
There was a problem hiding this comment.
Merge this if statement with the enclosing one.
| * Creates a JsonAutonomous from the specified file | ||
| * @param file The location of the file to parse | ||
| */ | ||
| public JsonAutonomous(String file, LoggableGyro gyro, Drivetrain drive, Shooter shooter, Manipulation manipulation) { |
There was a problem hiding this comment.
Line is longer than 100 characters (found 121).
| } | ||
| } | ||
|
|
||
| private void shoot(AutoInstruction ai) { |
There was a problem hiding this comment.
Method shoot has 30 lines of code (exceeds 25 allowed). Consider refactoring.
| } | ||
| } else if(u.equals(AutoInstruction.Unit.FEET) || u.equals(AutoInstruction.Unit.INCHES)) { | ||
| //amount: feet/inches to drive | ||
| if(driveDistance(ai.args.get(0), ai.args.get(0), (u.equals(AutoInstruction.Unit.INCHES) ? ai.amount * TICKS_PER_INCH : (ai.amount * TICKS_PER_INCH) * 12))) { |
There was a problem hiding this comment.
Line is longer than 100 characters (found 169).
| public void autonomousInit() { | ||
| gyro.reset(); | ||
|
|
||
| auto = new JsonAutonomous("/home/lvuser/deploy/autos/auto-test.json", gyro, drive, shooter, manipulation); |
There was a problem hiding this comment.
Line is longer than 100 characters (found 114).
| if(drive.getAverageCurrent() < current) { | ||
| drive.drive(leftPower, rightPower, false); | ||
| } else { | ||
| //drive.drive(0, 0); |
There was a problem hiding this comment.
This block of commented-out lines of code should be removed.
| } | ||
|
|
||
| private void shoot(AutoInstruction ai) { | ||
| AutoInstruction.Unit u = ai.unit; |
There was a problem hiding this comment.
Remove this useless assignment to local variable "u".
| private void shoot(AutoInstruction ai) { | ||
| AutoInstruction.Unit u = ai.unit; | ||
| System.out.println(shooter.getSpeed()); | ||
| //shooter.setPower(SHOOTER_SPEED); |
There was a problem hiding this comment.
This block of commented-out lines of code should be removed.
|
|
||
| private static final double TICKS_PER_ROTATION = 16750; //TODO: Update value for 2022 robot | ||
| private static final double TICKS_PER_INCH = TICKS_PER_ROTATION / (6 * Math.PI); //TODO: Update formula for 2022 robot | ||
| private static final double SHOOTER_SPEED = 1; |
There was a problem hiding this comment.
Remove this unused "SHOOTER_SPEED" private field.
| private Drivetrain drive; | ||
|
|
||
| private Shooter shooter; | ||
| private Manipulation manipulation; |
There was a problem hiding this comment.
Remove this unused "manipulation" private field.
| return false; | ||
| } | ||
|
|
||
| public boolean driveCurrent(double leftPower, double rightPower, double current) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| return false; | ||
| } | ||
|
|
||
| private boolean driveTime(double leftPower, double rightPower, double time) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| public void drive(double leftSpeed, double rightSpeed) { // Probably implement deadbands later | ||
| left.setSpeed(leftSpeed); | ||
| right.setSpeed(rightSpeed); | ||
| public void drive(double leftValue, double rightValue, boolean power) { // Probably implement deadbands later |
There was a problem hiding this comment.
Line is longer than 100 characters (found 113).
|
|
||
| public class Shooter implements Loggable { | ||
| TalonFX shooterMotor; | ||
| Shooter(int shooterID) { |
There was a problem hiding this comment.
'CTOR_DEF' should be separated from previous statement.
| public void autonomousInit() { | ||
| gyro.reset(); | ||
|
|
||
| auto = new JsonAutonomous("/home/lvuser/deploy/autos/shooter-test.json", gyro, drive, shooter, manipulation); |
There was a problem hiding this comment.
Line is longer than 100 characters (found 117).
Co-authored-by: theblindbandet <me@thisismy.computer>
Co-authored-by: theblindbandet <me@thisismy.computer>
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.
| } | ||
| } else if (u.equals(AutoInstruction.Unit.CURRENT)) { | ||
| // amount: motor current to stop at | ||
| if (driveCurrent(ai.args.get(0), ai.args.get(0), ai.amount)) { |
There was a problem hiding this comment.
Merge this if statement with the enclosing one.
| private void shoot(AutoInstruction ai) { | ||
| AutoInstruction.Unit u = ai.unit; | ||
| System.out.println(shooter.getSpeed()); | ||
| // shooter.setPower(SHOOTER_SPEED); |
There was a problem hiding this comment.
This block of commented-out lines of code should be removed.
| if (drive.getAverageCurrent() < current) { | ||
| drive.drive(leftPower, rightPower, false); | ||
| } else { | ||
| // drive.drive(0, 0); |
There was a problem hiding this comment.
This block of commented-out lines of code should be removed.
| System.out.println(shooter.getSpeed()); | ||
| // shooter.setPower(SHOOTER_SPEED); | ||
| /* | ||
| * if(u == AutoInstruction.Unit.SPEED) { if(shooter.getSpeed() < SHOOTER_SPEED) { |
There was a problem hiding this comment.
This block of commented-out lines of code should be removed.
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Method parseFile has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Method parseFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
|
|
||
| public class JsonAutonomous extends Autonomous implements Loggable { | ||
|
|
||
| private static final double TICKS_PER_ROTATION = 16750; // TODO: Update value for 2022 robot |
| public class JsonAutonomous extends Autonomous implements Loggable { | ||
|
|
||
| private static final double TICKS_PER_ROTATION = 16750; // TODO: Update value for 2022 robot | ||
| private static final double TICKS_PER_INCH = TICKS_PER_ROTATION / (6 * Math.PI); // TODO: Update |
Co-authored-by: NotMePipe <mepipeofficial@gmail.com> Co-authored-by: theblindbandet <me@thisismy.computer>
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Refactor this method to reduce its Cognitive Complexity from 26 to the 15 allowed.
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Method parseFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
| parseFile(file); | ||
| } | ||
|
|
||
| public void parseFile(String file) { |
There was a problem hiding this comment.
Method parseFile has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
| reset(); | ||
| } | ||
| } | ||
| } else if (u == AutoInstruction.Unit.POWER) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
| private void shoot(AutoInstruction ai) { | ||
| AutoInstruction.Unit u = ai.unit; | ||
|
|
||
| if (u == AutoInstruction.Unit.SPEED) { |
There was a problem hiding this comment.
Similar blocks of code found in 2 locations. Consider refactoring.
As a plus, it also works in simulations now! Co-authored-by: theblindbandet <me@thisismy.computer>
| @@ -0,0 +1,315 @@ | |||
| package frc.robot; | |||
There was a problem hiding this comment.
File JsonAutonomous.java has 255 lines of code (exceeds 250 allowed). Consider refactoring.
| public void autonomousInit() { | ||
| gyro.reset(); | ||
|
|
||
| auto = new JsonAutonomous(JsonAutonomous.getAutoPath("shooter-test.json"), gyro, drive, shooter, manipulation); |
There was a problem hiding this comment.
Line is longer than 100 characters (found 119).
…into autonomous
|
Code Climate has analyzed commit 94bf62c and detected 36 issues on this pull request. Here's the issue category breakdown:
Note: there are 3 critical issues. The test coverage on the diff in this pull request is 0.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 7.4% (-2.2% change). View more on Code Climate. |
No description provided.