From 84f8a9f63adf34ff6b7fc6bb116c9e1f6589204b Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Mon, 22 Jan 2024 17:27:37 -0600 Subject: [PATCH] Added warnings for NavX over serial --- swervelib/parser/json/DeviceJson.java | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/swervelib/parser/json/DeviceJson.java b/swervelib/parser/json/DeviceJson.java index 0d17ec3..2bdadfb 100644 --- a/swervelib/parser/json/DeviceJson.java +++ b/swervelib/parser/json/DeviceJson.java @@ -27,6 +27,7 @@ import swervelib.motors.SwerveMotor; import swervelib.motors.TalonFXSwerve; import swervelib.motors.TalonSRXSwerve; import swervelib.telemetry.Alert; +import swervelib.telemetry.Alert.AlertType; /** * Device JSON parsed class. Used to access the JSON data. @@ -37,15 +38,21 @@ public class DeviceJson /** * An {@link Alert} for if the CAN ID is greater than 40. */ - private final Alert canIdWarning = new Alert("JSON", - "CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!", - Alert.AlertType.WARNING); + private final Alert canIdWarning = new Alert("JSON", + "CAN IDs greater than 40 can cause undefined behaviour, please use a CAN ID below 40!", + Alert.AlertType.WARNING); /** * An {@link Alert} for if there is an I2C lockup issue on the roboRIO. */ - private final Alert i2cLockupWarning = new Alert("IMU", - "I2C lockup issue detected on roboRIO. Check console for more information.", - Alert.AlertType.WARNING); + private final Alert i2cLockupWarning = new Alert("IMU", + "I2C lockup issue detected on roboRIO. Check console for more information.", + Alert.AlertType.WARNING); + /** + * NavX serial comm issue. + */ + private final Alert serialCommsIssueWarning = new Alert("IMU", + "Serial comms is interrupted with USB and other serial traffic and causes intermittent connected/disconnection issues. Please consider another protocol or be mindful of this.", + AlertType.WARNING); /** * The device type, e.g. pigeon/pigeon2/sparkmax/talonfx/navx */ @@ -57,7 +64,7 @@ public class DeviceJson /** * The CAN bus name which the device resides on if using CAN. */ - public String canbus = ""; + public String canbus = ""; /** * Create a {@link SwerveAbsoluteEncoder} from the current configuration. @@ -124,7 +131,6 @@ public class DeviceJson case "analog": return new AnalogGyroSwerve(id); case "navx": - case "navx_mxp_spi": case "navx_spi": return new NavXSwerve(SPI.Port.kMXP); case "navx_i2c": @@ -136,8 +142,12 @@ public class DeviceJson i2cLockupWarning.set(true); return new NavXSwerve(I2C.Port.kMXP); case "navx_usb": + DriverStation.reportWarning("WARNING: There is issues when using USB camera's and the NavX like this!\n" + + "https://pdocs.kauailabs.com/navx-mxp/guidance/selecting-an-interface/", false); + serialCommsIssueWarning.set(true); return new NavXSwerve(Port.kUSB); case "navx_mxp_serial": + serialCommsIssueWarning.set(true); return new NavXSwerve(Port.kMXP); case "pigeon": return new PigeonSwerve(id);