SCRIPT: wpiformat

This commit is contained in:
PJ Reiniger
2025-11-07 20:01:58 -05:00
committed by Peter Johnson
parent ae6bdc9d25
commit 2109161534
749 changed files with 5504 additions and 3936 deletions

View File

@@ -106,8 +106,8 @@ void FieldObject2d::UpdateFromEntry() const {
}
m_poses.resize(size / 3);
for (size_t i = 0; i < size / 3; ++i) {
m_poses[i] =
wpi::math::Pose2d{wpi::units::meter_t{arr[i * 3 + 0]}, wpi::units::meter_t{arr[i * 3 + 1]},
wpi::units::degree_t{arr[i * 3 + 2]}};
m_poses[i] = wpi::math::Pose2d{wpi::units::meter_t{arr[i * 3 + 0]},
wpi::units::meter_t{arr[i * 3 + 1]},
wpi::units::degree_t{arr[i * 3 + 2]}};
}
}

View File

@@ -28,7 +28,8 @@ MechanismLigament2d::MechanismLigament2d(std::string_view name, double length,
void MechanismLigament2d::UpdateEntries(
std::shared_ptr<wpi::nt::NetworkTable> table) {
m_typePub = table->GetStringTopic(".type").PublishEx(
wpi::nt::StringTopic::kTypeString, {{"SmartDashboard", kSmartDashboardType}});
wpi::nt::StringTopic::kTypeString,
{{"SmartDashboard", kSmartDashboardType}});
m_typePub.Set(kSmartDashboardType);
m_colorEntry = table->GetStringTopic("color").GetEntry("");
@@ -45,7 +46,7 @@ void MechanismLigament2d::SetColor(const Color8Bit& color) {
std::scoped_lock lock(m_mutex);
wpi::util::format_to_n_c_str(m_color, sizeof(m_color), "#{:02X}{:02X}{:02X}",
color.red, color.green, color.blue);
color.red, color.green, color.blue);
if (m_colorEntry) {
m_colorEntry.Set(m_color);

View File

@@ -4,10 +4,10 @@
#include "wpi/smartdashboard/MechanismRoot2d.hpp"
#include "wpi/util/Color8Bit.hpp"
#include <memory>
#include "wpi/util/Color8Bit.hpp"
using namespace wpi;
MechanismRoot2d::MechanismRoot2d(std::string_view name, double x, double y,
@@ -21,7 +21,8 @@ void MechanismRoot2d::SetPosition(double x, double y) {
Flush();
}
void MechanismRoot2d::UpdateEntries(std::shared_ptr<wpi::nt::NetworkTable> table) {
void MechanismRoot2d::UpdateEntries(
std::shared_ptr<wpi::nt::NetworkTable> table) {
m_xPub = table->GetDoubleTopic("x").Publish();
m_yPub = table->GetDoubleTopic("y").Publish();
Flush();

View File

@@ -35,7 +35,8 @@ void SendableBuilderImpl::PropertyImpl<Topic>::Update(bool controllable,
}
}
void SendableBuilderImpl::SetTable(std::shared_ptr<wpi::nt::NetworkTable> table) {
void SendableBuilderImpl::SetTable(
std::shared_ptr<wpi::nt::NetworkTable> table) {
m_table = table;
m_controllablePublisher = table->GetBooleanTopic(".controllable").Publish();
m_controllablePublisher.SetDefault(false);
@@ -97,7 +98,8 @@ void SendableBuilderImpl::SetActuator(bool value) {
m_actuator = value;
}
void SendableBuilderImpl::SetUpdateTable(wpi::util::unique_function<void()> func) {
void SendableBuilderImpl::SetUpdateTable(
wpi::util::unique_function<void()> func) {
m_updateTables.emplace_back(std::move(func));
}
@@ -314,7 +316,8 @@ void SendableBuilderImpl::AddSmallPropertyImpl(Topic topic, Getter getter,
void SendableBuilderImpl::AddSmallStringProperty(
std::string_view key,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)> getter,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)>
getter,
std::function<void(std::string_view)> setter) {
AddSmallPropertyImpl<char, 128>(m_table->GetStringTopic(key),
std::move(getter), std::move(setter));
@@ -322,7 +325,8 @@ void SendableBuilderImpl::AddSmallStringProperty(
void SendableBuilderImpl::AddSmallBooleanArrayProperty(
std::string_view key,
std::function<std::span<const int>(wpi::util::SmallVectorImpl<int>& buf)> getter,
std::function<std::span<const int>(wpi::util::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));
@@ -330,7 +334,8 @@ void SendableBuilderImpl::AddSmallBooleanArrayProperty(
void SendableBuilderImpl::AddSmallIntegerArrayProperty(
std::string_view key,
std::function<std::span<const int64_t>(wpi::util::SmallVectorImpl<int64_t>& buf)>
std::function<
std::span<const int64_t>(wpi::util::SmallVectorImpl<int64_t>& buf)>
getter,
std::function<void(std::span<const int64_t>)> setter) {
AddSmallPropertyImpl<int64_t, 16>(m_table->GetIntegerArrayTopic(key),
@@ -339,7 +344,8 @@ void SendableBuilderImpl::AddSmallIntegerArrayProperty(
void SendableBuilderImpl::AddSmallFloatArrayProperty(
std::string_view key,
std::function<std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
std::function<
std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
getter,
std::function<void(std::span<const float>)> setter) {
AddSmallPropertyImpl<float, 16>(m_table->GetFloatArrayTopic(key),
@@ -348,7 +354,8 @@ void SendableBuilderImpl::AddSmallFloatArrayProperty(
void SendableBuilderImpl::AddSmallDoubleArrayProperty(
std::string_view key,
std::function<std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
std::function<
std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
getter,
std::function<void(std::span<const double>)> setter) {
AddSmallPropertyImpl<double, 16>(m_table->GetDoubleArrayTopic(key),
@@ -357,8 +364,8 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty(
void SendableBuilderImpl::AddSmallStringArrayProperty(
std::string_view key,
std::function<
std::span<const std::string>(wpi::util::SmallVectorImpl<std::string>& buf)>
std::function<std::span<const std::string>(
wpi::util::SmallVectorImpl<std::string>& buf)>
getter,
std::function<void(std::span<const std::string>)> setter) {
AddSmallPropertyImpl<std::string, 16>(m_table->GetStringArrayTopic(key),