Skip to content

Commit 6aca4df

Browse files
Merge pull request #40 from hammerhead226/michingtonak/states-changes
Minchingtonak/states changes
2 parents 8df8d12 + bf1752a commit 6aca4df

File tree

8 files changed

+81
-47
lines changed

8 files changed

+81
-47
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
<classpathentry kind="var" path="USERLIBS_DIR/navx_frc.jar"/>
1414
<classpathentry kind="var" path="USERLIBS_DIR/opencsv-4.1.jar"/>
1515
<classpathentry kind="var" path="USERLIBS_DIR/HammerheadLib-v1.0.jar"/>
16-
<classpathentry kind="var" path="USERLIBS_DIR/SharkMacro-v1.1.2.jar"/>
16+
<classpathentry kind="var" path="USERLIBS_DIR/SharkMacro-v1.1.4.jar"/>
1717
<classpathentry kind="output" path="bin"/>
1818
</classpath>

src/org/usfirst/frc/team226/robot/Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Constants {
44

55
// Arm PID Tolerance
6-
public static final int ARM_ERROR_TOLERANCE = 50;
6+
public static final int ARM_ERROR_TOLERANCE = 10;
77

88
// Arm Soft Limits
99
public static final boolean ARM_FORWARD_LIMIT_ENABLED = false;
@@ -34,7 +34,7 @@ public class Constants {
3434
public static final boolean CLIMBER_CURRENT_LIMIT_ENABLED = false;
3535

3636
// Invert Motors
37-
public static final boolean INTAKE_INVERT_L = true;
37+
public static final boolean INTAKE_INVERT_L = false;
3838
public static final boolean INTAKE_INVERT_R = false;
3939
public static final boolean ARM_INVERT_R = true;
4040
public static final boolean ARM_INVERT_L = true;
@@ -57,7 +57,7 @@ public class Constants {
5757
public static final double ARM_MAX_SPEED = 0.75;
5858
public static final int CLIMBER_SENSOR_TIMEOUT = 10;
5959
public static final double CLIMBER_SPEED = 0;
60-
public static final double DT_VOLTAGE_RAMP_RATE = 0.3;
60+
public static final double DT_VOLTAGE_RAMP_RATE = 0.1;
6161

6262
public static final double INTAKE_PULL_IN_SPEED = 0.5;
6363

src/org/usfirst/frc/team226/robot/Robot.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77

88
package org.usfirst.frc.team226.robot;
99

10-
import org.usfirst.frc.team226.robot.auton.ExecuteDoubleMacro;
10+
import java.util.ArrayList;
11+
import java.util.Arrays;
12+
import java.util.List;
13+
14+
import org.hammerhead226.sharkmacro.Parser;
15+
import org.hammerhead226.sharkmacro.motionprofiles.ProfileParser;
16+
import org.usfirst.frc.team226.robot.auton.ExecuteChoiceMacro;
1117
import org.usfirst.frc.team226.robot.auton.ExecuteMacro;
18+
import org.usfirst.frc.team226.robot.auton.grp_ExecuteMacroList;
1219
import org.usfirst.frc.team226.robot.commands.PS_ShiftDriveTrainHighGear;
1320
import org.usfirst.frc.team226.robot.subsystems.Arm;
1421
import org.usfirst.frc.team226.robot.subsystems.Climber;
@@ -50,11 +57,29 @@ public void robotInit() {
5057
intake = new Intake();
5158
oi = new OI();
5259
chooser.addDefault("Baseline Cross", new ExecuteMacro("baseline"));
53-
chooser.addObject("Left Switch", new ExecuteDoubleMacro("left", "baseline"));
54-
chooser.addObject("Center Switch", new ExecuteDoubleMacro("centerswitch_left", "centerswitch_right"));
55-
chooser.addObject("Right Switch", new ExecuteDoubleMacro("baseline", "rightswitch_right"));
60+
chooser.addObject("Left Switch", new ExecuteChoiceMacro("leftswitch_left", "baseline"));
61+
chooser.addObject("Center Switch", new ExecuteChoiceMacro("centerswitch_left", "centerswitch_right"));
62+
chooser.addObject("Right Switch", new ExecuteChoiceMacro("baseline", "rightswitch_right"));
63+
64+
ArrayList<String> left = new ArrayList<String>();
65+
left.add("centerswitch_left");
66+
left.add("centerswitch_left_pickup_fast");
67+
left.add("centerswitch_left_twocube");
68+
ArrayList<String> right = new ArrayList<String>();
69+
right.add("centerswitch_right");
70+
right.add("nothing");
71+
right.add("nothing");
72+
chooser.addObject("Center switch 2 cube?", new grp_ExecuteMacroList(left, right));
73+
5674
SmartDashboard.putData("Auto mode", chooser);
75+
5776
SmartDashboard.putData(new PS_ShiftDriveTrainHighGear());
77+
78+
ProfileParser.cache("centerswitch_left");
79+
ProfileParser.cache("centerswitch_left_pickup_fast");
80+
ProfileParser.cache("centerswitch_left_twocube");
81+
ProfileParser.cache("centerswitch_right");
82+
ProfileParser.cache("baseline");
5883
}
5984

6085
@Override
@@ -78,13 +103,6 @@ public void autonomousInit() {
78103
SmartDashboard.putString("Field State", DriverStation.getInstance().getGameSpecificMessage());
79104
m_autonomousCommand = chooser.getSelected();
80105

81-
/*
82-
* String autoSelected = SmartDashboard.getString("Auto Selector", "Default");
83-
* switch(autoSelected) { case "My Auto": autonomousCommand = new
84-
* MyAutoCommand(); break; case "Default Auto": default: autonomousCommand = new
85-
* ExampleCommand(); break; }
86-
*/
87-
88106
// schedule the autonomous command (example)
89107
if (m_autonomousCommand != null) {
90108
m_autonomousCommand.start();

src/org/usfirst/frc/team226/robot/RobotMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class RobotMap {
3030

3131
public static final int CLIMBER_LEFT = 11;
3232
public static final int CLIMBER_RIGHT = 15;
33-
public static final int CLIMBER_SERVO = 1;
33+
public static final int CLIMBER_SERVO = 0;
3434

3535
public static final int PCM_A = 11;
3636
public static final int PCM_B = 12;

src/org/usfirst/frc/team226/robot/auton/ExecuteDoubleMacro.java renamed to src/org/usfirst/frc/team226/robot/auton/ExecuteChoiceMacro.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
*
1717
*/
18-
public class ExecuteDoubleMacro extends Command {
18+
public class ExecuteChoiceMacro extends Command {
1919

2020
private String leftName;
2121
private String rightName;
@@ -24,7 +24,7 @@ public class ExecuteDoubleMacro extends Command {
2424

2525
private TalonSRX[] talons = Robot.driveTrain.getMotionProfileTalons();
2626

27-
public ExecuteDoubleMacro(String leftName, String rightName) {
27+
public ExecuteChoiceMacro(String leftName, String rightName) {
2828
// Use requires() here to declare subsystem dependencies
2929
// eg. requires(chassis);
3030
requires(Robot.driveTrain);
@@ -61,7 +61,7 @@ protected void execute() {
6161

6262
// Make this return true when this Command no longer needs to run execute()
6363
protected boolean isFinished() {
64-
return false;
64+
return profileToExecute.isFinished() && actionListToExecute.isFinished();
6565
}
6666

6767
// Called once after isFinished returns true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.usfirst.frc.team226.robot.auton;
2+
3+
import java.util.List;
4+
5+
import edu.wpi.first.wpilibj.command.CommandGroup;
6+
7+
/**
8+
*
9+
*/
10+
public class grp_ExecuteMacroList extends CommandGroup {
11+
12+
String voidMacro = "null";
13+
14+
public grp_ExecuteMacroList(List<String> leftNames, List<String> rightNames) {
15+
// while(true) {
16+
// if(leftNames.size() < rightNames.size()) {
17+
// leftNames.add(voidMacro);
18+
// }
19+
//
20+
// if(rightNames.size() < leftNames.size()) {
21+
// rightNames.add(voidMacro);
22+
// }
23+
//
24+
// if(leftNames.size() == rightNames.size()) {
25+
// break;
26+
// }
27+
// }
28+
29+
/*for (int i = 0; i < leftNames.size() || i < rightNames.size(); i++) {
30+
addSequential(new ExecuteChoiceMacro(leftNames.get(i), rightNames.get(i)));
31+
System.out.println(leftNames.get(i) + " " + rightNames.get(i));
32+
}*/
33+
34+
for (int i = 0; i < leftNames.size(); i++) {
35+
addSequential(new ExecuteChoiceMacro(leftNames.get(i), rightNames.get(i)));
36+
}
37+
}
38+
}

src/org/usfirst/frc/team226/robot/commands/C_UnlockClimber.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,22 @@
22

33
import org.usfirst.frc.team226.robot.Robot;
44

5-
import edu.wpi.first.wpilibj.command.Command;
5+
import edu.wpi.first.wpilibj.command.InstantCommand;
66

77
/**
88
*
99
*/
10-
public class C_UnlockClimber extends Command {
10+
public class C_UnlockClimber extends InstantCommand {
1111

1212
public C_UnlockClimber() {
13+
super();
1314
// Use requires() here to declare subsystem dependencies
1415
// eg. requires(chassis);
1516
requires(Robot.climber);
1617
}
1718

1819
// Called just before this Command runs the first time
1920
protected void initialize() {
20-
}
21-
22-
// Called repeatedly when this Command is scheduled to run
23-
protected void execute() {
2421
Robot.climber.activateClimber();
2522
}
26-
27-
// Make this return true when this Command no longer needs to run execute()
28-
protected boolean isFinished() {
29-
return false;
30-
}
31-
32-
// Called once after isFinished returns true
33-
protected void end() {
34-
}
35-
36-
// Called when another command which requires one or more of the same
37-
// subsystems is scheduled to run
38-
protected void interrupted() {
39-
}
4023
}

src/org/usfirst/frc/team226/robot/subsystems/Arm.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Arm() {
3131
right.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative, Constants.ARM_PIDSLOT_IDX,
3232
Constants.ARM_TIMEOUT);
3333
right.setSensorPhase(Constants.ARM_SENSOR_PHASE);
34-
34+
3535
right.configContinuousCurrentLimit(Constants.ARM_CURRENT_LIMIT, Constants.ARM_TIMEOUT);
3636
left.configContinuousCurrentLimit(Constants.ARM_CURRENT_LIMIT, Constants.ARM_TIMEOUT);
3737

@@ -56,7 +56,7 @@ public Arm() {
5656
right.configPeakOutputReverse(-Constants.ARM_MAX_SPEED, Constants.ARM_TIMEOUT);
5757

5858
left.follow(right);
59-
59+
6060
hardZeroEncoder();
6161

6262
}
@@ -85,7 +85,6 @@ public int getArmPos() {
8585
}
8686

8787
public void hardZeroEncoder() {
88-
// right.getSensorCollection().setPulseWidthPosition(0, Constants.ARM_TIMEOUT);
8988
right.setSelectedSensorPosition(ArmSetpoint.STRAIGHT_UP.position, 0, Constants.ARM_TIMEOUT);
9089
setArmSetpoint(ArmSetpoint.STRAIGHT_UP);
9190
}
@@ -100,7 +99,7 @@ public void driveArm(double speed) {
10099

101100
public void controlArm(double speed) {
102101
if (speed != 0) {
103-
right.set(ControlMode.PercentOutput, /*softLimit(speed)*/speed);
102+
right.set(ControlMode.PercentOutput, softLimit(speed));
104103
setpointPosition = getArmPos();
105104
} else {
106105
right.set(ControlMode.Position, setpointPosition);
@@ -112,10 +111,6 @@ private double softLimit(double input) {
112111
if (input > 0) {
113112
input = 0;
114113
}
115-
} else if (getArmPos() <= ArmSetpoint.BACK_GROUND.position - Constants.ARM_ERROR_TOLERANCE) {
116-
if (input < 0) {
117-
input = 0;
118-
}
119114
}
120115
return input;
121116
}

0 commit comments

Comments
 (0)