diff --git a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp index 523c1dfd24..2c1c62b14e 100644 --- a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp +++ b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp @@ -8,6 +8,7 @@ #include "frc/DriverStation.h" #include "frc/Timer.h" +#include "frc/smartdashboard/SendableBuilder.h" #include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -134,3 +135,9 @@ void ADXRS450_Gyro::Calibrate() { int ADXRS450_Gyro::GetPort() const { return m_port; } + +void ADXRS450_Gyro::InitSendable(SendableBuilder& builder) { + builder.SetSmartDashboardType("Gyro"); + builder.AddDoubleProperty( + "Value", [=]() { return GetAngle(); }, nullptr); +} diff --git a/wpilibc/src/main/native/cpp/AnalogGyro.cpp b/wpilibc/src/main/native/cpp/AnalogGyro.cpp index 867d1c618f..86e5b461f6 100644 --- a/wpilibc/src/main/native/cpp/AnalogGyro.cpp +++ b/wpilibc/src/main/native/cpp/AnalogGyro.cpp @@ -15,6 +15,7 @@ #include "frc/Base.h" #include "frc/Timer.h" #include "frc/WPIErrors.h" +#include "frc/smartdashboard/SendableBuilder.h" #include "frc/smartdashboard/SendableRegistry.h" using namespace frc; @@ -180,3 +181,9 @@ void AnalogGyro::Calibrate() { std::shared_ptr AnalogGyro::GetAnalogInput() const { return m_analog; } + +void AnalogGyro::InitSendable(SendableBuilder& builder) { + builder.SetSmartDashboardType("Gyro"); + builder.AddDoubleProperty( + "Value", [=]() { return GetAngle(); }, nullptr); +} diff --git a/wpilibc/src/main/native/cpp/GyroBase.cpp b/wpilibc/src/main/native/cpp/GyroBase.cpp deleted file mode 100644 index bcb25fad13..0000000000 --- a/wpilibc/src/main/native/cpp/GyroBase.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "frc/GyroBase.h" - -#include "frc/WPIErrors.h" -#include "frc/smartdashboard/SendableBuilder.h" - -using namespace frc; - -void GyroBase::InitSendable(SendableBuilder& builder) { - builder.SetSmartDashboardType("Gyro"); - builder.AddDoubleProperty( - "Value", [=]() { return GetAngle(); }, nullptr); -} diff --git a/wpilibc/src/main/native/cpp/romi/RomiGyro.cpp b/wpilibc/src/main/native/cpp/romi/RomiGyro.cpp index 50260f9d37..26a28fac73 100644 --- a/wpilibc/src/main/native/cpp/romi/RomiGyro.cpp +++ b/wpilibc/src/main/native/cpp/romi/RomiGyro.cpp @@ -4,6 +4,8 @@ #include "frc/romi/RomiGyro.h" +#include "frc/smartdashboard/SendableBuilder.h" + using namespace frc; RomiGyro::RomiGyro() : m_simDevice("Gyro:RomiGyro") { @@ -87,3 +89,9 @@ void RomiGyro::Reset() { m_angleZOffset = m_simAngleZ.Get(); } } + +void RomiGyro::InitSendable(SendableBuilder& builder) { + builder.SetSmartDashboardType("Gyro"); + builder.AddDoubleProperty( + "Value", [=]() { return GetAngle(); }, nullptr); +} diff --git a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h index 3c49c05622..556bb49a2e 100644 --- a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h +++ b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h @@ -8,8 +8,11 @@ #include -#include "frc/GyroBase.h" +#include "frc/ErrorBase.h" #include "frc/SPI.h" +#include "frc/interfaces/Gyro.h" +#include "frc/smartdashboard/Sendable.h" +#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -26,7 +29,10 @@ namespace frc { * This class is for the digital ADXRS450 gyro sensor that connects via SPI. * Only one instance of an ADXRS Gyro is supported. */ -class ADXRS450_Gyro : public GyroBase { +class ADXRS450_Gyro : public Gyro, + public ErrorBase, + public Sendable, + public SendableHelper { public: /** * Gyro constructor on onboard CS0. @@ -96,6 +102,8 @@ class ADXRS450_Gyro : public GyroBase { */ int GetPort() const; + void InitSendable(SendableBuilder& builder) override; + private: SPI m_spi; SPI::Port m_port; diff --git a/wpilibc/src/main/native/include/frc/AnalogGyro.h b/wpilibc/src/main/native/include/frc/AnalogGyro.h index 42b6317def..e2646cec5a 100644 --- a/wpilibc/src/main/native/include/frc/AnalogGyro.h +++ b/wpilibc/src/main/native/include/frc/AnalogGyro.h @@ -8,7 +8,8 @@ #include -#include "frc/GyroBase.h" +#include "frc/ErrorBase.h" +#include "frc/interfaces/Gyro.h" #include "frc/smartdashboard/Sendable.h" #include "frc/smartdashboard/SendableHelper.h" @@ -29,7 +30,10 @@ class AnalogInput; * * This class is for gyro sensors that connect to an analog input. */ -class AnalogGyro : public GyroBase { +class AnalogGyro : public Gyro, + public ErrorBase, + public Sendable, + public SendableHelper { public: static constexpr int kOversampleBits = 10; static constexpr int kAverageBits = 0; @@ -190,6 +194,8 @@ class AnalogGyro : public GyroBase { */ std::shared_ptr GetAnalogInput() const; + void InitSendable(SendableBuilder& builder) override; + protected: std::shared_ptr m_analog; diff --git a/wpilibc/src/main/native/include/frc/GyroBase.h b/wpilibc/src/main/native/include/frc/GyroBase.h deleted file mode 100644 index 004d146874..0000000000 --- a/wpilibc/src/main/native/include/frc/GyroBase.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once - -#include "frc/ErrorBase.h" -#include "frc/interfaces/Gyro.h" -#include "frc/smartdashboard/Sendable.h" -#include "frc/smartdashboard/SendableHelper.h" - -namespace frc { - -/** - * GyroBase is the common base class for Gyro implementations such as - * AnalogGyro. - */ -class GyroBase : public Gyro, - public ErrorBase, - public Sendable, - public SendableHelper { - public: - GyroBase() = default; - GyroBase(GyroBase&&) = default; - GyroBase& operator=(GyroBase&&) = default; - - void InitSendable(SendableBuilder& builder) override; -}; - -} // namespace frc diff --git a/wpilibc/src/main/native/include/frc/romi/RomiGyro.h b/wpilibc/src/main/native/include/frc/romi/RomiGyro.h index 391e26b700..eb33efc559 100644 --- a/wpilibc/src/main/native/include/frc/romi/RomiGyro.h +++ b/wpilibc/src/main/native/include/frc/romi/RomiGyro.h @@ -6,7 +6,10 @@ #include -#include "frc/GyroBase.h" +#include "frc/ErrorBase.h" +#include "frc/interfaces/Gyro.h" +#include "frc/smartdashboard/Sendable.h" +#include "frc/smartdashboard/SendableHelper.h" namespace frc { @@ -16,7 +19,10 @@ namespace frc { * This class is for the Romi onboard gyro, and will only work in * simulation/Romi mode. Only one instance of a RomiGyro is supported. */ -class RomiGyro : public GyroBase { +class RomiGyro : public Gyro, + public ErrorBase, + public Sendable, + public SendableHelper { public: RomiGyro(); @@ -84,6 +90,8 @@ class RomiGyro : public GyroBase { */ void Reset() override; + void InitSendable(SendableBuilder& builder) override; + private: hal::SimDevice m_simDevice; hal::SimDouble m_simRateX; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java index a179f1f870..183960a60d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXRS450_Gyro.java @@ -9,6 +9,8 @@ import edu.wpi.first.hal.HAL; import edu.wpi.first.hal.SimBoolean; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDouble; +import edu.wpi.first.wpilibj.interfaces.Gyro; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -24,7 +26,7 @@ import java.nio.ByteOrder; * an ADXRS Gyro is supported. */ @SuppressWarnings({"TypeName", "AbbreviationAsWordInName", "PMD.UnusedPrivateField"}) -public class ADXRS450_Gyro extends GyroBase { +public class ADXRS450_Gyro implements Gyro, Sendable { private static final double kSamplePeriod = 0.0005; private static final double kCalibrationSampleTime = 5.0; private static final double kDegreePerSecondPerLSB = 0.0125; @@ -206,4 +208,10 @@ public class ADXRS450_Gyro extends GyroBase { } return m_spi.getAccumulatorLastValue() * kDegreePerSecondPerLSB; } + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("Gyro"); + builder.addDoubleProperty("Value", this::getAngle, null); + } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java index 11958cbd2d..2b250d3bbc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogGyro.java @@ -9,6 +9,8 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam; import edu.wpi.first.hal.AnalogGyroJNI; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; +import edu.wpi.first.wpilibj.interfaces.Gyro; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; /** @@ -20,7 +22,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry; * *

