[hal, wpilib] Remove analog accumulator and analog gyro (#7697)

The 2 high level classes were temporarily kept to keep the examples compiling. We will remove those when we have the interface into the built in IMU.
This commit is contained in:
Thad House
2025-01-17 12:58:31 -08:00
committed by GitHub
parent 92f0a3c961
commit f80874dd4b
76 changed files with 33 additions and 3886 deletions

View File

@@ -1,97 +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 "AnalogGyroSimGui.h"
#include <memory>
#include <vector>
#include <glass/hardware/AnalogGyro.h>
#include <glass/other/DeviceTree.h>
#include <hal/Ports.h>
#include <hal/Value.h>
#include <hal/simulation/AnalogGyroData.h>
#include "HALDataSource.h"
#include "HALSimGui.h"
#include "SimDeviceGui.h"
using namespace halsimgui;
namespace {
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(AnalogGyroAngle, "AGyro Angle");
HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(AnalogGyroRate, "AGyro Rate");
class AnalogGyroSimModel : public glass::AnalogGyroModel {
public:
explicit AnalogGyroSimModel(int32_t index)
: m_index{index}, m_angle{index}, m_rate{index} {}
void Update() override {}
bool Exists() override { return HALSIM_GetAnalogGyroInitialized(m_index); }
glass::DoubleSource* GetAngleData() override { return &m_angle; }
glass::DoubleSource* GetRateData() override { return &m_rate; }
void SetAngle(double val) override {
HALSIM_SetAnalogGyroAngle(m_index, val);
}
void SetRate(double val) override { HALSIM_SetAnalogGyroRate(m_index, val); }
private:
int32_t m_index;
AnalogGyroAngleSource m_angle;
AnalogGyroRateSource m_rate;
};
class AnalogGyrosSimModel : public glass::AnalogGyrosModel {
public:
AnalogGyrosSimModel() : m_models(HAL_GetNumAccumulators()) {}
void Update() override;
bool Exists() override { return true; }
void ForEachAnalogGyro(
wpi::function_ref<void(glass::AnalogGyroModel& model, int index)> func)
override;
private:
// indexed by channel
std::vector<std::unique_ptr<AnalogGyroSimModel>> m_models;
};
} // namespace
void AnalogGyrosSimModel::Update() {
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
++i) {
auto& model = m_models[i];
if (HALSIM_GetAnalogGyroInitialized(i)) {
if (!model) {
model = std::make_unique<AnalogGyroSimModel>(i);
}
} else {
model.reset();
}
}
}
void AnalogGyrosSimModel::ForEachAnalogGyro(
wpi::function_ref<void(glass::AnalogGyroModel& model, int index)> func) {
for (int32_t i = 0, iend = static_cast<int32_t>(m_models.size()); i < iend;
++i) {
if (auto model = m_models[i].get()) {
func(*model, i);
}
}
}
void AnalogGyroSimGui::Initialize() {
SimDeviceGui::GetDeviceTree().Add(
std::make_unique<AnalogGyrosSimModel>(), [](glass::Model* model) {
glass::DisplayAnalogGyrosDevice(
static_cast<AnalogGyrosSimModel*>(model));
});
}

View File

@@ -1,14 +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
namespace halsimgui {
class AnalogGyroSimGui {
public:
static void Initialize();
};
} // namespace halsimgui

View File

@@ -10,7 +10,6 @@
#include <glass/View.h>
#include <glass/hardware/AnalogInput.h>
#include <hal/Ports.h>
#include <hal/simulation/AnalogGyroData.h>
#include <hal/simulation/AnalogInData.h>
#include <hal/simulation/SimDeviceData.h>
@@ -31,11 +30,6 @@ class AnalogInputSimModel : public glass::AnalogInputModel {
bool Exists() override { return HALSIM_GetAnalogInInitialized(m_index); }
bool IsGyro() const override {
return m_index < HAL_GetNumAccumulators() &&
HALSIM_GetAnalogGyroInitialized(m_index);
}
const char* GetSimDevice() const override {
if (auto simDevice = HALSIM_GetAnalogInSimDevice(m_index)) {
return HALSIM_GetSimDeviceName(simDevice);

View File

@@ -17,7 +17,6 @@
#include "AccelerometerSimGui.h"
#include "AddressableLEDGui.h"
#include "AnalogGyroSimGui.h"
#include "AnalogInputSimGui.h"
#include "DIOSimGui.h"
#include "DriverStationGui.h"
@@ -76,7 +75,6 @@ __declspec(dllexport)
AccelerometerSimGui::Initialize();
AddressableLEDGui::Initialize();
AnalogGyroSimGui::Initialize();
AnalogInputSimGui::Initialize();
DIOSimGui::Initialize();
NetworkTablesSimGui::Initialize();