org.usfirst.frc.team3695.robot.auto.CommandGroupAuto   A
last analyzed

Complexity

Total Complexity 25

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 111
rs 10
c 1
b 0
f 0
wmc 25

1 Method

Rating   Name   Duplication   Size   Complexity  
F CommandGroupAuto(Position,Goal) 0 106 25
1
package org.usfirst.frc.team3695.robot.auto;
2
3
import edu.wpi.first.wpilibj.DriverStation;
4
import edu.wpi.first.wpilibj.command.CommandGroup;
5
import org.usfirst.frc.team3695.robot.Robot;
6
import org.usfirst.frc.team3695.robot.commands.CyborgCommandDriveDistance;
7
import org.usfirst.frc.team3695.robot.commands.CyborgCommandDriveUntilError;
8
import org.usfirst.frc.team3695.robot.commands.CyborgCommandRotateDegrees;
9
import org.usfirst.frc.team3695.robot.enumeration.Goal;
10
import org.usfirst.frc.team3695.robot.enumeration.Position;
11
12
import static org.usfirst.frc.team3695.robot.Constants.AutonomousConstants;
13
14
/** the sequence of commands for autonomous */
15
public class CommandGroupAuto extends CommandGroup {
16
17
	//Stores the states of the switches and scale
18
	String gameData;
19
20
	public CommandGroupAuto(Position position, Goal goal) {
21
		//Get the state of the switches and scale for each round
22
		gameData = DriverStation.getInstance().getGameSpecificMessage();
23
24
		// make sure everything is in the right state/position up here
25
		Robot.SUB_CLAMP.closeArms();
26
27
28
		// EX: making sure flap is closed before auto starts
29
		switch (position) {
30
			case LEFT:
31
				switch (goal){
32
					case RUN_FOR_IT:
33
						addSequential(new CyborgCommandDriveUntilError());
34
						break;
35
					case SWITCH:
36
						if (gameData.charAt(0) == 'L'){ //When the switch is on the left
37
							addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_TO_SWITCH_FROM_SIDE));
38
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_CLOCKWISE));
39
							Robot.SUB_MANIPULATOR.spit();
40
						} else { //When the switch is on the right
41
42
						}
43
						Robot.SUB_MANIPULATOR.spit();
44
						break;
45
					case ENEMY_SWITCH:
46
                        if (gameData.charAt(2) == 'L'){ //When switch is on the left
0 ignored issues
show
Comprehensibility introduced by
Consider assigning this magic number 2 to a constant.

Using constants for hard-coded numbers is a best practice. A constant’s name can explain the rationale behind this magic number. It is also easier to find if you ever need to change it.

Loading history...
47
48
                        } else { //When switch is on the right
49
50
                        }
51
						break;
52
					case SCALE:
53
						if (gameData.charAt(1) == 'L'){ //When scale is on the left
54
55
						} else { //When scale is on the right
56
57
						}
58
						break;
59
					
60
					case BEST_OPTION:
61
						break;
62
				}
63
				break;
64
65
			case CENTER:
66
				switch (goal){
67
					case RUN_FOR_IT:
68
						addSequential(new CyborgCommandDriveUntilError());
69
						break;
70
					case SWITCH:
71
						addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_PASS_PORTAL));
72
						if (gameData.charAt(0) == 'L'){ //When the switch is on the left
73
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_COUNTERCLOCKWISE));
74
							addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_CENTER_LINE_SWITCH_ALIGN));
75
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_CLOCKWISE));
76
							addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_WALL_TO_BLOCKS
77
																				+ AutonomousConstants.DIST_BLOCKS_TO_SWITCH
78
																				- AutonomousConstants.DIST_PASS_PORTAL));
79
80
						} else { //When the switch is on the right
81
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_CLOCKWISE));
82
							addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_CENTER_LINE_SWITCH_ALIGN));
83
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_COUNTERCLOCKWISE));
84
				//			addParallel(new CyborgCommandGoToMid());
85
							addSequential(new CyborgCommandDriveDistance(AutonomousConstants.DIST_WALL_TO_BLOCKS
86
																				+ AutonomousConstants.DIST_BLOCKS_TO_SWITCH
87
																				- AutonomousConstants.DIST_PASS_PORTAL));
88
						}
89
						break;
90
					case ENEMY_SWITCH:
91
						break;
92
					case SCALE:
0 ignored issues
show
Bug introduced by
Your code has two case statements with the same code. Consider merging these statements to make the code more readable and easier to maintain.

case statements can be bundled like this:

switch (s) {
    case "A":
    case "B":
        doSomething();
    break;
}
Loading history...
93
						break;
94
					case BEST_OPTION:
0 ignored issues
show
Bug introduced by
Your code has two case statements with the same code. Consider merging these statements to make the code more readable and easier to maintain.

case statements can be bundled like this:

switch (s) {
    case "A":
    case "B":
        doSomething();
    break;
}
Loading history...
95
						break;
96
			}
97
				break;
98
				
99
			case RIGHT:
100
				switch (goal) {
101
					case RUN_FOR_IT:
102
						addSequential(new CyborgCommandDriveUntilError());
103
						break;
104
					case SWITCH:
105
						if (gameData.charAt(0) == 'R'){ //When the switch is on the right
106
							addParallel(new CyborgCommandDriveDistance(AutonomousConstants.DIST_TO_SWITCH_FROM_SIDE));
107
							addSequential(new CyborgCommandRotateDegrees(AutonomousConstants.ROT_90_COUNTERCLOCKWISE));
108
						} else { //When the switch is on the left
109
110
						}
111
						break;
112
					case ENEMY_SWITCH:
113
114
						break;
115
					case SCALE:
116
						if (gameData.charAt(1) == 'R'){ //When scale is on the right
117
118
						} else { //When scale is on the left
119
120
						}
121
						break;
122
					case BEST_OPTION:
0 ignored issues
show
Bug introduced by
Your code has two case statements with the same code. Consider merging these statements to make the code more readable and easier to maintain.

case statements can be bundled like this:

switch (s) {
    case "A":
    case "B":
        doSomething();
    break;
}
Loading history...
123
						break;
124
				}
125
			break;
126
		}	
127
	}
128
}