SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -15,7 +15,7 @@
#include "wpi/util/MathExtras.hpp"
#include "wpi/util/SymbolExports.hpp"
namespace frc {
namespace wpi::math {
/**
* The TimeInterpolatableBuffer provides an easy way to estimate past
@@ -24,7 +24,7 @@ namespace frc {
* when vision or other global measurement were recorded is necessary, or for
* recording the past angles of mechanisms as measured by encoders.
*
* When sampling this buffer, a user-provided function or wpi::Lerp can be
* When sampling this buffer, a user-provided function or wpi::util::Lerp can be
* used. For Pose2ds, we use Twists.
*
* @tparam T The type stored in this buffer.
@@ -38,20 +38,20 @@ class TimeInterpolatableBuffer {
* @param historySize The history size of the buffer.
* @param func The function used to interpolate between values.
*/
TimeInterpolatableBuffer(units::second_t historySize,
TimeInterpolatableBuffer(wpi::units::second_t historySize,
std::function<T(const T&, const T&, double)> func)
: m_historySize(historySize), m_interpolatingFunc(func) {}
/**
* Create a new TimeInterpolatableBuffer. By default, the interpolation
* function is wpi::Lerp except for Pose2d, which uses the pose exponential.
* function is wpi::util::Lerp except for Pose2d, which uses the pose exponential.
*
* @param historySize The history size of the buffer.
*/
explicit TimeInterpolatableBuffer(units::second_t historySize)
explicit TimeInterpolatableBuffer(wpi::units::second_t historySize)
: m_historySize(historySize),
m_interpolatingFunc([](const T& start, const T& end, double t) {
return wpi::Lerp(start, end, t);
return wpi::util::Lerp(start, end, t);
}) {}
/**
@@ -60,7 +60,7 @@ class TimeInterpolatableBuffer {
* @param time The timestamp of the sample.
* @param sample The sample object.
*/
void AddSample(units::second_t time, T sample) {
void AddSample(wpi::units::second_t time, T sample) {
// Add the new state into the vector
if (m_pastSnapshots.size() == 0 || time > m_pastSnapshots.back().first) {
m_pastSnapshots.emplace_back(time, sample);
@@ -97,7 +97,7 @@ class TimeInterpolatableBuffer {
*
* @param time The time at which to sample the buffer.
*/
std::optional<T> Sample(units::second_t time) const {
std::optional<T> Sample(wpi::units::second_t time) const {
if (m_pastSnapshots.empty()) {
return {};
}
@@ -137,27 +137,27 @@ class TimeInterpolatableBuffer {
* Grant access to the internal sample buffer. Used in Pose Estimation to
* replay odometry inputs stored within this buffer.
*/
std::vector<std::pair<units::second_t, T>>& GetInternalBuffer() {
std::vector<std::pair<wpi::units::second_t, T>>& GetInternalBuffer() {
return m_pastSnapshots;
}
/**
* Grant access to the internal sample buffer.
*/
const std::vector<std::pair<units::second_t, T>>& GetInternalBuffer() const {
const std::vector<std::pair<wpi::units::second_t, T>>& GetInternalBuffer() const {
return m_pastSnapshots;
}
private:
units::second_t m_historySize;
std::vector<std::pair<units::second_t, T>> m_pastSnapshots;
wpi::units::second_t m_historySize;
std::vector<std::pair<wpi::units::second_t, T>> m_pastSnapshots;
std::function<T(const T&, const T&, double)> m_interpolatingFunc;
};
// Template specialization to ensure that Pose2d uses pose exponential
template <>
inline TimeInterpolatableBuffer<Pose2d>::TimeInterpolatableBuffer(
units::second_t historySize)
wpi::units::second_t historySize)
: m_historySize(historySize),
m_interpolatingFunc([](const Pose2d& start, const Pose2d& end, double t) {
if (t < 0) {
@@ -171,4 +171,4 @@ inline TimeInterpolatableBuffer<Pose2d>::TimeInterpolatableBuffer(
}
}) {}
} // namespace frc
} // namespace wpi::math