Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/cmake-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r27d
ndk-version: r29
add-to-path: false

- name: Install sccache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
**/upstream_utils/**
**/generated/**
./wpigui/src/main/native/cpp/portable-file-dialogs.*
./wpimath/src/main/native/include/wpi/units/base.hpp
./wpimath/src/test/native/cpp/units/main.cpp
./wpinet/src/main/native/linux/AvahiClient.*
./wpiutil/src/main/native/include/wpi/util/FastQueue.hpp
./wpiutil/src/test/native/cpp/json/**
Expand Down
3 changes: 1 addition & 2 deletions .wpiformat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ generatedFileExclude {
thirdparty/
wpigui/src/main/native/cpp/portable-file-dialogs\.cpp$
wpigui/src/main/native/include/wpi/gui/portable-file-dialogs\.h$
wpimath/src/main/native/include/wpi/units/base\.hpp$
wpimath/src/test/native/cpp/units/
wpiutil/src/main/native/include/wpi/util/FastQueue\.hpp$
wpiutil/src/test/native/cpp/json/
wpiutil/src/test/native/cpp/llvm/
Expand All @@ -31,7 +31,6 @@ generatedFileExclude {

modifiableFileExclude {
objcpp/
wpimath/src/test/native/cpp/UnitsTest\.cpp$
wpiutil/src/main/native/cpp/fs\.cpp$
wpiutil/src/main/native/include/wpi/util/fs\.hpp$
}
Expand Down
6 changes: 3 additions & 3 deletions apriltag/src/main/native/cpp/AprilTagPoseEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ static wpi::math::Transform3d MakePose(const apriltag_pose_t& pose) {
if (!pose.R || !pose.t) {
return {};
}
return {wpi::math::Translation3d{wpi::units::meter_t{pose.t->data[0]},
wpi::units::meter_t{pose.t->data[1]},
wpi::units::meter_t{pose.t->data[2]}},
return {wpi::math::Translation3d{wpi::units::meters<>{pose.t->data[0]},
wpi::units::meters<>{pose.t->data[1]},
wpi::units::meters<>{pose.t->data[2]}},
wpi::math::Rotation3d{OrthogonalizeRotationMatrix(
Eigen::Map<Eigen::Matrix<double, 3, 3, Eigen::RowMajor>>{
pose.R->data})}};
Expand Down
8 changes: 4 additions & 4 deletions apriltag/src/main/native/cpp/jni/AprilTagJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static AprilTagDetector::QuadThresholdParameters FromJavaDetectorQTP(
return {
FIELD(int, Int, minClusterPixels),
FIELD(int, Int, maxNumMaxima),
.criticalAngle = wpi::units::radian_t{static_cast<double>(
.criticalAngle = wpi::units::radians<>{static_cast<double>(
env->GetDoubleField(jparams, criticalAngleField))},
FIELD(float, Float, maxLineFitMSE),
FIELD(int, Int, minWhiteBlackDiff),
Expand Down Expand Up @@ -517,7 +517,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePoseHomography
}

AprilTagPoseEstimator estimator(
{wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
{wpi::units::meters<>{tagSize}, fx, fy, cx, cy});
return MakeJObject(env, estimator.EstimateHomography(harr));
}

Expand Down Expand Up @@ -554,7 +554,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
}

AprilTagPoseEstimator estimator(
{wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
{wpi::units::meters<>{tagSize}, fx, fy, cx, cy});
return MakeJObject(env,
estimator.EstimateOrthogonalIteration(harr, carr, nIters));
}
Expand Down Expand Up @@ -592,7 +592,7 @@ Java_org_wpilib_vision_apriltag_jni_AprilTagJNI_estimatePose
}

AprilTagPoseEstimator estimator(
{wpi::units::meter_t{tagSize}, fx, fy, cx, cy});
{wpi::units::meters<>{tagSize}, fx, fy, cx, cy});
return MakeJObject(env, estimator.Estimate(harr, carr));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
* angles that are close to straight or close to 180 degrees. Zero means
* that no quads are rejected. Default is 45 degrees.
*/
wpi::units::radian_t criticalAngle = 45_deg;
wpi::units::radians<> criticalAngle = 45_deg;

/**
* When fitting lines to the contours, the maximum mean squared error
Expand Down Expand Up @@ -255,7 +255,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {

void* m_impl;
wpi::util::StringMap<void*> m_families;
wpi::units::radian_t m_qtpCriticalAngle = 10_deg;
wpi::units::radians<> m_qtpCriticalAngle = 10_deg;
};

} // namespace wpi::apriltag
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WPILIB_DLLEXPORT AprilTagPoseEstimator {
bool operator==(const Config&) const = default;

/** The tag size. */
wpi::units::meter_t tagSize;
wpi::units::meters<> tagSize;

