Skip to content

Commit

Permalink
allow for dynamic std devs for pose estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-05RPGV3\Malachi committed Feb 29, 2024
1 parent 3285471 commit 129aef9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 3534CTRESwerve.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "3534CTRESwerve.json",
"name": "3534CTRESwerve",
"version": "2024.2.2",
"version": "2024.2.3",
"frcYear": 2024,
"uuid": "1fcedb64-1708-4258-9f56-fc21dc0d7c78",
"mavenUrls": [
Expand All @@ -12,7 +12,7 @@
{
"groupId": "com.github.HOC-Team-3534",
"artifactId": "3534CTRESwerve",
"version": "2024.2.2"
"version": "2024.2.3"
}
],
"jniDependencies": [],
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/swerve/CommandSwerveDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
import com.pathplanner.lib.path.PathPlannerTrajectory;
import com.pathplanner.lib.util.HolonomicPathFollowerConfig;

import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.SwerveModuleState;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N3;
import edu.wpi.first.wpilibj.Notifier;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj2.command.Command;
Expand All @@ -46,6 +50,15 @@ public class CommandSwerveDrivetrain extends SwerveDrivetrain implements Subsyst
public CommandSwerveDrivetrain(SwerveDrivetrainConstants driveTrainConstants, double OdometryUpdateFrequency,
double maxSpeed, HolonomicPathFollowerConfig holoConfig,
SwerveModuleConstants... modules) {
this(driveTrainConstants, OdometryUpdateFrequency,
VecBuilder.fill(0.1, 0.1, 0.1),
VecBuilder.fill(0.9, 0.9, 0.9), maxSpeed, holoConfig, modules);
}

public CommandSwerveDrivetrain(SwerveDrivetrainConstants driveTrainConstants, double OdometryUpdateFrequency,
Matrix<N3, N1> odometryStandardDeviation, Matrix<N3, N1> visionStandardDeviation,
double maxSpeed, HolonomicPathFollowerConfig holoConfig,
SwerveModuleConstants... modules) {
super(driveTrainConstants, OdometryUpdateFrequency, modules);
this.maxSpeed = maxSpeed;
pathplanner.configureHolonomic(() -> this.getState().Pose, this::seedFieldRelative,
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/swerve/SwerveDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import com.ctre.phoenix6.mechanisms.swerve.SwerveDrivetrainConstants;
import com.ctre.phoenix6.mechanisms.swerve.SwerveModuleConstants;

import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.kinematics.ChassisSpeeds;
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N3;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

Expand All @@ -17,7 +21,18 @@ public enum RobotCentricity {

public SwerveDrivetrain(SwerveDrivetrainConstants driveTrainConstants, double OdometryUpdateFrequency,
SwerveModuleConstants[] modules) {
super(driveTrainConstants, OdometryUpdateFrequency, modules);
this(driveTrainConstants,
OdometryUpdateFrequency,
VecBuilder.fill(0.1, 0.1, 0.1),
VecBuilder.fill(0.9, 0.9, 0.9),
modules);
}

public SwerveDrivetrain(SwerveDrivetrainConstants driveTrainConstants, double OdometryUpdateFrequency,
Matrix<N3, N1> odometryStandardDeviation, Matrix<N3, N1> visionStandardDeviation,
SwerveModuleConstants[] modules) {
super(driveTrainConstants, OdometryUpdateFrequency, odometryStandardDeviation, visionStandardDeviation,
modules);
centricityChooser.setDefaultOption("Field Centric", RobotCentricity.FieldCentric.toString());
centricityChooser.addOption("Robot Centric", RobotCentricity.RobotCentric.toString());
SmartDashboard.putData("Centricity Chooser", centricityChooser);
Expand Down

0 comments on commit 129aef9

Please sign in to comment.