[hal, wpilib] Remove built in accelerometer (#7702)

This commit is contained in:
Thad House
2025-01-17 14:06:09 -08:00
committed by GitHub
parent 1600e773f4
commit 5a6c895b87
48 changed files with 0 additions and 2304 deletions

View File

@@ -1,47 +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/BuiltInAccelerometer.h"
#include <hal/Accelerometer.h>
#include <hal/FRCUsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
#include "frc/Errors.h"
using namespace frc;
BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
SetRange(range);
HAL_Report(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
"Built-in accelerometer");
wpi::SendableRegistry::AddLW(this, "BuiltInAccel");
}
void BuiltInAccelerometer::SetRange(Range range) {
HAL_SetAccelerometerActive(false);
HAL_SetAccelerometerRange(static_cast<HAL_AccelerometerRange>(range));
HAL_SetAccelerometerActive(true);
}
double BuiltInAccelerometer::GetX() {
return HAL_GetAccelerometerX();
}
double BuiltInAccelerometer::GetY() {
return HAL_GetAccelerometerY();
}
double BuiltInAccelerometer::GetZ() {
return HAL_GetAccelerometerZ();
}
void BuiltInAccelerometer::InitSendable(wpi::SendableBuilder& builder) {
builder.SetSmartDashboardType("3AxisAccelerometer");
builder.AddDoubleProperty("X", [=, this] { return GetX(); }, nullptr);
builder.AddDoubleProperty("Y", [=, this] { return GetY(); }, nullptr);
builder.AddDoubleProperty("Z", [=, this] { return GetZ(); }, nullptr);
}

View File

@@ -1,108 +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/simulation/BuiltInAccelerometerSim.h"
#include <memory>
#include <hal/simulation/AccelerometerData.h>
#include "frc/BuiltInAccelerometer.h"
using namespace frc;
using namespace frc::sim;
BuiltInAccelerometerSim::BuiltInAccelerometerSim() : m_index{0} {}
BuiltInAccelerometerSim::BuiltInAccelerometerSim(const BuiltInAccelerometer&)
: m_index{0} {}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterActiveCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool BuiltInAccelerometerSim::GetActive() const {
return HALSIM_GetAccelerometerActive(m_index);
}
void BuiltInAccelerometerSim::SetActive(bool active) {
HALSIM_SetAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterRangeCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
HAL_AccelerometerRange BuiltInAccelerometerSim::GetRange() const {
return HALSIM_GetAccelerometerRange(m_index);
}
void BuiltInAccelerometerSim::SetRange(HAL_AccelerometerRange range) {
HALSIM_SetAccelerometerRange(m_index, range);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterXCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerXCallback);
store->SetUid(HALSIM_RegisterAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetX() const {
return HALSIM_GetAccelerometerX(m_index);
}
void BuiltInAccelerometerSim::SetX(double x) {
HALSIM_SetAccelerometerX(m_index, x);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterYCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerYCallback);
store->SetUid(HALSIM_RegisterAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetY() const {
return HALSIM_GetAccelerometerY(m_index);
}
void BuiltInAccelerometerSim::SetY(double y) {
HALSIM_SetAccelerometerY(m_index, y);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterZCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerZCallback);
store->SetUid(HALSIM_RegisterAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetZ() const {
return HALSIM_GetAccelerometerZ(m_index);
}
void BuiltInAccelerometerSim::SetZ(double z) {
HALSIM_SetAccelerometerZ(m_index, z);
}
void BuiltInAccelerometerSim::ResetData() {
HALSIM_ResetAccelerometerData(m_index);
}