Skip to content

Commit 596b383

Browse files
committed
tuned the parameters for the TestingBot
1 parent 815ef0a commit 596b383

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static final class DriveConstants {
5656
// public static final double kP = 0.09;
5757
public static final double kP = 0.03;
5858
public static final double kI = 0.0;
59-
public static final double kD = 0;
59+
public static final double kD = kP * 0.05;
60+
// public static final double kD = 0;
6061
public static final double kS = 0;
6162
// public static final double kV = 0.11;
6263
// public static final double kA = 0.009;
@@ -68,7 +69,8 @@ public static final class DriveConstants {
6869
// public static final double kTeleopMaxVoltage = 12;
6970
// public static final double kTeleopMaxTurnVoltage = 7.2;
7071

71-
public static final double kDriveMaxSpeed = 3.0; // 3 meters per second
72+
// public static final double kDriveMaxSpeed = 3.0; // 3 meters per second
73+
public static final double kDriveMaxSpeed = 5.0; // 5 meters per second
7274
public static final double kTurnMaxAngularSpeed = Math.PI; // 1/2 rotation per second
7375
public static final double kDriveMaxVoltage = 12;
7476

@@ -95,11 +97,13 @@ public static final class DriveConstants {
9597
public static final double kRampRate = .1;
9698

9799
// DriveCommand.java Constants
98-
public static final double kDriveP = 4; // up to 1.0?
100+
public static final double kDriveP = 6; // up to 1.0?
99101
// public static final double kDriveP = 0.4; // up to 1.0?
100102
public static final double kDriveI = 0;
101103
public static final double kDriveD = 0;
102-
public static final double kDriveMaxAcceleration = 2 * kDriveMaxSpeed; // kDriveMaxSpeed in 1/2 sec
104+
// public static final double kDriveMaxAcceleration = 2 * kDriveMaxSpeed; //
105+
// kDriveMaxSpeed in 1/2 sec
106+
public static final double kDriveMaxAcceleration = 1 * kDriveMaxSpeed; // kDriveMaxSpeed in 1 sec
103107

104108
public static final double kTurnP = 0.2; // was 0.005 upto 0.2?
105109
// public static final double kTurnP = 0.02; // was 0.005 upto 0.2?
@@ -120,7 +124,7 @@ public static final class RobotConstants {
120124
* The {@code Transform3d} expressing the pose of the first camera relative to
121125
* the pose of the robot.
122126
*/
123-
public static Transform3d kRobotToCamera1 = new Transform3d(new Translation3d(0.0, -0.1, 0.2),
127+
public static Transform3d kRobotToCamera1 = new Transform3d(new Translation3d(0.0, 0.0, 0.2),
124128
new Rotation3d(0, Units.degreesToRadians(-20), 0));
125129

126130
/**

src/main/java/frc/robot/Robot.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.littletonrobotics.urcl.URCL;
1717
import org.photonvision.PhotonCamera;
1818

19+
import edu.wpi.first.math.geometry.Pose2d;
1920
import edu.wpi.first.math.geometry.Rotation2d;
2021
import edu.wpi.first.math.geometry.Transform2d;
2122
import edu.wpi.first.wpilibj.DataLogManager;
@@ -74,8 +75,8 @@ public void bindDriveControls() {
7475
() -> m_driverController.getR2Axis() - m_driverController.getL2Axis(),
7576
m_driverController.getHID()::getSquareButton));
7677

77-
double distanceTolerance = 0.05;
78-
double angleTolerance = 5;
78+
double distanceTolerance = 0.03;
79+
double angleTolerance = 3;
7980
m_driverController.button(Button.kSquare) // home
8081
.whileTrue(
8182
new DriveCommand(
@@ -90,36 +91,46 @@ public void bindDriveControls() {
9091
DriveCommand.moveForward(m_driveSubsystem, -1.8, distanceTolerance, angleTolerance)));
9192

9293
Transform2d robotToTarget = new Transform2d(1, 0, Rotation2d.fromDegrees(180));
93-
m_driverController.button(Button.kTriangle)
94-
.whileTrue(
95-
AlignCommand.moveTo(
96-
m_driveSubsystem, m_poseEstimationSubystem,
97-
kFieldLayout.getTagPose(17).get().toPose2d().plus(robotToTarget),
98-
distanceTolerance, angleTolerance));
99-
10094
double angleOfCoverageInDegrees = 90;
10195
double distanceThresholdInMeters = 4;
102-
m_driverController.button(Button.kLeftBumper)
96+
m_driverController.button(Button.kTriangle)
10397
.whileTrue(
104-
AlignCommand.turnToClosestTag(
105-
m_driveSubsystem, m_poseEstimationSubystem, angleOfCoverageInDegrees,
106-
distanceThresholdInMeters,
107-
distanceTolerance, angleTolerance));
98+
alignTest(1, robotToTarget, distanceTolerance, angleTolerance));
99+
// m_driverController.button(Button.kTriangle)
100+
// .whileTrue(
101+
// AlignCommand.turnToClosestTag(
102+
// m_driveSubsystem, m_poseEstimationSubystem, angleOfCoverageInDegrees,
103+
// distanceThresholdInMeters,
104+
// distanceTolerance, angleTolerance));
108105

109-
m_driverController.button(Button.kRightBumper)
106+
m_driverController.button(Button.kLeftBumper)
110107
.whileTrue(
111108
AlignCommand.moveToClosestTag(
112109
m_driveSubsystem, m_poseEstimationSubystem, angleOfCoverageInDegrees,
113110
distanceThresholdInMeters, robotToTarget,
114111
distanceTolerance, angleTolerance));
115112

116-
m_driverController.button(Button.kLeftTrigger)
113+
m_driverController.button(Button.kRightBumper)
117114
.whileTrue(
118115
tourCommand(
119-
m_driveSubsystem, m_poseEstimationSubystem, distanceTolerance, angleTolerance,
116+
m_driveSubsystem, m_poseEstimationSubystem, distanceTolerance,
117+
angleTolerance,
120118
robotToTarget, 12, 15, 14, 16, 17, 18, 19, 20, 21, 22));
121119
}
122120

121+
private Command alignTest(int tagIDs, Transform2d robotToTarget, double distanceTolerance, double angleTolerance) {
122+
return sequence(
123+
AlignCommand.moveTo(
124+
m_driveSubsystem, m_poseEstimationSubystem,
125+
kFieldLayout.getTagPose(1).get().toPose2d().plus(robotToTarget),
126+
distanceTolerance, angleTolerance),
127+
AlignCommand.moveTo(
128+
m_driveSubsystem, m_poseEstimationSubystem,
129+
() -> m_poseEstimationSubystem.getEstimatedPose()
130+
.plus(pose(-2, 0, 0).minus(Pose2d.kZero)),
131+
distanceTolerance, angleTolerance));
132+
}
133+
123134
Command tourCommand(DriveSubsystem driveSubsystem, PoseEstimationSubsystem poseEstimationSubystem,
124135
double distanceTolerance, double angleTolerance, Transform2d robotToTarget, int... tagIDs) {
125136
List<Command> commands = Arrays.stream(tagIDs).mapToObj(i -> kFieldLayout.getTagPose(i))

0 commit comments

Comments
 (0)