Skip to content

Commit 78cb351

Browse files
committed
added telemetry check for updating smartdashboard values
created sendable chooser to change competition mode + vision
1 parent aa44163 commit 78cb351

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import edu.wpi.first.math.geometry.Translation3d;
1818
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
1919
import edu.wpi.first.math.numbers.N3;
20+
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
21+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
2022

2123
/**
2224
* The Constants class provides a convenient place for teams to hold robot-wide
@@ -88,6 +90,9 @@ public static final class DriveConstants {
8890
// TODO: Tune this PID before running on a robot on the ground
8991
public static final double kPModuleTurningController = 0.3;
9092

93+
// TODO: Set value
94+
public static final boolean kUseTelemetry = false;
95+
9196
public static final SwerveDriveKinematics kDriveKinematics = new SwerveDriveKinematics(
9297
new Translation2d(kWheelBase / 2, kTrackWidth / 2),
9398
new Translation2d(kWheelBase / 2, -kTrackWidth / 2),
@@ -114,7 +119,13 @@ public static final class DriveConstants {
114119
public static final double kMaxAccelerationUnitsPerSecond = 100;
115120
public static final double kMaxAngularAccelerationUnitsPerSecond = 100;
116121
}
117-
122+
public static final class competitionMode {
123+
public static final boolean kCompetitionMode = false;
124+
125+
} {
126+
127+
128+
}
118129
public static final class VisionConstants {
119130
// TODO: Update cam pose relative to center of bot
120131
public static final Pose3d kCamPos = new Pose3d(
@@ -206,4 +217,11 @@ public static final class EndEffectorConstants{
206217
Map.entry(0.0, Pair.of(0.0, Math.PI / 2)),
207218
Map.entry(1.0, Pair.of(Math.PI / 2, Math.PI)))); // TODO: find safe pivot position
208219
}
209-
}
220+
public static final class SendableChooserConstants {
221+
public static final String kcompetitionMode = "competition mode";
222+
public static final String kpracticeMode = "practice mode";
223+
public static final String kUseVision = "use vision";
224+
public static final String kNotUseVision = "don't use vision";
225+
}
226+
}
227+

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package frc.robot;
66

77
import edu.wpi.first.wpilibj.TimedRobot;
8+
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
89
import edu.wpi.first.wpilibj2.command.Command;
910
import edu.wpi.first.wpilibj2.command.CommandScheduler;
1011

@@ -23,6 +24,22 @@ public class Robot extends TimedRobot {
2324
* This function is run when the robot is first started up and should be used for any
2425
* initialization code.
2526
*/
27+
28+
//creating sendable chooser to set competition mode
29+
public final class sendableChooserCompMode {
30+
public String m_modeSelected;
31+
private final SendableChooser<String> m_sendableChooserCompetition = new SendableChooser<>();
32+
}
33+
34+
//creating a sendable chooser to set vision
35+
public final class sendableChooserVision {
36+
public String m_usingVision;
37+
private final SendableChooser<String> m_sendableChooserVision = new SendableChooser<>();
38+
}
39+
40+
private sendableChooserCompMode sendableComp = new sendableChooserCompMode();
41+
private sendableChooserVision sendableVision = new sendableChooserVision();
42+
2643
@Override
2744
public void robotInit() {
2845
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
@@ -78,6 +95,12 @@ public void teleopInit() {
7895
if (m_autonomousCommand != null) {
7996
m_autonomousCommand.cancel();
8097
}
98+
sendableComp.m_modeSelected = sendableComp.m_sendableChooserCompetition.getSelected();
99+
boolean m_competitionMode = sendableComp.m_modeSelected.equals("competition mode");
100+
101+
sendableVision.m_usingVision = sendableVision.m_sendableChooserVision.getSelected();
102+
boolean m_usingVision = sendableVision.m_usingVision.equals("use vision");
103+
81104
}
82105

83106
/** This function is called periodically during operator control. */

src/main/java/frc/robot/subsystems/DriveSubsystem.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ public void periodic() {
162162
m_desiredStates[3].angle.getDegrees(), m_desiredStates[3].speedMetersPerSecond / DriveConstants.kMaxSpeedMetersPerSecond,
163163
};
164164

165-
SmartDashboard.putNumberArray("AdvantageScope Swerve Desired States", logDataDesired);
166-
SmartDashboard.putNumberArray("AdvantageScope Swerve States", logData);
165+
if (Constants.DriveConstants.kUseTelemetry) {
166+
SmartDashboard.putNumberArray("AdvantageScope Swerve Desired States", logDataDesired);
167+
SmartDashboard.putNumberArray("AdvantageScope Swerve States", logData);
168+
}
167169
}
168170

169171
/**

src/main/java/frc/robot/utils/AllianceFlipUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import edu.wpi.first.math.geometry.Translation2d;
1010
import edu.wpi.first.math.util.Units;
1111
import edu.wpi.first.wpilibj.DriverStation;
12+
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
1213

1314
/** Add your docs here. */
1415
public class AllianceFlipUtil {

0 commit comments

Comments
 (0)