mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sysid] Remove unused includes and inline short functions (#7296)
This commit is contained in:
@@ -58,24 +58,6 @@ void sysid::CreateErrorPopup(bool& isError, std::string_view errorMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view sysid::GetAbbreviation(std::string_view unit) {
|
||||
if (unit == "Meters") {
|
||||
return "m";
|
||||
} else if (unit == "Feet") {
|
||||
return "ft";
|
||||
} else if (unit == "Inches") {
|
||||
return "in";
|
||||
} else if (unit == "Radians") {
|
||||
return "rad";
|
||||
} else if (unit == "Degrees") {
|
||||
return "deg";
|
||||
} else if (unit == "Rotations") {
|
||||
return "rot";
|
||||
} else {
|
||||
throw std::runtime_error("Invalid Unit");
|
||||
}
|
||||
}
|
||||
|
||||
void sysid::SaveFile(std::string_view contents,
|
||||
const std::filesystem::path& path) {
|
||||
// Create the path if it doesn't already exist.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/StringMap.h>
|
||||
|
||||
#include "sysid/analysis/FeedforwardAnalysis.h"
|
||||
#include "sysid/analysis/FilteringUtils.h"
|
||||
|
||||
using namespace sysid;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
|
||||
using namespace sysid;
|
||||
|
||||
AnalysisType sysid::analysis::FromName(std::string_view name) {
|
||||
if (name == "Elevator") {
|
||||
return sysid::analysis::kElevator;
|
||||
}
|
||||
if (name == "Arm") {
|
||||
return sysid::analysis::kArm;
|
||||
}
|
||||
return sysid::analysis::kSimple;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "sysid/analysis/TrackWidthAnalysis.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
double sysid::CalculateTrackWidth(double l, double r, units::radian_t accum) {
|
||||
// The below comes from solving ω = (vr − vl) / 2r for 2r.
|
||||
return (std::abs(r) + std::abs(l)) / std::abs(accum.value());
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
|
||||
// The generated AppleScript by portable-file-dialogs for just *.json does not
|
||||
@@ -67,7 +67,23 @@ void CreateErrorPopup(bool& isError, std::string_view errorMessage);
|
||||
* @param unit The unit to return the abbreviation for.
|
||||
* @return The abbreviation for the unit.
|
||||
*/
|
||||
std::string_view GetAbbreviation(std::string_view unit);
|
||||
constexpr std::string_view GetAbbreviation(std::string_view unit) {
|
||||
if (unit == "Meters") {
|
||||
return "m";
|
||||
} else if (unit == "Feet") {
|
||||
return "ft";
|
||||
} else if (unit == "Inches") {
|
||||
return "in";
|
||||
} else if (unit == "Radians") {
|
||||
return "rad";
|
||||
} else if (unit == "Degrees") {
|
||||
return "deg";
|
||||
} else if (unit == "Rotations") {
|
||||
return "rot";
|
||||
} else {
|
||||
throw std::runtime_error("Invalid Unit");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a file with the provided contents to a specified location.
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
#include <exception>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <units/time.h>
|
||||
@@ -23,7 +21,7 @@
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
#include "sysid/analysis/FeedbackAnalysis.h"
|
||||
#include "sysid/analysis/FeedbackControllerPreset.h"
|
||||
#include "sysid/analysis/FeedforwardAnalysis.h"
|
||||
#include "sysid/analysis/OLS.h"
|
||||
#include "sysid/analysis/Storage.h"
|
||||
|
||||
namespace sysid {
|
||||
|
||||
@@ -56,6 +56,14 @@ inline constexpr AnalysisType kElevator{4, 4, "Elevator"};
|
||||
inline constexpr AnalysisType kArm{5, 4, "Arm"};
|
||||
inline constexpr AnalysisType kSimple{3, 4, "Simple"};
|
||||
|
||||
AnalysisType FromName(std::string_view name);
|
||||
constexpr AnalysisType FromName(std::string_view name) {
|
||||
if (name == "Elevator") {
|
||||
return sysid::analysis::kElevator;
|
||||
}
|
||||
if (name == "Arm") {
|
||||
return sysid::analysis::kArm;
|
||||
}
|
||||
return sysid::analysis::kSimple;
|
||||
}
|
||||
} // namespace analysis
|
||||
} // namespace sysid
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
#include "sysid/analysis/OLS.h"
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <units/voltage.h>
|
||||
|
||||
namespace sysid {
|
||||
|
||||
/**
|
||||
* Simulation of a Simple Motor mechanism based off of a model from SysId
|
||||
* Feedforward gains.
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gcem.hpp>
|
||||
#include <units/angle.h>
|
||||
|
||||
namespace sysid {
|
||||
|
||||
/**
|
||||
* Calculates the track width given the left distance, right distance, and
|
||||
* accumulated gyro angle.
|
||||
@@ -15,5 +17,10 @@ namespace sysid {
|
||||
* @param r The distance traveled by the right side of the drivetrain.
|
||||
* @param accum The accumulated gyro angle.
|
||||
*/
|
||||
double CalculateTrackWidth(double l, double r, units::radian_t accum);
|
||||
constexpr double CalculateTrackWidth(double l, double r,
|
||||
units::radian_t accum) {
|
||||
// The below comes from solving ω = (vr − vl) / 2r for 2r.
|
||||
return (gcem::abs(r) + gcem::abs(l)) / gcem::abs(accum.value());
|
||||
}
|
||||
|
||||
} // namespace sysid
|
||||
|
||||
@@ -4,13 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <glass/View.h>
|
||||
#include <implot.h>
|
||||
@@ -21,7 +18,6 @@
|
||||
#include <wpi/StringMap.h>
|
||||
|
||||
#include "sysid/analysis/AnalysisManager.h"
|
||||
#include "sysid/analysis/AnalysisType.h"
|
||||
#include "sysid/analysis/FeedbackAnalysis.h"
|
||||
#include "sysid/analysis/FeedbackControllerPreset.h"
|
||||
#include "sysid/view/AnalyzerPlot.h"
|
||||
|
||||
Reference in New Issue
Block a user