mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Upgrade to C++20 (#4239)
* Use explicit this capture required by C++20 * Use C++20 span * Replace wpi::numbers with std::numbers * Fix C++20 clang-tidy warning false positive in fmt * Remove ciso646 include since C++20 removed that header * Fix global-buffer-overflow asan warnings in ntcore tests * Add DIOSetProxy constructor to HAL * Upgrade MSVC compiler to 2022 * Bump native-utils to 2023.2.7 (changes to std=c++20) Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -22,11 +22,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <string>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
#include <wpi/numbers>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
@@ -630,29 +630,29 @@ void ADIS16448_IMU::Acquire() {
|
||||
|
||||
/* Complementary filter functions */
|
||||
double ADIS16448_IMU::FormatFastConverge(double compAngle, double accAngle) {
|
||||
if (compAngle > accAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
} else if (accAngle > compAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > accAngle + std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
} else if (accAngle > compAngle + std::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16448_IMU::FormatRange0to2PI(double compAngle) {
|
||||
while (compAngle >= 2 * wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
while (compAngle >= 2 * std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
while (compAngle < 0.0) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16448_IMU::FormatAccelRange(double accelAngle, double accelZ) {
|
||||
if (accelZ < 0.0) {
|
||||
accelAngle = wpi::numbers::pi - accelAngle;
|
||||
accelAngle = std::numbers::pi - accelAngle;
|
||||
} else if (accelZ > 0.0 && accelAngle < 0.0) {
|
||||
accelAngle = 2.0 * wpi::numbers::pi + accelAngle;
|
||||
accelAngle = 2.0 * std::numbers::pi + accelAngle;
|
||||
}
|
||||
return accelAngle;
|
||||
}
|
||||
@@ -663,8 +663,8 @@ double ADIS16448_IMU::CompFilterProcess(double compAngle, double accelAngle,
|
||||
compAngle =
|
||||
m_alpha * (compAngle + omega * m_dt) + (1.0 - m_alpha) * accelAngle;
|
||||
compAngle = FormatRange0to2PI(compAngle);
|
||||
if (compAngle > wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
@@ -874,5 +874,5 @@ int ADIS16448_IMU::GetPort() const {
|
||||
void ADIS16448_IMU::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("ADIS16448 IMU");
|
||||
builder.AddDoubleProperty(
|
||||
"Yaw Angle", [=] { return GetAngle().value(); }, nullptr);
|
||||
"Yaw Angle", [=, this] { return GetAngle().value(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
#include <frc/Timer.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <string>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
#include <wpi/numbers>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
@@ -647,29 +647,29 @@ void ADIS16470_IMU::Acquire() {
|
||||
|
||||
/* Complementary filter functions */
|
||||
double ADIS16470_IMU::FormatFastConverge(double compAngle, double accAngle) {
|
||||
if (compAngle > accAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
} else if (accAngle > compAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > accAngle + std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
} else if (accAngle > compAngle + std::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16470_IMU::FormatRange0to2PI(double compAngle) {
|
||||
while (compAngle >= 2 * wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
while (compAngle >= 2 * std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
while (compAngle < 0.0) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16470_IMU::FormatAccelRange(double accelAngle, double accelZ) {
|
||||
if (accelZ < 0.0) {
|
||||
accelAngle = wpi::numbers::pi - accelAngle;
|
||||
accelAngle = std::numbers::pi - accelAngle;
|
||||
} else if (accelZ > 0.0 && accelAngle < 0.0) {
|
||||
accelAngle = 2.0 * wpi::numbers::pi + accelAngle;
|
||||
accelAngle = 2.0 * std::numbers::pi + accelAngle;
|
||||
}
|
||||
return accelAngle;
|
||||
}
|
||||
@@ -680,8 +680,8 @@ double ADIS16470_IMU::CompFilterProcess(double compAngle, double accelAngle,
|
||||
compAngle =
|
||||
m_alpha * (compAngle + omega * m_dt) + (1.0 - m_alpha) * accelAngle;
|
||||
compAngle = FormatRange0to2PI(compAngle);
|
||||
if (compAngle > wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
@@ -809,5 +809,5 @@ int ADIS16470_IMU::GetPort() const {
|
||||
void ADIS16470_IMU::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("ADIS16470 IMU");
|
||||
builder.AddDoubleProperty(
|
||||
"Yaw Angle", [=] { return GetAngle().value(); }, nullptr);
|
||||
"Yaw Angle", [=, this] { return GetAngle().value(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -137,5 +137,5 @@ int ADXRS450_Gyro::GetPort() const {
|
||||
void ADXRS450_Gyro::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Gyro");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetAngle(); }, nullptr);
|
||||
"Value", [=, this] { return GetAngle(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ void AddressableLED::SetLength(int length) {
|
||||
static_assert(sizeof(AddressableLED::LEDData) == sizeof(HAL_AddressableLEDData),
|
||||
"LED Structs MUST be the same size");
|
||||
|
||||
void AddressableLED::SetData(wpi::span<const LEDData> ledData) {
|
||||
void AddressableLED::SetData(std::span<const LEDData> ledData) {
|
||||
int32_t status = 0;
|
||||
HAL_WriteAddressableLEDData(m_handle, ledData.begin(), ledData.size(),
|
||||
HAL_WriteAddressableLEDData(m_handle, ledData.data(), ledData.size(),
|
||||
&status);
|
||||
FRC_CheckErrorStatus(status, "Port {}", m_port);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ void AnalogAccelerometer::SetZero(double zero) {
|
||||
void AnalogAccelerometer::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Accelerometer");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetAcceleration(); }, nullptr);
|
||||
"Value", [=, this] { return GetAcceleration(); }, nullptr);
|
||||
}
|
||||
|
||||
void AnalogAccelerometer::InitAccelerometer() {
|
||||
|
||||
@@ -140,5 +140,5 @@ std::shared_ptr<AnalogInput> AnalogGyro::GetAnalogInput() const {
|
||||
void AnalogGyro::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Gyro");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetAngle(); }, nullptr);
|
||||
"Value", [=, this] { return GetAngle(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -197,5 +197,5 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
void AnalogInput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetAverageVoltage(); }, nullptr);
|
||||
"Value", [=, this] { return GetAverageVoltage(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,6 @@ int AnalogOutput::GetChannel() const {
|
||||
void AnalogOutput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Output");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetVoltage(); },
|
||||
[=](double value) { SetVoltage(value); });
|
||||
"Value", [=, this] { return GetVoltage(); },
|
||||
[=, this](double value) { SetVoltage(value); });
|
||||
}
|
||||
|
||||
@@ -46,5 +46,5 @@ double AnalogPotentiometer::Get() const {
|
||||
void AnalogPotentiometer::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, nullptr);
|
||||
"Value", [=, this] { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ double BuiltInAccelerometer::GetZ() {
|
||||
void BuiltInAccelerometer::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("3AxisAccelerometer");
|
||||
builder.AddDoubleProperty(
|
||||
"X", [=] { return GetX(); }, nullptr);
|
||||
"X", [=, this] { return GetX(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Y", [=] { return GetY(); }, nullptr);
|
||||
"Y", [=, this] { return GetY(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Z", [=] { return GetZ(); }, nullptr);
|
||||
"Z", [=, this] { return GetZ(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ CompressorConfigType Compressor::GetConfigType() const {
|
||||
void Compressor::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Compressor");
|
||||
builder.AddBooleanProperty(
|
||||
"Enabled", [=] { return IsEnabled(); }, nullptr);
|
||||
"Enabled", [this] { return IsEnabled(); }, nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr);
|
||||
"Pressure switch", [this] { return GetPressureSwitchValue(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -309,5 +309,5 @@ bool Counter::GetDirection() const {
|
||||
void Counter::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Counter");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, nullptr);
|
||||
"Value", [=, this] { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -69,5 +69,5 @@ int DigitalInput::GetChannel() const {
|
||||
void DigitalInput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Input");
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=] { return Get(); }, nullptr);
|
||||
"Value", [=, this] { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -143,5 +143,6 @@ void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
void DigitalOutput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Output");
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=] { return Get(); }, [=](bool value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](bool value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ bool DoubleSolenoid::IsRevSolenoidDisabled() const {
|
||||
void DoubleSolenoid::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Double Solenoid");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { Set(kOff); });
|
||||
builder.SetSafeState([=, this] { Set(kOff); });
|
||||
builder.AddSmallStringProperty(
|
||||
"Value",
|
||||
[=](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
switch (Get()) {
|
||||
case kForward:
|
||||
return "Forward";
|
||||
@@ -142,7 +142,7 @@ void DoubleSolenoid::InitSendable(wpi::SendableBuilder& builder) {
|
||||
return "Off";
|
||||
}
|
||||
},
|
||||
[=](std::string_view value) {
|
||||
[=, this](std::string_view value) {
|
||||
Value lvalue = kOff;
|
||||
if (value == "Forward") {
|
||||
lvalue = kForward;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
@@ -846,7 +847,7 @@ void JoystickLogSender::Init(wpi::log::DataLog& log, unsigned int stick,
|
||||
HAL_GetJoystickPOVs(m_stick, &m_prevPOVs);
|
||||
AppendButtons(m_prevButtons, timestamp);
|
||||
m_logAxes.Append(
|
||||
wpi::span<const float>{m_prevAxes.axes,
|
||||
std::span<const float>{m_prevAxes.axes,
|
||||
static_cast<size_t>(m_prevAxes.count)},
|
||||
timestamp);
|
||||
AppendPOVs(m_prevPOVs, timestamp);
|
||||
@@ -867,7 +868,7 @@ void JoystickLogSender::Send(uint64_t timestamp) {
|
||||
std::memcmp(axes.axes, m_prevAxes.axes,
|
||||
sizeof(axes.axes[0]) * axes.count) != 0) {
|
||||
m_logAxes.Append(
|
||||
wpi::span<const float>{axes.axes, static_cast<size_t>(axes.count)},
|
||||
std::span<const float>{axes.axes, static_cast<size_t>(axes.count)},
|
||||
timestamp);
|
||||
}
|
||||
m_prevAxes = axes;
|
||||
@@ -888,7 +889,7 @@ void JoystickLogSender::AppendButtons(HAL_JoystickButtons buttons,
|
||||
for (unsigned int i = 0; i < buttons.count; ++i) {
|
||||
buttonsArr[i] = (buttons.buttons & (1u << i)) != 0;
|
||||
}
|
||||
m_logButtons.Append(wpi::span<const uint8_t>{buttonsArr, buttons.count},
|
||||
m_logButtons.Append(std::span<const uint8_t>{buttonsArr, buttons.count},
|
||||
timestamp);
|
||||
}
|
||||
|
||||
@@ -899,7 +900,7 @@ void JoystickLogSender::AppendPOVs(const HAL_JoystickPOVs& povs,
|
||||
povsArr[i] = povs.povs[i];
|
||||
}
|
||||
m_logPOVs.Append(
|
||||
wpi::span<const int64_t>{povsArr, static_cast<size_t>(povs.count)},
|
||||
std::span<const int64_t>{povsArr, static_cast<size_t>(povs.count)},
|
||||
timestamp);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,11 +217,12 @@ void Encoder::InitSendable(wpi::SendableBuilder& builder) {
|
||||
}
|
||||
|
||||
builder.AddDoubleProperty(
|
||||
"Speed", [=] { return GetRate(); }, nullptr);
|
||||
"Speed", [=, this] { return GetRate(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance", [=] { return GetDistance(); }, nullptr);
|
||||
"Distance", [=, this] { return GetDistance(); }, nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"Distance per Tick", [=] { return GetDistancePerPulse(); }, nullptr);
|
||||
"Distance per Tick", [=, this] { return GetDistancePerPulse(); },
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "frc/Joystick.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -124,5 +124,5 @@ double Joystick::GetDirectionRadians() const {
|
||||
}
|
||||
|
||||
double Joystick::GetDirectionDegrees() const {
|
||||
return (180 / wpi::numbers::pi) * GetDirectionRadians();
|
||||
return (180 / std::numbers::pi) * GetDirectionRadians();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ Notifier::Notifier(std::function<void()> handler) {
|
||||
m_notifier = HAL_InitializeNotifier(&status);
|
||||
FRC_CheckErrorStatus(status, "{}", "InitializeNotifier");
|
||||
|
||||
m_thread = std::thread([=] {
|
||||
m_thread = std::thread([=, this] {
|
||||
for (;;) {
|
||||
int32_t status = 0;
|
||||
HAL_NotifierHandle notifier = m_notifier.load();
|
||||
@@ -67,7 +67,7 @@ Notifier::Notifier(int priority, std::function<void()> handler) {
|
||||
m_notifier = HAL_InitializeNotifier(&status);
|
||||
FRC_CheckErrorStatus(status, "{}", "InitializeNotifier");
|
||||
|
||||
m_thread = std::thread([=] {
|
||||
m_thread = std::thread([=, this] {
|
||||
int32_t status = 0;
|
||||
HAL_SetCurrentThreadPriority(true, priority, &status);
|
||||
for (;;) {
|
||||
|
||||
@@ -166,7 +166,8 @@ int PWM::GetChannel() const {
|
||||
void PWM::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PWM");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { SetDisabled(); });
|
||||
builder.SetSafeState([=, this] { SetDisabled(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return GetRaw(); }, [=](double value) { SetRaw(value); });
|
||||
"Value", [=, this] { return GetRaw(); },
|
||||
[=, this](double value) { SetRaw(value); });
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void PowerDistribution::InitSendable(wpi::SendableBuilder& builder) {
|
||||
for (int i = 0; i < numChannels; ++i) {
|
||||
builder.AddDoubleProperty(
|
||||
fmt::format("Chan{}", i),
|
||||
[=] {
|
||||
[=, this] {
|
||||
int32_t lStatus = 0;
|
||||
return HAL_GetPowerDistributionChannelCurrent(m_handle, i, &lStatus);
|
||||
},
|
||||
@@ -203,25 +203,25 @@ void PowerDistribution::InitSendable(wpi::SendableBuilder& builder) {
|
||||
}
|
||||
builder.AddDoubleProperty(
|
||||
"Voltage",
|
||||
[=] {
|
||||
[=, this] {
|
||||
int32_t lStatus = 0;
|
||||
return HAL_GetPowerDistributionVoltage(m_handle, &lStatus);
|
||||
},
|
||||
nullptr);
|
||||
builder.AddDoubleProperty(
|
||||
"TotalCurrent",
|
||||
[=] {
|
||||
[=, this] {
|
||||
int32_t lStatus = 0;
|
||||
return HAL_GetPowerDistributionTotalCurrent(m_handle, &lStatus);
|
||||
},
|
||||
nullptr);
|
||||
builder.AddBooleanProperty(
|
||||
"SwitchableChannel",
|
||||
[=] {
|
||||
[=, this] {
|
||||
int32_t lStatus = 0;
|
||||
return HAL_GetPowerDistributionSwitchableChannel(m_handle, &lStatus);
|
||||
},
|
||||
[=](bool value) {
|
||||
[=, this](bool value) {
|
||||
int32_t lStatus = 0;
|
||||
HAL_SetPowerDistributionSwitchableChannel(m_handle, value, &lStatus);
|
||||
});
|
||||
|
||||
@@ -175,10 +175,10 @@ std::string Relay::GetDescription() const {
|
||||
void Relay::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Relay");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { Set(kOff); });
|
||||
builder.SetSafeState([=, this] { Set(kOff); });
|
||||
builder.AddSmallStringProperty(
|
||||
"Value",
|
||||
[=](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
switch (Get()) {
|
||||
case kOn:
|
||||
return "On";
|
||||
@@ -190,7 +190,7 @@ void Relay::InitSendable(wpi::SendableBuilder& builder) {
|
||||
return "Off";
|
||||
}
|
||||
},
|
||||
[=](std::string_view value) {
|
||||
[=, this](std::string_view value) {
|
||||
if (value == "Off") {
|
||||
Set(kOff);
|
||||
} else if (value == "Forward") {
|
||||
|
||||
@@ -25,7 +25,7 @@ class SPI::Accumulator {
|
||||
public:
|
||||
Accumulator(HAL_SPIPort port, int xferSize, int validMask, int validValue,
|
||||
int dataShift, int dataSize, bool isSigned, bool bigEndian)
|
||||
: m_notifier([=] {
|
||||
: m_notifier([=, this] {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
Update();
|
||||
}),
|
||||
@@ -268,7 +268,7 @@ void SPI::FreeAuto() {
|
||||
FRC_CheckErrorStatus(status, "Port {}", static_cast<int>(m_port));
|
||||
}
|
||||
|
||||
void SPI::SetAutoTransmitData(wpi::span<const uint8_t> dataToSend,
|
||||
void SPI::SetAutoTransmitData(std::span<const uint8_t> dataToSend,
|
||||
int zeroSize) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSPIAutoTransmitData(m_port, dataToSend.data(), dataToSend.size(),
|
||||
|
||||
@@ -64,7 +64,8 @@ double Servo::GetMinAngle() const {
|
||||
void Servo::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Servo");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, [=](double value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](double value) { Set(value); });
|
||||
}
|
||||
|
||||
double Servo::GetServoAngleRange() const {
|
||||
|
||||
@@ -77,7 +77,8 @@ void Solenoid::StartPulse() {
|
||||
void Solenoid::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Solenoid");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { Set(false); });
|
||||
builder.SetSafeState([=, this] { Set(false); });
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=] { return Get(); }, [=](bool value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](bool value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void TimedRobot::EndCompetition() {
|
||||
|
||||
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
|
||||
m_startTime = Timer::GetFPGATimestamp();
|
||||
AddPeriodic([=] { LoopFunc(); }, period);
|
||||
AddPeriodic([=, this] { LoopFunc(); }, period);
|
||||
|
||||
int32_t status = 0;
|
||||
m_notifier = HAL_InitializeNotifier(&status);
|
||||
|
||||
@@ -157,7 +157,8 @@ void Ultrasonic::SetEnabled(bool enable) {
|
||||
void Ultrasonic::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Ultrasonic");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return units::inch_t{GetRange()}.value(); }, nullptr);
|
||||
"Value", [=, this] { return units::inch_t{GetRange()}.value(); },
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void Ultrasonic::Initialize() {
|
||||
|
||||
@@ -50,7 +50,7 @@ Watchdog::Impl::Impl() {
|
||||
FRC_CheckErrorStatus(status, "{}", "starting watchdog notifier");
|
||||
HAL_SetNotifierName(m_notifier, "Watchdog", &status);
|
||||
|
||||
m_thread = std::thread([=] { Main(); });
|
||||
m_thread = std::thread([=, this] { Main(); });
|
||||
}
|
||||
|
||||
Watchdog::Impl::~Impl() {
|
||||
|
||||
@@ -189,11 +189,11 @@ std::string DifferentialDrive::GetDescription() const {
|
||||
void DifferentialDrive::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("DifferentialDrive");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.SetSafeState([=, this] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Left Motor Speed", [=] { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
"Left Motor Speed", [=, this] { return m_leftMotor->Get(); },
|
||||
[=, this](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Right Motor Speed", [=] { return m_rightMotor->Get(); },
|
||||
[=](double value) { m_rightMotor->Set(value); });
|
||||
"Right Motor Speed", [=, this] { return m_rightMotor->Get(); },
|
||||
[=, this](double value) { m_rightMotor->Set(value); });
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/numbers>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
@@ -30,12 +30,12 @@ KilloughDrive::KilloughDrive(MotorController& leftMotor,
|
||||
: m_leftMotor(&leftMotor),
|
||||
m_rightMotor(&rightMotor),
|
||||
m_backMotor(&backMotor) {
|
||||
m_leftVec = {std::cos(leftMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(leftMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(rightMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (wpi::numbers::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (wpi::numbers::pi / 180.0))};
|
||||
m_leftVec = {std::cos(leftMotorAngle * (std::numbers::pi / 180.0)),
|
||||
std::sin(leftMotorAngle * (std::numbers::pi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (std::numbers::pi / 180.0)),
|
||||
std::sin(rightMotorAngle * (std::numbers::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (std::numbers::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (std::numbers::pi / 180.0))};
|
||||
wpi::SendableRegistry::AddChild(this, m_leftMotor);
|
||||
wpi::SendableRegistry::AddChild(this, m_rightMotor);
|
||||
wpi::SendableRegistry::AddChild(this, m_backMotor);
|
||||
@@ -73,8 +73,8 @@ void KilloughDrive::DrivePolar(double magnitude, double angle,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
DriveCartesian(magnitude * std::sin(angle * (wpi::numbers::pi / 180.0)),
|
||||
magnitude * std::cos(angle * (wpi::numbers::pi / 180.0)),
|
||||
DriveCartesian(magnitude * std::sin(angle * (std::numbers::pi / 180.0)),
|
||||
magnitude * std::cos(angle * (std::numbers::pi / 180.0)),
|
||||
zRotation, 0.0);
|
||||
}
|
||||
|
||||
@@ -113,14 +113,14 @@ std::string KilloughDrive::GetDescription() const {
|
||||
void KilloughDrive::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("KilloughDrive");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.SetSafeState([=, this] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Left Motor Speed", [=] { return m_leftMotor->Get(); },
|
||||
[=](double value) { m_leftMotor->Set(value); });
|
||||
"Left Motor Speed", [=, this] { return m_leftMotor->Get(); },
|
||||
[=, this](double value) { m_leftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Right Motor Speed", [=] { return m_rightMotor->Get(); },
|
||||
[=](double value) { m_rightMotor->Set(value); });
|
||||
"Right Motor Speed", [=, this] { return m_rightMotor->Get(); },
|
||||
[=, this](double value) { m_rightMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Back Motor Speed", [=] { return m_backMotor->Get(); },
|
||||
[=](double value) { m_backMotor->Set(value); });
|
||||
"Back Motor Speed", [=, this] { return m_backMotor->Get(); },
|
||||
[=, this](double value) { m_backMotor->Set(value); });
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/numbers>
|
||||
#include <wpi/sendable/SendableBuilder.h>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
@@ -65,8 +65,8 @@ void MecanumDrive::DrivePolar(double magnitude, double angle,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
DriveCartesian(magnitude * std::cos(angle * (wpi::numbers::pi / 180.0)),
|
||||
magnitude * std::sin(angle * (wpi::numbers::pi / 180.0)),
|
||||
DriveCartesian(magnitude * std::cos(angle * (std::numbers::pi / 180.0)),
|
||||
magnitude * std::sin(angle * (std::numbers::pi / 180.0)),
|
||||
zRotation, 0.0);
|
||||
}
|
||||
|
||||
@@ -108,17 +108,17 @@ std::string MecanumDrive::GetDescription() const {
|
||||
void MecanumDrive::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("MecanumDrive");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.SetSafeState([=, this] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Front Left Motor Speed", [=] { return m_frontLeftMotor->Get(); },
|
||||
[=](double value) { m_frontLeftMotor->Set(value); });
|
||||
"Front Left Motor Speed", [=, this] { return m_frontLeftMotor->Get(); },
|
||||
[=, this](double value) { m_frontLeftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Front Right Motor Speed", [=] { return m_frontRightMotor->Get(); },
|
||||
[=](double value) { m_frontRightMotor->Set(value); });
|
||||
"Front Right Motor Speed", [=, this] { return m_frontRightMotor->Get(); },
|
||||
[=, this](double value) { m_frontRightMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Rear Left Motor Speed", [=] { return m_rearLeftMotor->Get(); },
|
||||
[=](double value) { m_rearLeftMotor->Set(value); });
|
||||
"Rear Left Motor Speed", [=, this] { return m_rearLeftMotor->Get(); },
|
||||
[=, this](double value) { m_rearLeftMotor->Set(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"Rear Right Motor Speed", [=] { return m_rearRightMotor->Get(); },
|
||||
[=](double value) { m_rearRightMotor->Set(value); });
|
||||
"Rear Right Motor Speed", [=, this] { return m_rearRightMotor->Get(); },
|
||||
[=, this](double value) { m_rearRightMotor->Set(value); });
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ void RobotDriveBase::FeedWatchdog() {
|
||||
Feed();
|
||||
}
|
||||
|
||||
void RobotDriveBase::Desaturate(wpi::span<double> wheelSpeeds) {
|
||||
void RobotDriveBase::Desaturate(std::span<double> wheelSpeeds) {
|
||||
double maxMagnitude = std::abs(wheelSpeeds[0]);
|
||||
for (size_t i = 1; i < wheelSpeeds.size(); i++) {
|
||||
double temp = std::abs(wheelSpeeds[i]);
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include "frc/drive/Vector2d.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -16,8 +15,8 @@ Vector2d::Vector2d(double x, double y) {
|
||||
}
|
||||
|
||||
void Vector2d::Rotate(double angle) {
|
||||
double cosA = std::cos(angle * (wpi::numbers::pi / 180.0));
|
||||
double sinA = std::sin(angle * (wpi::numbers::pi / 180.0));
|
||||
double cosA = std::cos(angle * (std::numbers::pi / 180.0));
|
||||
double sinA = std::sin(angle * (std::numbers::pi / 180.0));
|
||||
double out[2];
|
||||
out[0] = x * cosA - y * sinA;
|
||||
out[1] = x * sinA + y * cosA;
|
||||
|
||||
@@ -69,7 +69,8 @@ void MotorControllerGroup::StopMotor() {
|
||||
void MotorControllerGroup::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Motor Controller");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.SetSafeState([=, this] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, [=](double value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](double value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ int NidecBrushless::GetChannel() const {
|
||||
void NidecBrushless::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Nidec Brushless");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { StopMotor(); });
|
||||
builder.SetSafeState([=, this] { StopMotor(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, [=](double value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](double value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ PWMMotorController::PWMMotorController(std::string_view name, int channel)
|
||||
void PWMMotorController::InitSendable(wpi::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Motor Controller");
|
||||
builder.SetActuator(true);
|
||||
builder.SetSafeState([=] { Disable(); });
|
||||
builder.SetSafeState([=, this] { Disable(); });
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=] { return Get(); }, [=](double value) { Set(value); });
|
||||
"Value", [=, this] { return Get(); },
|
||||
[=, this](double value) { Set(value); });
|
||||
}
|
||||
|
||||
@@ -118,27 +118,27 @@ SimpleWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
wpi::span<const bool> defaultValue) {
|
||||
std::span<const bool> defaultValue) {
|
||||
return Add(title, nt::Value::MakeBooleanArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
wpi::span<const double> defaultValue) {
|
||||
std::span<const double> defaultValue) {
|
||||
return Add(title, nt::Value::MakeDoubleArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
wpi::span<const float> defaultValue) {
|
||||
std::span<const float> defaultValue) {
|
||||
return Add(title, nt::Value::MakeFloatArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(
|
||||
std::string_view title, wpi::span<const int64_t> defaultValue) {
|
||||
std::string_view title, std::span<const int64_t> defaultValue) {
|
||||
return Add(title, nt::Value::MakeIntegerArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::Add(
|
||||
std::string_view title, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view title, std::span<const std::string> defaultValue) {
|
||||
return Add(title, nt::Value::MakeStringArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -353,27 +353,27 @@ SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, wpi::span<const bool> defaultValue) {
|
||||
std::string_view title, std::span<const bool> defaultValue) {
|
||||
return AddPersistent(title, nt::Value::MakeBooleanArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, wpi::span<const double> defaultValue) {
|
||||
std::string_view title, std::span<const double> defaultValue) {
|
||||
return AddPersistent(title, nt::Value::MakeDoubleArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, wpi::span<const float> defaultValue) {
|
||||
std::string_view title, std::span<const float> defaultValue) {
|
||||
return AddPersistent(title, nt::Value::MakeFloatArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, wpi::span<const int64_t> defaultValue) {
|
||||
std::string_view title, std::span<const int64_t> defaultValue) {
|
||||
return AddPersistent(title, nt::Value::MakeIntegerArray(defaultValue));
|
||||
}
|
||||
|
||||
SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view title, std::span<const std::string> defaultValue) {
|
||||
return AddPersistent(title, nt::Value::MakeStringArray(defaultValue));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Pose2d FieldObject2d::GetPose() const {
|
||||
return m_poses[0];
|
||||
}
|
||||
|
||||
void FieldObject2d::SetPoses(wpi::span<const Pose2d> poses) {
|
||||
void FieldObject2d::SetPoses(std::span<const Pose2d> poses) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_poses.assign(poses.begin(), poses.end());
|
||||
UpdateEntry();
|
||||
@@ -68,7 +68,7 @@ std::vector<Pose2d> FieldObject2d::GetPoses() const {
|
||||
return std::vector<Pose2d>(m_poses.begin(), m_poses.end());
|
||||
}
|
||||
|
||||
wpi::span<const Pose2d> FieldObject2d::GetPoses(
|
||||
std::span<const Pose2d> FieldObject2d::GetPoses(
|
||||
wpi::SmallVectorImpl<Pose2d>& out) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
UpdateFromEntry();
|
||||
|
||||
@@ -176,35 +176,35 @@ void SendableBuilderImpl::AddStringProperty(
|
||||
|
||||
void SendableBuilderImpl::AddBooleanArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int>()> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) {
|
||||
std::function<void(std::span<const int>)> setter) {
|
||||
AddPropertyImpl(m_table->GetBooleanArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddIntegerArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int64_t>()> getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) {
|
||||
std::function<void(std::span<const int64_t>)> setter) {
|
||||
AddPropertyImpl(m_table->GetIntegerArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddFloatArrayProperty(
|
||||
std::string_view key, std::function<std::vector<float>()> getter,
|
||||
std::function<void(wpi::span<const float>)> setter) {
|
||||
std::function<void(std::span<const float>)> setter) {
|
||||
AddPropertyImpl(m_table->GetFloatArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddDoubleArrayProperty(
|
||||
std::string_view key, std::function<std::vector<double>()> getter,
|
||||
std::function<void(wpi::span<const double>)> setter) {
|
||||
std::function<void(std::span<const double>)> setter) {
|
||||
AddPropertyImpl(m_table->GetDoubleArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddStringArrayProperty(
|
||||
std::string_view key, std::function<std::vector<std::string>()> getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) {
|
||||
std::function<void(std::span<const std::string>)> setter) {
|
||||
AddPropertyImpl(m_table->GetStringArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void SendableBuilderImpl::AddStringArrayProperty(
|
||||
void SendableBuilderImpl::AddRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<std::vector<uint8_t>()> getter,
|
||||
std::function<void(wpi::span<const uint8_t>)> setter) {
|
||||
std::function<void(std::span<const uint8_t>)> setter) {
|
||||
auto topic = m_table->GetRawTopic(key);
|
||||
auto prop = std::make_unique<PropertyImpl<nt::RawTopic>>();
|
||||
if (getter) {
|
||||
@@ -265,35 +265,35 @@ void SendableBuilderImpl::AddSmallStringProperty(
|
||||
|
||||
void SendableBuilderImpl::AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int>(wpi::SmallVectorImpl<int>& buf)> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) {
|
||||
std::function<std::span<const int>(wpi::SmallVectorImpl<int>& buf)> getter,
|
||||
std::function<void(std::span<const int>)> setter) {
|
||||
AddSmallPropertyImpl<int, 16>(m_table->GetBooleanArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallIntegerArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
std::function<std::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) {
|
||||
std::function<void(std::span<const int64_t>)> setter) {
|
||||
AddSmallPropertyImpl<int64_t, 16>(m_table->GetIntegerArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallFloatArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const float>(wpi::SmallVectorImpl<float>& buf)>
|
||||
std::function<std::span<const float>(wpi::SmallVectorImpl<float>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const float>)> setter) {
|
||||
std::function<void(std::span<const float>)> setter) {
|
||||
AddSmallPropertyImpl<float, 16>(m_table->GetFloatArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallDoubleArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
std::function<std::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const double>)> setter) {
|
||||
std::function<void(std::span<const double>)> setter) {
|
||||
AddSmallPropertyImpl<double, 16>(m_table->GetDoubleArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
@@ -301,18 +301,18 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty(
|
||||
void SendableBuilderImpl::AddSmallStringArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
wpi::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
std::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) {
|
||||
std::function<void(std::span<const std::string>)> setter) {
|
||||
AddSmallPropertyImpl<std::string, 16>(m_table->GetStringArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<wpi::span<uint8_t>(wpi::SmallVectorImpl<uint8_t>& buf)>
|
||||
std::function<std::span<uint8_t>(wpi::SmallVectorImpl<uint8_t>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const uint8_t>)> setter) {
|
||||
std::function<void(std::span<const uint8_t>)> setter) {
|
||||
auto topic = m_table->GetRawTopic(key);
|
||||
auto prop = std::make_unique<PropertyImpl<nt::RawTopic>>();
|
||||
if (getter) {
|
||||
|
||||
@@ -157,63 +157,63 @@ std::string SmartDashboard::GetString(std::string_view keyName,
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutBooleanArray(std::string_view key,
|
||||
wpi::span<const int> value) {
|
||||
std::span<const int> value) {
|
||||
return GetInstance().table->GetEntry(key).SetBooleanArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultBooleanArray(std::string_view key,
|
||||
wpi::span<const int> defaultValue) {
|
||||
std::span<const int> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultBooleanArray(
|
||||
defaultValue);
|
||||
}
|
||||
|
||||
std::vector<int> SmartDashboard::GetBooleanArray(
|
||||
std::string_view key, wpi::span<const int> defaultValue) {
|
||||
std::string_view key, std::span<const int> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetBooleanArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutNumberArray(std::string_view key,
|
||||
wpi::span<const double> value) {
|
||||
std::span<const double> value) {
|
||||
return GetInstance().table->GetEntry(key).SetDoubleArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue) {
|
||||
std::string_view key, std::span<const double> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<double> SmartDashboard::GetNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue) {
|
||||
std::string_view key, std::span<const double> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutStringArray(std::string_view key,
|
||||
wpi::span<const std::string> value) {
|
||||
std::span<const std::string> value) {
|
||||
return GetInstance().table->GetEntry(key).SetStringArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultStringArray(
|
||||
std::string_view key, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view key, std::span<const std::string> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultStringArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<std::string> SmartDashboard::GetStringArray(
|
||||
std::string_view key, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view key, std::span<const std::string> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetStringArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> value) {
|
||||
std::span<const uint8_t> value) {
|
||||
return GetInstance().table->GetEntry(key).SetRaw(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> defaultValue) {
|
||||
std::span<const uint8_t> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultRaw(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> SmartDashboard::GetRaw(
|
||||
std::string_view key, wpi::span<const uint8_t> defaultValue) {
|
||||
std::string_view key, std::span<const uint8_t> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetRaw(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user