mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +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);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
|
||||
#include <hal/AddressableLEDTypes.h>
|
||||
#include <hal/Types.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "util/Color.h"
|
||||
#include "util/Color8Bit.h"
|
||||
@@ -107,7 +107,7 @@ class AddressableLED {
|
||||
*
|
||||
* @param ledData the buffer to write
|
||||
*/
|
||||
void SetData(wpi::span<const LEDData> ledData);
|
||||
void SetData(std::span<const LEDData> ledData);
|
||||
|
||||
/**
|
||||
* Sets the led output data.
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include <hal/SPITypes.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/deprecated.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -196,7 +196,7 @@ class SPI {
|
||||
* @param dataToSend data to send (maximum 16 bytes)
|
||||
* @param zeroSize number of zeros to send after the data
|
||||
*/
|
||||
void SetAutoTransmitData(wpi::span<const uint8_t> dataToSend, int zeroSize);
|
||||
void SetAutoTransmitData(std::span<const uint8_t> dataToSend, int zeroSize);
|
||||
|
||||
/**
|
||||
* Start running the automatic SPI transfer engine at a periodic rate.
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc/MotorSafety.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -75,7 +74,7 @@ class RobotDriveBase : public MotorSafety {
|
||||
* Renormalize all wheel speeds if the magnitude of any wheel is greater than
|
||||
* 1.0.
|
||||
*/
|
||||
static void Desaturate(wpi::span<double> wheelSpeeds);
|
||||
static void Desaturate(std::span<double> wheelSpeeds);
|
||||
|
||||
double m_deadband = 0.02;
|
||||
double m_maxOutput = 1.0;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -25,7 +26,6 @@ using CS_Source = CS_Handle; // NOLINT
|
||||
#include <networktables/StringArrayTopic.h>
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -64,7 +64,7 @@ class SendableCameraWrapper
|
||||
* @param cameraUrls camera URLs
|
||||
*/
|
||||
SendableCameraWrapper(std::string_view cameraName,
|
||||
wpi::span<const std::string> cameraUrls,
|
||||
std::span<const std::string> cameraUrls,
|
||||
const private_init&);
|
||||
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ class SendableCameraWrapper
|
||||
static SendableCameraWrapper& Wrap(CS_Source source);
|
||||
|
||||
static SendableCameraWrapper& Wrap(std::string_view cameraName,
|
||||
wpi::span<const std::string> cameraUrls);
|
||||
std::span<const std::string> cameraUrls);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
|
||||
@@ -97,7 +97,7 @@ inline SendableCameraWrapper::SendableCameraWrapper(std::string_view name,
|
||||
}
|
||||
|
||||
inline SendableCameraWrapper::SendableCameraWrapper(
|
||||
std::string_view cameraName, wpi::span<const std::string> cameraUrls,
|
||||
std::string_view cameraName, std::span<const std::string> cameraUrls,
|
||||
const private_init&)
|
||||
: SendableCameraWrapper(cameraName, private_init{}) {
|
||||
m_streams = nt::NetworkTableInstance::GetDefault()
|
||||
@@ -123,7 +123,7 @@ inline SendableCameraWrapper& SendableCameraWrapper::Wrap(CS_Source source) {
|
||||
}
|
||||
|
||||
inline SendableCameraWrapper& SendableCameraWrapper::Wrap(
|
||||
std::string_view cameraName, wpi::span<const std::string> cameraUrls) {
|
||||
std::string_view cameraName, std::span<const std::string> cameraUrls) {
|
||||
auto& wrapper = detail::GetSendableCameraWrapper(cameraName);
|
||||
if (!wrapper) {
|
||||
wrapper = std::make_shared<SendableCameraWrapper>(cameraName, cameraUrls,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -14,7 +15,6 @@
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
#include <wpi/SmallSet.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc/shuffleboard/BuiltInLayouts.h"
|
||||
#include "frc/shuffleboard/LayoutType.h"
|
||||
@@ -137,7 +137,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the camera stream
|
||||
*/
|
||||
ComplexWidget& AddCamera(std::string_view title, std::string_view cameraName,
|
||||
wpi::span<const std::string> cameraUrls);
|
||||
std::span<const std::string> cameraUrls);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given sendable.
|
||||
@@ -259,10 +259,10 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see AddPersistent(std::string_view, wpi::span<const bool>)
|
||||
* Add(std::string_view title, wpi::span<const bool> defaultValue)
|
||||
* @see AddPersistent(std::string_view, std::span<const bool>)
|
||||
* Add(std::string_view title, std::span<const bool> defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(std::string_view title, wpi::span<const bool> defaultValue);
|
||||
SimpleWidget& Add(std::string_view title, std::span<const bool> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
@@ -272,11 +272,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see AddPersistent(std::string_view, wpi::span<const double>)
|
||||
* Add(std::string_view title, wpi::span<const double> defaultValue)
|
||||
* @see AddPersistent(std::string_view, std::span<const double>)
|
||||
* Add(std::string_view title, std::span<const double> defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(std::string_view title,
|
||||
wpi::span<const double> defaultValue);
|
||||
std::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
@@ -286,11 +286,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see AddPersistent(std::string_view, wpi::span<const double>)
|
||||
* Add(std::string_view title, wpi::span<const double> defaultValue)
|
||||
* @see AddPersistent(std::string_view, std::span<const double>)
|
||||
* Add(std::string_view title, std::span<const double> defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(std::string_view title,
|
||||
wpi::span<const float> defaultValue);
|
||||
std::span<const float> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
@@ -300,11 +300,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see AddPersistent(std::string_view, wpi::span<const double>)
|
||||
* Add(std::string_view title, wpi::span<const double> defaultValue)
|
||||
* @see AddPersistent(std::string_view, std::span<const double>)
|
||||
* Add(std::string_view title, std::span<const double> defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(std::string_view title,
|
||||
wpi::span<const int64_t> defaultValue);
|
||||
std::span<const int64_t> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display the given data.
|
||||
@@ -314,11 +314,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
* @return a widget to display the sendable data
|
||||
* @throws IllegalArgumentException if a widget already exists in this
|
||||
* container with the given title
|
||||
* @see AddPersistent(std::string_view, wpi::span<const std::string>)
|
||||
* Add(std::string_view title, wpi::span<const std::string> defaultValue)
|
||||
* @see AddPersistent(std::string_view, std::span<const std::string>)
|
||||
* Add(std::string_view title, std::span<const std::string> defaultValue)
|
||||
*/
|
||||
SimpleWidget& Add(std::string_view title,
|
||||
wpi::span<const std::string> defaultValue);
|
||||
std::span<const std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container. The widget will display the data provided
|
||||
@@ -600,82 +600,82 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
|
||||
/**
|
||||
* Adds a widget to this container to display a simple piece of data.
|
||||
*
|
||||
* Unlike Add(std::string_view, wpi::span<const bool>), the value in the
|
||||
* Unlike Add(std::string_view, std::span<const bool>), the value in the
|
||||
* widget will be saved on the robot and will be used when the robot program
|
||||
* next starts rather than {@code defaultValue}.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @see Add(std::string_view, wpi::span<const bool>)
|
||||
* Add(std::string_view title, wpi::span<const bool> defaultValue)
|
||||
* @see Add(std::string_view, std::span<const bool>)
|
||||
* Add(std::string_view title, std::span<const bool> defaultValue)
|
||||
*/
|
||||
SimpleWidget& AddPersistent(std::string_view title,
|
||||
wpi::span<const bool> defaultValue);
|
||||
std::span<const bool> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display a simple piece of data.
|
||||
*
|
||||
* Unlike Add(std::string_view, wpi::span<const double>), the value in the
|
||||
* Unlike Add(std::string_view, std::span<const double>), the value in the
|
||||
* widget will be saved on the robot and will be used when the robot program
|
||||
* next starts rather than {@code defaultValue}.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @see Add(std::string_view, wpi::span<const double>)
|
||||
* Add(std::string_view title, wpi::span<const double> defaultValue)
|
||||
* @see Add(std::string_view, std::span<const double>)
|
||||
* Add(std::string_view title, std::span<const double> defaultValue)
|
||||
*/
|
||||
SimpleWidget& AddPersistent(std::string_view title,
|
||||
wpi::span<const double> defaultValue);
|
||||
std::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display a simple piece of data.
|
||||
*
|
||||
* Unlike Add(std::string_view, wpi::span<const float>), the value in the
|
||||
* Unlike Add(std::string_view, std::span<const float>), the value in the
|
||||
* widget will be saved on the robot and will be used when the robot program
|
||||
* next starts rather than {@code defaultValue}.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @see Add(std::string_view, wpi::span<const float>)
|
||||
* Add(std::string_view title, wpi::span<const float> defaultValue)
|
||||
* @see Add(std::string_view, std::span<const float>)
|
||||
* Add(std::string_view title, std::span<const float> defaultValue)
|
||||
*/
|
||||
SimpleWidget& AddPersistent(std::string_view title,
|
||||
wpi::span<const float> defaultValue);
|
||||
std::span<const float> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display a simple piece of data.
|
||||
*
|
||||
* Unlike Add(std::string_view, wpi::span<const int64_t>), the value in the
|
||||
* Unlike Add(std::string_view, std::span<const int64_t>), the value in the
|
||||
* widget will be saved on the robot and will be used when the robot program
|
||||
* next starts rather than {@code defaultValue}.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @see Add(std::string_view, wpi::span<const int64_t>)
|
||||
* Add(std::string_view title, wpi::span<const int64_t> defaultValue)
|
||||
* @see Add(std::string_view, std::span<const int64_t>)
|
||||
* Add(std::string_view title, std::span<const int64_t> defaultValue)
|
||||
*/
|
||||
SimpleWidget& AddPersistent(std::string_view title,
|
||||
wpi::span<const int64_t> defaultValue);
|
||||
std::span<const int64_t> defaultValue);
|
||||
|
||||
/**
|
||||
* Adds a widget to this container to display a simple piece of data.
|
||||
*
|
||||
* Unlike Add(std::string_view, wpi::span<const std::string>), the value in
|
||||
* Unlike Add(std::string_view, std::span<const std::string>), the value in
|
||||
* the widget will be saved on the robot and will be used when the robot
|
||||
* program next starts rather than {@code defaultValue}.
|
||||
*
|
||||
* @param title the title of the widget
|
||||
* @param defaultValue the default value of the widget
|
||||
* @return a widget to display the sendable data
|
||||
* @see Add(std::string_view, wpi::span<const std::string>)
|
||||
* Add(std::string_view title, wpi::span<const std::string> defaultValue)
|
||||
* @see Add(std::string_view, std::span<const std::string>)
|
||||
* Add(std::string_view title, std::span<const std::string> defaultValue)
|
||||
*/
|
||||
SimpleWidget& AddPersistent(std::string_view title,
|
||||
wpi::span<const std::string> defaultValue);
|
||||
std::span<const std::string> defaultValue);
|
||||
|
||||
void EnableIfActuator() override;
|
||||
|
||||
@@ -721,7 +721,7 @@ inline frc::ComplexWidget& frc::ShuffleboardContainer::Add(
|
||||
|
||||
inline frc::ComplexWidget& frc::ShuffleboardContainer::AddCamera(
|
||||
std::string_view title, std::string_view cameraName,
|
||||
wpi::span<const std::string> cameraUrls) {
|
||||
std::span<const std::string> cameraUrls) {
|
||||
return Add(title, frc::SendableCameraWrapper::Wrap(cameraName, cameraUrls));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <numeric>
|
||||
#include <span>
|
||||
|
||||
#include <units/current.h>
|
||||
#include <units/impedance.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc::sim {
|
||||
|
||||
@@ -32,7 +32,7 @@ class BatterySim {
|
||||
*/
|
||||
static units::volt_t Calculate(units::volt_t nominalVoltage,
|
||||
units::ohm_t resistance,
|
||||
wpi::span<const units::ampere_t> currents) {
|
||||
std::span<const units::ampere_t> currents) {
|
||||
return nominalVoltage -
|
||||
std::accumulate(currents.begin(), currents.end(), 0_A) * resistance;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class BatterySim {
|
||||
* @param currents The currents drawn from the battery.
|
||||
* @return The battery's voltage under load.
|
||||
*/
|
||||
static units::volt_t Calculate(wpi::span<const units::ampere_t> currents) {
|
||||
static units::volt_t Calculate(std::span<const units::ampere_t> currents) {
|
||||
return Calculate(12_V, 0.02_Ohm, currents);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
@@ -14,7 +15,6 @@
|
||||
#include <units/length.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "frc/geometry/Pose2d.h"
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
@@ -66,7 +66,7 @@ class FieldObject2d {
|
||||
*
|
||||
* @param poses array of 2D poses
|
||||
*/
|
||||
void SetPoses(wpi::span<const Pose2d> poses);
|
||||
void SetPoses(std::span<const Pose2d> poses);
|
||||
|
||||
/**
|
||||
* Set multiple poses from an array of Pose objects.
|
||||
@@ -97,7 +97,7 @@ class FieldObject2d {
|
||||
* @param out output SmallVector to hold 2D poses
|
||||
* @return span referring to output SmallVector
|
||||
*/
|
||||
wpi::span<const Pose2d> GetPoses(wpi::SmallVectorImpl<Pose2d>& out) const;
|
||||
std::span<const Pose2d> GetPoses(wpi::SmallVectorImpl<Pose2d>& out) const;
|
||||
|
||||
private:
|
||||
void UpdateEntry(bool setDefault = false);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
@@ -17,7 +18,6 @@
|
||||
#include <networktables/StringTopic.h>
|
||||
#include <wpi/FunctionExtras.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -111,28 +111,28 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
|
||||
void AddBooleanArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int>()> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) override;
|
||||
std::function<void(std::span<const int>)> setter) override;
|
||||
|
||||
void AddIntegerArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int64_t>()> getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) override;
|
||||
std::function<void(std::span<const int64_t>)> setter) override;
|
||||
|
||||
void AddFloatArrayProperty(
|
||||
std::string_view key, std::function<std::vector<float>()> getter,
|
||||
std::function<void(wpi::span<const float>)> setter) override;
|
||||
std::function<void(std::span<const float>)> setter) override;
|
||||
|
||||
void AddDoubleArrayProperty(
|
||||
std::string_view key, std::function<std::vector<double>()> getter,
|
||||
std::function<void(wpi::span<const double>)> setter) override;
|
||||
std::function<void(std::span<const double>)> setter) override;
|
||||
|
||||
void AddStringArrayProperty(
|
||||
std::string_view key, std::function<std::vector<std::string>()> getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) override;
|
||||
std::function<void(std::span<const std::string>)> setter) override;
|
||||
|
||||
void 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) override;
|
||||
std::function<void(std::span<const uint8_t>)> setter) override;
|
||||
|
||||
void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
@@ -141,41 +141,41 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
|
||||
void AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int>(wpi::SmallVectorImpl<int>& buf)>
|
||||
std::function<std::span<const int>(wpi::SmallVectorImpl<int>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const int>)> setter) override;
|
||||
std::function<void(std::span<const int>)> setter) override;
|
||||
|
||||
void AddSmallIntegerArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
wpi::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
std::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) override;
|
||||
std::function<void(std::span<const int64_t>)> setter) override;
|
||||
|
||||
void 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) override;
|
||||
std::function<void(std::span<const float>)> setter) override;
|
||||
|
||||
void 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) override;
|
||||
std::function<void(std::span<const double>)> setter) override;
|
||||
|
||||
void 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) override;
|
||||
std::function<void(std::span<const std::string>)> setter) override;
|
||||
|
||||
void 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) override;
|
||||
std::function<void(std::span<const uint8_t>)> setter) override;
|
||||
|
||||
private:
|
||||
struct Property {
|
||||
|
||||
@@ -58,7 +58,7 @@ void SendableChooser<T>::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
}
|
||||
builder.AddStringArrayProperty(
|
||||
kOptions,
|
||||
[=] {
|
||||
[=, this] {
|
||||
std::vector<std::string> keys;
|
||||
for (const auto& choice : m_choices) {
|
||||
keys.emplace_back(choice.first());
|
||||
@@ -73,13 +73,13 @@ void SendableChooser<T>::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kDefault,
|
||||
[=](wpi::SmallVectorImpl<char>&) -> std::string_view {
|
||||
[=, this](wpi::SmallVectorImpl<char>&) -> std::string_view {
|
||||
return m_defaultChoice;
|
||||
},
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kActive,
|
||||
[=](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (m_haveSelected) {
|
||||
buf.assign(m_selected.begin(), m_selected.end());
|
||||
@@ -89,14 +89,15 @@ void SendableChooser<T>::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
builder.AddStringProperty(kSelected, nullptr, [=](std::string_view val) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_haveSelected = true;
|
||||
m_selected = val;
|
||||
for (auto& pub : m_activePubs) {
|
||||
pub.Set(val);
|
||||
}
|
||||
});
|
||||
builder.AddStringProperty(kSelected, nullptr,
|
||||
[=, this](std::string_view val) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_haveSelected = true;
|
||||
m_selected = val;
|
||||
for (auto& pub : m_activePubs) {
|
||||
pub.Set(val);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableValue.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
namespace wpi {
|
||||
class Sendable;
|
||||
@@ -216,7 +216,7 @@ class SmartDashboard {
|
||||
* std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
static bool PutBooleanArray(std::string_view key, wpi::span<const int> value);
|
||||
static bool PutBooleanArray(std::string_view key, std::span<const int> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -226,7 +226,7 @@ class SmartDashboard {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultBooleanArray(std::string_view key,
|
||||
wpi::span<const int> defaultValue);
|
||||
std::span<const int> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to.
|
||||
@@ -247,7 +247,7 @@ class SmartDashboard {
|
||||
* non-zero value is true.
|
||||
*/
|
||||
static std::vector<int> GetBooleanArray(std::string_view key,
|
||||
wpi::span<const int> defaultValue);
|
||||
std::span<const int> defaultValue);
|
||||
|
||||
/**
|
||||
* Put a number array in the table.
|
||||
@@ -257,7 +257,7 @@ class SmartDashboard {
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutNumberArray(std::string_view key,
|
||||
wpi::span<const double> value);
|
||||
std::span<const double> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -267,7 +267,7 @@ class SmartDashboard {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultNumberArray(std::string_view key,
|
||||
wpi::span<const double> defaultValue);
|
||||
std::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to.
|
||||
@@ -284,7 +284,7 @@ class SmartDashboard {
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
static std::vector<double> GetNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue);
|
||||
std::string_view key, std::span<const double> defaultValue);
|
||||
|
||||
/**
|
||||
* Put a string array in the table.
|
||||
@@ -294,7 +294,7 @@ class SmartDashboard {
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutStringArray(std::string_view key,
|
||||
wpi::span<const std::string> value);
|
||||
std::span<const std::string> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -304,7 +304,7 @@ class SmartDashboard {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultStringArray(std::string_view key,
|
||||
wpi::span<const std::string> defaultValue);
|
||||
std::span<const std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to.
|
||||
@@ -321,7 +321,7 @@ class SmartDashboard {
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
static std::vector<std::string> GetStringArray(
|
||||
std::string_view key, wpi::span<const std::string> defaultValue);
|
||||
std::string_view key, std::span<const std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Put a raw value (byte array) in the table.
|
||||
@@ -330,7 +330,7 @@ class SmartDashboard {
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
static bool PutRaw(std::string_view key, wpi::span<const uint8_t> value);
|
||||
static bool PutRaw(std::string_view key, std::span<const uint8_t> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -340,7 +340,7 @@ class SmartDashboard {
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
static bool SetDefaultRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> defaultValue);
|
||||
std::span<const uint8_t> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to.
|
||||
@@ -357,7 +357,7 @@ class SmartDashboard {
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
static std::vector<uint8_t> GetRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> defaultValue);
|
||||
std::span<const uint8_t> defaultValue);
|
||||
|
||||
/**
|
||||
* Maps the specified key to the specified complex value (such as an array) in
|
||||
|
||||
Reference in New Issue
Block a user