@@ -81,8 +81,21 @@ public DriveSubsystem() {
8181 m_headingCorrectionPID .enableContinuousInput (-Math .PI , Math .PI );
8282
8383 // TODO: Name the Limelight "LL1899" and set the camera orientation
84- // TODO: Set a custom crop window for improved performance (the bot only needs to see april tags on the reef)
84+ // TODO: Set a custom crop window for improved performance (the bot only needs
85+ // to see april tags on the reef)
8586 m_poseEstimator .setVisionMeasurementStdDevs (VecBuilder .fill (0.5 , 0.5 , 9999999 ));
87+
88+ if (VisionConstants .kUseVision && Robot .isReal ()) {
89+ LimelightHelpers .setCameraPose_RobotSpace (
90+ VisionConstants .kLimelightName ,
91+ VisionConstants .kCamPos .getX (),
92+ VisionConstants .kCamPos .getY (),
93+ VisionConstants .kCamPos .getZ (),
94+ VisionConstants .kCamPos .getRotation ().getX (),
95+ VisionConstants .kCamPos .getRotation ().getY (),
96+ VisionConstants .kCamPos .getRotation ().getZ ());
97+ LimelightHelpers .SetIMUMode (VisionConstants .kLimelightName , VisionConstants .kIMUMode );
98+ }
8699 }
87100
88101 @ Override
@@ -101,10 +114,11 @@ public void periodic() {
101114
102115 if (VisionConstants .kUseVision && Robot .isReal ()) {
103116 // Update LimeLight with current robot orientation
104- LimelightHelpers .SetRobotOrientation ("LL1899" , m_gyro .getAngle (), 0.0 , 0.0 , 0.0 , 0.0 , 0.0 );
117+ LimelightHelpers .SetRobotOrientation (VisionConstants . kLimelightName , m_gyro .getAngle (), 0.0 , 0.0 , 0.0 , 0.0 , 0.0 );
105118
106119 // Get the pose estimate
107- LimelightHelpers .PoseEstimate limelightMeasurement = LimelightHelpers .getBotPoseEstimate_wpiBlue_MegaTag2 ("LL1899" );
120+ LimelightHelpers .PoseEstimate limelightMeasurement = LimelightHelpers
121+ .getBotPoseEstimate_wpiBlue_MegaTag2 (VisionConstants .kLimelightName );
108122
109123 // Add it to your pose estimator if it is a valid measurement
110124 if (limelightMeasurement != null && limelightMeasurement .tagCount != 0 && m_gyro .getRate () < 720 ) {
@@ -113,7 +127,6 @@ public void periodic() {
113127 limelightMeasurement .timestampSeconds );
114128 }
115129 }
116-
117130
118131 m_field .setRobotPose (m_poseEstimator .getEstimatedPosition ());
119132
@@ -246,7 +259,8 @@ public void setModuleStates(SwerveModuleState[] desiredStates) {
246259 };
247260 SmartDashboard .putNumberArray ("AdvantageScope Swerve Desired States" , logData );
248261
249- // Takes the integral of the rotation speed to find the current angle for the simulator
262+ // Takes the integral of the rotation speed to find the current angle for the
263+ // simulator
250264 m_gyroAngle += DriveConstants .kDriveKinematics .toChassisSpeeds (desiredStates ).omegaRadiansPerSecond
251265 * Robot .kDefaultPeriod ;
252266 }
0 commit comments