mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Add IsConnected function to all gyros (#4465)
This commit is contained in:
@@ -74,6 +74,8 @@ ADIS16448_IMU::ADIS16448_IMU(IMUAxis yaw_axis, SPI::Port port,
|
||||
m_spi_port(port),
|
||||
m_simDevice("Gyro:ADIS16448", port) {
|
||||
if (m_simDevice) {
|
||||
m_connected =
|
||||
m_simDevice.CreateBoolean("connected", hal::SimDevice::kInput, true);
|
||||
m_simGyroAngleX =
|
||||
m_simDevice.CreateDouble("gyro_angle_x", hal::SimDevice::kInput, 0.0);
|
||||
m_simGyroAngleY =
|
||||
@@ -150,6 +152,14 @@ ADIS16448_IMU::ADIS16448_IMU(IMUAxis yaw_axis, SPI::Port port,
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADIS16448, 0);
|
||||
|
||||
wpi::SendableRegistry::AddLW(this, "ADIS16448", port);
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
bool ADIS16448_IMU::IsConnected() const {
|
||||
if (m_simConnected) {
|
||||
return m_simConnected.Get();
|
||||
}
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,6 +72,8 @@ ADIS16470_IMU::ADIS16470_IMU(IMUAxis yaw_axis, SPI::Port port,
|
||||
m_calibration_time(static_cast<uint16_t>(cal_time)),
|
||||
m_simDevice("Gyro:ADIS16470", port) {
|
||||
if (m_simDevice) {
|
||||
m_connected =
|
||||
m_simDevice.CreateBoolean("connected", hal::SimDevice::kInput, true);
|
||||
m_simGyroAngleX =
|
||||
m_simDevice.CreateDouble("gyro_angle_x", hal::SimDevice::kInput, 0.0);
|
||||
m_simGyroAngleY =
|
||||
@@ -147,6 +149,14 @@ ADIS16470_IMU::ADIS16470_IMU(IMUAxis yaw_axis, SPI::Port port,
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADIS16470, 0);
|
||||
|
||||
wpi::SendableRegistry::AddLW(this, "ADIS16470", port);
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
bool ADIS16470_IMU::IsConnected() const {
|
||||
if (m_simConnected) {
|
||||
return m_simConnected.Get();
|
||||
}
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,8 @@ ADXRS450_Gyro::ADXRS450_Gyro() : ADXRS450_Gyro(SPI::kOnboardCS0) {}
|
||||
ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port)
|
||||
: m_spi(port), m_port(port), m_simDevice("Gyro:ADXRS450", port) {
|
||||
if (m_simDevice) {
|
||||
m_simConnected =
|
||||
m_simDevice.CreateBoolean("connected", hal::SimDevice::kInput, true);
|
||||
m_simAngle =
|
||||
m_simDevice.CreateDouble("angle_x", hal::SimDevice::kInput, 0.0);
|
||||
m_simRate = m_simDevice.CreateDouble("rate_x", hal::SimDevice::kInput, 0.0);
|
||||
@@ -57,6 +59,14 @@ ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port)
|
||||
HAL_Report(HALUsageReporting::kResourceType_ADXRS450, port + 1);
|
||||
|
||||
wpi::SendableRegistry::AddLW(this, "ADXRS450_Gyro", port);
|
||||
m_connected = true;
|
||||
}
|
||||
|
||||
bool ADXRS450_Gyro::IsConnected() const {
|
||||
if (m_simConnected) {
|
||||
return m_simConnected.Get();
|
||||
}
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
static bool CalcParity(int v) {
|
||||
|
||||
Reference in New Issue
Block a user