Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add States to drive #70

Merged
merged 25 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
653654e
move otf and lineup logic into states to separate from drive
linglejack06 Feb 4, 2025
b719d81
add state configurations to drive
linglejack06 Feb 5, 2025
84a4a9c
begin implementing state machine logic in drive
linglejack06 Feb 5, 2025
0dccd9f
add test periodic to lineup state
linglejack06 Feb 5, 2025
080d0e4
add fire trigger within otf and lineup states to cancel due to issues
linglejack06 Feb 5, 2025
74defac
add idle state for after lineup while waiting on score
linglejack06 Feb 5, 2025
a97f27a
add joystick logic to idle state for when scoring is finished
linglejack06 Feb 5, 2025
7c4d8f7
add rerun on entry to OTF state by periodically checking for new pose
linglejack06 Feb 5, 2025
9358233
update InitBindings
linglejack06 Feb 5, 2025
0f76512
add state machine periodic to drive
linglejack06 Feb 5, 2025
96417fe
Merge remote-tracking branch 'origin' into drive-state
linglejack06 Feb 6, 2025
02de9b9
remove merge residue
linglejack06 Feb 6, 2025
da1a37a
remove merge residue
linglejack06 Feb 6, 2025
ba4a622
move over otf poses to otf state
linglejack06 Feb 6, 2025
fe7be9f
add logs, etc
linglejack06 Feb 6, 2025
2da0caa
update otf state
linglejack06 Feb 6, 2025
5853412
begin trying to fix entering lineup state
linglejack06 Feb 6, 2025
695903b
move alignment supplier to drive (doesnt work in state)
linglejack06 Feb 6, 2025
baed82e
fix some state logic and add BeginLineup trigger
linglejack06 Feb 7, 2025
d810226
fix rotation lock
linglejack06 Feb 7, 2025
6014bab
disable alignment when entering lineup
linglejack06 Feb 7, 2025
4de33eb
add variables to help with coral station -> reef quick otf
linglejack06 Feb 7, 2025
5c38818
update reef center translation in java file
linglejack06 Feb 7, 2025
1fa7923
remove todo and add comment to explain testPeriodic
linglejack06 Feb 7, 2025
9b06b3e
format
linglejack06 Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies {
def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit:akit-autolog:$akitJson.version"

def coppercoreVersion = "2025.1.7" // mavenLocal version
def coppercoreVersion = "2025.1.8" // mavenLocal version

implementation "io.github.team401.coppercore:controls:$coppercoreVersion"
implementation "io.github.team401.coppercore:geometry:$coppercoreVersion"
Expand Down
6 changes: 2 additions & 4 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@
}
],
"robotJoysticks": [
{},
{
"guid": "030000006d04000014c2000000000000"
},
{
"guid": "030000006d04000014c2000000000000"
"guid": "030000004f0400000ab1000000050000"
}
]
}
4 changes: 2 additions & 2 deletions src/main/deploy/constants/RedFieldLocations.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"redReefCenterTranslation": {
"x": 176.75,
"y": 158.5
"x": 12.5,
"y": 4.0259
},
"redReefCenterRotation": {
"radians": 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"driveAlongTrackMultiplier": -1,
"driveAlongTrackOffset": 0.25,
"driveCrossTrackFrontRightOffset": 0.0,
"otfPoseDistanceLimit": 0.1,
"otfPoseDistanceLimit": 0.2,
"kSteerClosedLoopOutput": "Voltage",
"kDriveClosedLoopOutput": "TorqueCurrentFOC",
"kDriveMotorType": "TalonFX_Integrated",
Expand Down Expand Up @@ -330,7 +330,7 @@
"kInvertRightSide": true,
"kPigeonId": 20,
"OTFMaxLinearVelocity": 3.5,
"OTFMaxLinearAccel": 0.5,
"OTFMaxLinearAccel": 2.0,
"OTFMaxAngularVelocity": 3.141592653589793,
"OTFMaxAngularAccel": 1.5707963267948966,
"DrivetrainConstants": {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/frc/robot/BuildConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/** Automatically generated file containing build version information. */
public final class BuildConstants {
public static final String MAVEN_GROUP = "";
public static final String MAVEN_NAME = "2025-Robot-Code-2";
public static final String MAVEN_NAME = "2025-Robot-Code";
public static final String VERSION = "unspecified";
public static final int GIT_REVISION = 46;
public static final String GIT_SHA = "25f2cfcfd7a62559b6af5fc71c2258639513996c";
public static final String GIT_DATE = "2025-02-05 19:00:34 EST";
public static final String GIT_BRANCH = "add-lock-on-reef";
public static final String BUILD_DATE = "2025-02-05 19:11:03 EST";
public static final long BUILD_UNIX_TIME = 1738800663170L;
public static final int GIT_REVISION = 41;
public static final String GIT_SHA = "6014babca388b45cfb9884e60358fcf30f37bc46";
public static final String GIT_DATE = "2025-02-06 19:36:46 EST";
public static final String GIT_BRANCH = "drive-state";
public static final String BUILD_DATE = "2025-02-06 19:49:52 EST";
public static final long BUILD_UNIX_TIME = 1738889392945L;
public static final int DIRTY = 1;

private BuildConstants() {}
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/frc/robot/InitBindings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import frc.robot.constants.JsonConstants;
import frc.robot.constants.OperatorConstants;
import frc.robot.subsystems.drive.Drive;
import frc.robot.subsystems.drive.Drive.DriveTrigger;

public final class InitBindings {
// Controller
Expand Down Expand Up @@ -44,15 +45,15 @@ public static void initDriveBindings(Drive drive) {
.onTrue(
new InstantCommand(
() -> {
drive.setAutoAlignment(true);
drive.fireTrigger(DriveTrigger.BeginAutoAlignment);
},
drive));
rightJoystick
.button(1)
.onFalse(
new InstantCommand(
() -> {
drive.setAutoAlignment(false);
drive.fireTrigger(DriveTrigger.CancelAutoAlignment);
},
drive));

Expand Down Expand Up @@ -101,5 +102,24 @@ public static void initDriveBindings(Drive drive) {
new Pose2d(
Meters.of(14.350), Meters.of(4.0), new Rotation2d(Degrees.of(180))));
}));
rightJoystick
.top()
.onTrue(
new InstantCommand(
() -> {
drive.setGoToIntake(true);
drive.fireTrigger(DriveTrigger.BeginAutoAlignment);
},
drive));

rightJoystick
.top()
.onFalse(
new InstantCommand(
() -> {
drive.setGoToIntake(false);
drive.fireTrigger(DriveTrigger.CancelAutoAlignment);
},
drive));
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testPeriodic() {
scoringSubsystem.testPeriodic();
}
if (FeatureFlags.synced.getObject().runDrive) {
drive.testPeriodic();
// TODO: run lineup state test periodic
jkleiber marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/constants/JsonConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static void loadConstants() {
ScoringSetpoints.synced.loadData();
RedFieldLocations.synced.loadData();
BlueFieldLocations.synced.loadData();
DrivetrainConstants.synced.loadData();
VisionConstants.synced.loadData();

elevatorConstants = ElevatorConstants.synced.getObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class RedFieldLocations {
.toString(),
new JSONSyncConfigBuilder().setPrettyPrinting(true).build());

public Translation2d redReefCenterTranslation = new Translation2d(176.75, (158.5));
public Translation2d redReefCenterTranslation =
new Translation2d(Units.inchesToMeters(176.75), Units.inchesToMeters(158.5));
linglejack06 marked this conversation as resolved.
Show resolved Hide resolved
public Rotation2d redReefCenterRotation = new Rotation2d();

public Translation2d redReef01Translation = new Translation2d(11.5, 4.1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class DrivetrainConstants {

// OTF Max speed / accel
public final Double OTFMaxLinearVelocity = 3.5;
public final Double OTFMaxLinearAccel = 0.5;
public final Double OTFMaxLinearAccel = 2.0;
public final Double OTFMaxAngularVelocity = Math.PI;
public final Double OTFMaxAngularAccel = Math.PI / 2;

Expand Down
Loading
Loading