Skip to content

Commit 93e84dc

Browse files
authored
Merge pull request #9 from IgniteRobotics/feature/intake
Feature/intake
2 parents ce9859f + 7ea3a7b commit 93e84dc

File tree

11 files changed

+304
-4
lines changed

11 files changed

+304
-4
lines changed

.github/prompts/code-review-prompt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public abstract class ServoMotorSubsystem<IO extends MotorIO> extends SubsystemB
222222
}
223223
```
224224

225-
12. Safety & Error Handling
225+
## Safety & Error Handling
226226

227227
### Mechanism Limits
228228

.github/scripts/gemini-code-review.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from github import Github, GithubException
1313

1414
# Configuration
15-
GEMINI_MODEL = "gemini-2.0-flash-exp"
15+
GEMINI_MODEL = "gemini-2.5-flash"
1616
MAX_FILES_TO_REVIEW = 50
1717
MAX_FILE_SIZE = 100000 # 100KB per file
1818
REVIEW_COMMENT_MARKER = "<!-- ai-code-review-bot -->"

.github/workflows/ai-code-review.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ on:
1919
default: false
2020

2121
permissions:
22-
contents: read
23-
pull-requests: write
22+
issues: write # Allows reading and posting comments to issues
23+
pull-requests: write # Allows reading and posting to PRs
24+
contents: read # Standard permission to read the code
2425

2526
jobs:
2627
ai-review:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package frc.robot.preferences;
2+
3+
import edu.wpi.first.wpilibj.Preferences;
4+
5+
public class BooleanPreference extends RobotPreference<Boolean> {
6+
private boolean defaultValue;
7+
8+
public BooleanPreference(String key) {
9+
this(key, false);
10+
}
11+
12+
public BooleanPreference(String key, boolean defaultValue) {
13+
super(key);
14+
this.defaultValue = defaultValue;
15+
16+
Preferences.initBoolean(key, defaultValue);
17+
}
18+
19+
public boolean getValue() {
20+
return Preferences.getBoolean(super.key, defaultValue);
21+
}
22+
23+
@Override
24+
public Boolean get() {
25+
return getValue();
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package frc.robot.preferences;
2+
3+
import edu.wpi.first.wpilibj.Preferences;
4+
5+
public class DoublePreference extends RobotPreference<Double> {
6+
private double defaultValue;
7+
8+
public DoublePreference(String key) {
9+
this(key, 0.0);
10+
}
11+
12+
public DoublePreference(String key, double defaultValue) {
13+
super(key);
14+
this.defaultValue = defaultValue;
15+
16+
Preferences.initDouble(key, defaultValue);
17+
}
18+
19+
public double getValue() {
20+
return Preferences.getDouble(super.key, defaultValue);
21+
}
22+
23+
@Override
24+
public Double get() {
25+
return getValue();
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package frc.robot.preferences;
2+
3+
import edu.wpi.first.wpilibj.Preferences;
4+
5+
public class IntegerPreference extends RobotPreference<Integer> {
6+
private int defaultValue;
7+
8+
public IntegerPreference(String key) {
9+
this(key, 0);
10+
}
11+
12+
public IntegerPreference(String key, int defaultValue) {
13+
super(key);
14+
this.defaultValue = defaultValue;
15+
16+
Preferences.initInt(key, defaultValue);
17+
}
18+
19+
public int getValue() {
20+
return Preferences.getInt(super.key, defaultValue);
21+
}
22+
23+
@Override
24+
public Integer get() {
25+
return getValue();
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package frc.robot.preferences;
2+
3+
import edu.wpi.first.wpilibj.Preferences;
4+
import java.util.Collection;
5+
import java.util.function.Supplier;
6+
7+
public abstract class RobotPreference<T> implements Supplier<T> {
8+
protected String key;
9+
10+
public RobotPreference(String key) {
11+
this.key = key;
12+
}
13+
14+
public void remove() {
15+
Preferences.remove(key);
16+
}
17+
18+
public static void removeAll() {
19+
Preferences.removeAll();
20+
}
21+
22+
public static Collection<String> getKeys() {
23+
return Preferences.getKeys();
24+
}
25+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package frc.robot.preferences;
2+
3+
import edu.wpi.first.wpilibj.Preferences;
4+
5+
public class StringPreference extends RobotPreference<String> {
6+
private String defaultValue;
7+
8+
public StringPreference(String key) {
9+
this(key, "");
10+
}
11+
12+
public StringPreference(String key, String defaultValue) {
13+
super(key);
14+
this.defaultValue = defaultValue;
15+
16+
Preferences.initString(key, defaultValue);
17+
}
18+
19+
public String getValue() {
20+
return Preferences.getString(super.key, defaultValue);
21+
}
22+
23+
@Override
24+
public String get() {
25+
return getValue();
26+
}
27+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package frc.robot.subsystems.intake;
2+
3+
import com.ctre.phoenix6.configs.Slot0Configs;
4+
import com.ctre.phoenix6.configs.SoftwareLimitSwitchConfigs;
5+
6+
public class IntakeConstants {
7+
8+
private IntakeConstants() {}
9+
10+
// TODO: Change to actual ports
11+
public static final int ROLLER_MOTOR_ID = 2;
12+
public static final int EXTENSION_MOTOR_ID = 3;
13+
14+
// TODO: Tune Roller and Extension Motors
15+
16+
// Roller Motor
17+
public static final double ROLLER_KS = 0;
18+
public static final double ROLLER_KV = 0;
19+
public static final double ROLLER_KP = 0;
20+
public static final double ROLLER_KD = 0;
21+
22+
public static Slot0Configs createRollerMotorSlot0Configs() {
23+
Slot0Configs slot = new Slot0Configs();
24+
slot.kS = ROLLER_KS;
25+
slot.kV = ROLLER_KV;
26+
slot.kP = ROLLER_KP;
27+
slot.kD = ROLLER_KD;
28+
return slot;
29+
}
30+
31+
// Extension Motor
32+
public static final double ALLOWABLE_EXTENSION_ERROR = 0.1;
33+
public static final double INTAKE_FORWARD_LIMIT = 100;
34+
public static final double INTAKE_REVERSE_LIMIT = 0;
35+
public static final double EXTENSION_KS = 0;
36+
public static final double EXTENSION_KP = 0;
37+
public static final double EXTENSION_KD = 0;
38+
39+
public static Slot0Configs createExtensionMotorSlot0Configs() {
40+
Slot0Configs slot = new Slot0Configs();
41+
slot.kS = EXTENSION_KS;
42+
slot.kP = EXTENSION_KP;
43+
slot.kD = EXTENSION_KD;
44+
return slot;
45+
}
46+
47+
public static SoftwareLimitSwitchConfigs createExtensionSoftwareLimitSwitchConfigs() {
48+
SoftwareLimitSwitchConfigs configs = new SoftwareLimitSwitchConfigs();
49+
configs.ForwardSoftLimitEnable = false;
50+
configs.ReverseSoftLimitEnable = false;
51+
configs.ForwardSoftLimitThreshold = INTAKE_FORWARD_LIMIT;
52+
configs.ReverseSoftLimitThreshold = INTAKE_REVERSE_LIMIT;
53+
return configs;
54+
}
55+
56+
public static final double SAFE_HOMING_EFFORT = -0.2;
57+
public static final double SAFE_STATOR_LIMIT = 0.8;
58+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package frc.robot.subsystems.intake;
2+
3+
import frc.robot.preferences.DoublePreference;
4+
5+
public class IntakePreferences {
6+
7+
private IntakePreferences() {}
8+
;
9+
10+
public static DoublePreference rollerIntakeSpeed =
11+
new DoublePreference("Intake/Roller Intake Speed", 0.1); // in rotations per second
12+
public static DoublePreference intakeCollectPosition =
13+
new DoublePreference("Intake/Stowed Intake Position", 3); // in rotations
14+
}

0 commit comments

Comments
 (0)