/** Camera horizontal focal length, in pixels. */
double fx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classes:
methods:
operator==:
inline_code: |
.def(py::init([](wpi::units::meter_t tagSize, double fx, double fy, double cx, double cy) {
.def(py::init([](wpi::units::meters<> tagSize, double fx, double fy, double cx, double cy) {
AprilTagPoseEstimator::Config cfg{tagSize, fx, fy, cx, cy};
return std::make_unique<AprilTagPoseEstimator::Config>(std::move(cfg));
}), py::arg("tag_size"), py::arg("fx"), py::arg("fy"), py::arg("cx"), py::arg("cy"))
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static constexpr int iterations = 100;
inline void BM_TravelingSalesman_Transform(benchmark::State& state) {
wpi::math::TravelingSalesman traveler{[](auto pose1, auto pose2) {
auto transform = pose2 - pose1;
return wpi::units::math::hypot(transform.X(), transform.Y()).value();
return wpi::units::hypot(transform.X(), transform.Y()).value();
}};
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
for (auto _ : state) {
Expand All @@ -33,7 +33,7 @@ inline void BM_TravelingSalesman_Transform(benchmark::State& state) {
inline void BM_TravelingSalesman_Twist(benchmark::State& state) {
wpi::math::TravelingSalesman traveler{[](auto pose1, auto pose2) {
auto twist = (pose2 - pose1).Log();
return wpi::units::math::hypot(twist.dx, twist.dy).value();
return wpi::units::hypot(twist.dx, twist.dy).value();
}};
// NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores)
for (auto _ : state) {
Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void Command::SetSubsystem(std::string_view subsystem) {
m_subsystem = subsystem;
}

CommandPtr Command::WithTimeout(wpi::units::second_t duration) && {
CommandPtr Command::WithTimeout(wpi::units::seconds<> duration) && {
return std::move(*this).ToPtr().WithTimeout(duration);
}

Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/CommandPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ CommandPtr CommandPtr::BeforeStarting(CommandPtr&& before) && {
return std::move(*this);
}

CommandPtr CommandPtr::WithTimeout(wpi::units::second_t duration) && {
CommandPtr CommandPtr::WithTimeout(wpi::units::seconds<> duration) && {
AssertValid();
std::vector<std::unique_ptr<Command>> temp;
temp.emplace_back(std::move(m_ptr));
Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/CommandScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CommandScheduler& CommandScheduler::GetInstance() {
return scheduler;
}

void CommandScheduler::SetPeriod(wpi::units::second_t period) {
void CommandScheduler::SetPeriod(wpi::units::seconds<> period) {
m_watchdog.SetTimeout(period);
}

Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CommandPtr DeferredProxy(wpi::util::unique_function<CommandPtr()> supplier) {
{});
}

CommandPtr Wait(wpi::units::second_t duration) {
CommandPtr Wait(wpi::units::seconds<> duration) {
return WaitCommand(duration).ToPtr();
}

Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/NotifierCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using namespace wpi::cmd;

NotifierCommand::NotifierCommand(std::function<void()> toRun,
wpi::units::second_t period,
wpi::units::seconds<> period,
Requirements requirements)
: m_toRun(toRun), m_notifier{std::move(toRun)}, m_period{period} {
AddRequirements(requirements);
Expand Down
3 changes: 2 additions & 1 deletion commandsv2/src/main/native/cpp/WaitCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

using namespace wpi::cmd;

WaitCommand::WaitCommand(wpi::units::second_t duration) : m_duration{duration} {
WaitCommand::WaitCommand(wpi::units::seconds<> duration)
: m_duration{duration} {
SetName(std::format("{}: {}", GetName(), duration));
}

Expand Down
2 changes: 1 addition & 1 deletion commandsv2/src/main/native/cpp/WaitUntilCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace wpi::cmd;
WaitUntilCommand::WaitUntilCommand(std::function<bool()> condition)
: m_condition{std::move(condition)} {}

WaitUntilCommand::WaitUntilCommand(wpi::units::second_t time)
WaitUntilCommand::WaitUntilCommand(wpi::units::seconds<> time)
: m_condition{[=] { return wpi::Timer::GetMatchTime() < time; }} {}

bool WaitUntilCommand::IsFinished() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ double CommandJoystick::GetMagnitude() const {
return m_joystick.GetMagnitude();
}

wpi::units::radian_t CommandJoystick::GetDirection() const {
wpi::units::radians<> CommandJoystick::GetDirection() const {
// https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system
// A positive rotation around the X axis moves the joystick right, and a
// positive rotation around the Y axis moves the joystick backward. When
Expand Down
4 changes: 2 additions & 2 deletions commandsv2/src/main/native/cpp/button/Trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
return *this;
}

Trigger Trigger::Debounce(wpi::units::second_t debounceTime,
Trigger Trigger::Debounce(wpi::units::seconds<> debounceTime,
wpi::math::Debouncer::DebounceType type) {
return Trigger(m_loop, [debouncer = wpi::math::Debouncer(debounceTime, type),
condition = m_condition]() mutable {
return debouncer.Calculate(condition());
});
}

Trigger Trigger::MultiPress(int requiredPresses, units::second_t windowTime) {
Trigger Trigger::MultiPress(int requiredPresses, units::seconds<> windowTime) {
return Trigger(m_loop, [filter = wpi::math::EdgeCounterFilter(requiredPresses,
windowTime),
condition = m_condition]() mutable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Command : public wpi::telemetry::TelemetryLoggable,
* @param duration the timeout duration
* @return the command with the timeout added
*/
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
CommandPtr WithTimeout(wpi::units::seconds<> duration) &&;

/**
* Decorates this command with an interrupt condition. If the specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class [[nodiscard]] CommandPtr final {
* @param duration the timeout duration
* @return the command with the timeout added
*/
CommandPtr WithTimeout(wpi::units::second_t duration) &&;
CommandPtr WithTimeout(wpi::units::seconds<> duration) &&;

/**
* Decorates this command with an interrupt condition. If the specified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CommandScheduler final : public wpi::telemetry::TelemetryLoggable,
* Changes the period of the loop overrun watchdog. This should be kept in
* sync with the TimedRobot period.
*/
void SetPeriod(wpi::units::second_t period);
void SetPeriod(wpi::units::seconds<> period);

/**
* Get the active button poll.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ CommandPtr Print(std::string_view msg);
*
* @param duration after how long the command finishes
*/
CommandPtr Wait(wpi::units::second_t duration);
CommandPtr Wait(wpi::units::seconds<> duration);

/**
* Constructs a command that does nothing, finishing once a condition becomes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
* @param period the period at which the notifier should run
* @param requirements the subsystems required by this command
*/
NotifierCommand(std::function<void()> toRun, wpi::units::second_t period,
NotifierCommand(std::function<void()> toRun, wpi::units::seconds<> period,
Requirements requirements = {});

NotifierCommand(NotifierCommand&& other);
Expand All @@ -48,6 +48,6 @@ class NotifierCommand : public CommandHelper<Command, NotifierCommand> {
private:
std::function<void()> m_toRun;
wpi::Notifier m_notifier;
wpi::units::second_t m_period;
wpi::units::seconds<> m_period;
};
} // namespace wpi::cmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WaitCommand : public CommandHelper<Command, WaitCommand> {
*
* @param duration the time to wait
*/
explicit WaitCommand(wpi::units::second_t duration);
explicit WaitCommand(wpi::units::seconds<> duration);

WaitCommand(WaitCommand&& other) = default;

Expand All @@ -44,6 +44,6 @@ class WaitCommand : public CommandHelper<Command, WaitCommand> {
wpi::Timer m_timer;

private:
wpi::units::second_t m_duration;
wpi::units::seconds<> m_duration;
};
} // namespace wpi::cmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class WaitUntilCommand : public CommandHelper<Command, WaitUntilCommand> {
* @param time the match time after which to end, in seconds
* @see wpi::DriverStation::GetMatchTime()
*/
explicit WaitUntilCommand(wpi::units::second_t time);
explicit WaitUntilCommand(wpi::units::seconds<> time);

WaitUntilCommand(WaitUntilCommand&& other) = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CommandJoystick {
*
* @return The direction of the vector.
*/
wpi::units::radian_t GetDirection() const;
wpi::units::radians<> GetDirection() const;

private:
CommandGenericHID* m_hid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class Trigger {
* @param type The debounce type.
* @return The debounced trigger.
*/
Trigger Debounce(wpi::units::second_t debounceTime,
Trigger Debounce(wpi::units::seconds<> debounceTime,
wpi::math::Debouncer::DebounceType type =
wpi::math::Debouncer::DebounceType::RISING);

Expand All @@ -297,7 +297,7 @@ class Trigger {
* @param windowTime The time in which the presses must occur.
* @return The multi-press trigger.
*/
Trigger MultiPress(int requiredPresses, units::second_t windowTime);
Trigger MultiPress(int requiredPresses, units::seconds<> windowTime);

/**
* Returns the current state of this trigger.
Expand Down
Loading
Loading