This class is for gyro sensors that connect to an analog input. */ -public class AnalogGyro extends GyroBase { +public class AnalogGyro implements Gyro, Sendable { private static final double kDefaultVoltsPerDegreePerSecond = 0.007; protected AnalogInput m_analog; private boolean m_channelAllocated; @@ -188,4 +190,10 @@ public class AnalogGyro extends GyroBase { public AnalogInput getAnalogInput() { return m_analog; } + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("Gyro"); + builder.addDoubleProperty("Value", this::getAngle, null); + } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java deleted file mode 100644 index 8bc1076541..0000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GyroBase.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj; - -import edu.wpi.first.wpilibj.interfaces.Gyro; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; - -/** GyroBase is the common base class for Gyro implementations such as AnalogGyro. */ -public abstract class GyroBase implements Gyro, Sendable { - @Override - public void initSendable(SendableBuilder builder) { - builder.setSmartDashboardType("Gyro"); - builder.addDoubleProperty("Value", this::getAngle, null); - } -} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/romi/RomiGyro.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/romi/RomiGyro.java index ea61795c4e..3c5e228606 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/romi/RomiGyro.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/romi/RomiGyro.java @@ -7,9 +7,11 @@ package edu.wpi.first.wpilibj.romi; import edu.wpi.first.hal.SimDevice; import edu.wpi.first.hal.SimDevice.Direction; import edu.wpi.first.hal.SimDouble; -import edu.wpi.first.wpilibj.GyroBase; +import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.wpilibj.interfaces.Gyro; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -public class RomiGyro extends GyroBase { +public class RomiGyro implements Gyro, Sendable { private final SimDevice m_simDevice; private SimDouble m_simRateX; private SimDouble m_simRateY; @@ -146,4 +148,10 @@ public class RomiGyro extends GyroBase { m_simDevice.close(); } } + + @Override + public void initSendable(SendableBuilder builder) { + builder.setSmartDashboardType("Gyro"); + builder.addDoubleProperty("Value", this::getAngle, null); + } }