mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Fixed NetworkAlerts
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package swervelib.imu;
|
||||
|
||||
import com.kauailabs.navx.frc.AHRS;
|
||||
import edu.wpi.first.math.geometry.Quaternion;
|
||||
import edu.wpi.first.math.geometry.Rotation3d;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import edu.wpi.first.wpilibj.I2C;
|
||||
import edu.wpi.first.wpilibj.SPI;
|
||||
import edu.wpi.first.wpilibj.SerialPort;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import java.util.Optional;
|
||||
import swervelib.telemetry.Alert;
|
||||
|
||||
/**
|
||||
* Communicates with the NavX as the IMU.
|
||||
@@ -25,6 +24,10 @@ public class NavXSwerve extends SwerveIMU
|
||||
* Offset for the NavX.
|
||||
*/
|
||||
private Rotation3d offset = new Rotation3d();
|
||||
/**
|
||||
* An {@link Alert} for if there is an error instantiating the NavX.
|
||||
*/
|
||||
private Alert navXError;
|
||||
|
||||
/**
|
||||
* Constructor for the NavX swerve.
|
||||
@@ -33,6 +36,7 @@ public class NavXSwerve extends SwerveIMU
|
||||
*/
|
||||
public NavXSwerve(SerialPort.Port port)
|
||||
{
|
||||
navXError = new Alert("IMU", "Error instantiating NavX.", Alert.AlertType.ERROR_TRACE);
|
||||
try
|
||||
{
|
||||
/* Communicate w/navX-MXP via the MXP SPI Bus. */
|
||||
@@ -43,7 +47,8 @@ public class NavXSwerve extends SwerveIMU
|
||||
SmartDashboard.putData(gyro);
|
||||
} catch (RuntimeException ex)
|
||||
{
|
||||
DriverStation.reportError("Error instantiating navX: " + ex.getMessage(), true);
|
||||
navXError.setText("Error instantiating NavX: " + ex.getMessage());
|
||||
navXError.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +69,8 @@ public class NavXSwerve extends SwerveIMU
|
||||
SmartDashboard.putData(gyro);
|
||||
} catch (RuntimeException ex)
|
||||
{
|
||||
DriverStation.reportError("Error instantiating navX: " + ex.getMessage(), true);
|
||||
navXError.setText("Error instantiating NavX: " + ex.getMessage());
|
||||
navXError.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +91,8 @@ public class NavXSwerve extends SwerveIMU
|
||||
SmartDashboard.putData(gyro);
|
||||
} catch (RuntimeException ex)
|
||||
{
|
||||
DriverStation.reportError("Error instantiating navX: " + ex.getMessage(), true);
|
||||
navXError.setText("Error instantiating NavX: " + ex.getMessage());
|
||||
navXError.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user