[robotpy] Run wpiformat on non-python robotpy files (#8362)

This turns the styleguide on for the non-python robotpy files.

The overwhelming amount of changes were
related to whitespace, followed by some IWYU for standard library
headers.
This commit is contained in:
PJ Reiniger
2026-06-21 22:36:03 -04:00
committed by GitHub
parent 6bc7051e23
commit 4a2cd3e5d0
71 changed files with 877 additions and 739 deletions

View File

@@ -43,7 +43,7 @@ inline_code: |
self->ax = ax;
}
)
.def_property("ay_fpss",
.def_property("ay_fpss",
[](ChassisAccelerations * self) -> wpi::units::feet_per_second_squared_t {
return self->ay;
},
@@ -51,7 +51,7 @@ inline_code: |
self->ay = ay;
}
)
.def_property("alpha_dpss",
.def_property("alpha_dpss",
[](ChassisAccelerations * self) -> wpi::units::degrees_per_second_squared_t {
return self->alpha;
},

View File

@@ -45,7 +45,7 @@ inline_code: |
self->vx = vx;
}
)
.def_property("vy_fps",
.def_property("vy_fps",
[](ChassisVelocities * self) -> wpi::units::feet_per_second_t {
return self->vy;
},
@@ -53,7 +53,7 @@ inline_code: |
self->vy = vy;
}
)
.def_property("omega_dps",
.def_property("omega_dps",
[](ChassisVelocities * self) -> wpi::units::degrees_per_second_t {
return self->omega;
},

View File

@@ -36,7 +36,7 @@ inline_code: |
self->left = left;
}
)
.def_property("right_fpss",
.def_property("right_fpss",
[](DifferentialDriveWheelAccelerations * self) -> wpi::units::feet_per_second_squared_t {
return self->right;
},

View File

@@ -35,7 +35,7 @@ inline_code: |
self->left = left;
}
)
.def_property("right_fps",
.def_property("right_fps",
[](DifferentialDriveWheelVelocities * self) -> wpi::units::feet_per_second_t {
return self->right;
},
@@ -50,4 +50,3 @@ inline_code: |
;
SetupWPyStruct<wpi::math::DifferentialDriveWheelVelocities>(cls_DifferentialDriveWheelVelocities);

View File

@@ -29,9 +29,9 @@ inline_code: |
>(),
py::arg("frontLeft") = 0, py::arg("frontRight") = 0, py::arg("rearLeft") = 0, py::arg("rearRight") = 0
)
.def_static("fromFps", [](wpi::units::feet_per_second_squared_t frontLeft,
wpi::units::feet_per_second_squared_t frontRight,
wpi::units::feet_per_second_squared_t rearLeft,
.def_static("fromFps", [](wpi::units::feet_per_second_squared_t frontLeft,
wpi::units::feet_per_second_squared_t frontRight,
wpi::units::feet_per_second_squared_t rearLeft,
wpi::units::feet_per_second_squared_t rearRight){
return MecanumDriveWheelAccelerations{frontLeft, frontRight, rearLeft, rearRight};
}, py::arg("frontLeft") = 0, py::arg("frontRight") = 0, py::arg("rearLeft") = 0, py::arg("rearRight") = 0)
@@ -43,7 +43,7 @@ inline_code: |
self->frontLeft = frontLeft;
}
)
.def_property("front_right_fpss",
.def_property("front_right_fpss",
[](MecanumDriveWheelAccelerations * self) -> wpi::units::feet_per_second_squared_t {
return self->frontRight;
},
@@ -59,7 +59,7 @@ inline_code: |
self->rearLeft = rearLeft;
}
)
.def_property("rear_right_fpss",
.def_property("rear_right_fpss",
[](MecanumDriveWheelAccelerations * self) -> wpi::units::feet_per_second_squared_t {
return self->rearRight;
},

View File

@@ -46,7 +46,7 @@ inline_code: |
self->frontLeft = fps;
}
)
.def_property("frontRight_fps",
.def_property("frontRight_fps",
[](MecanumDriveWheelVelocities * self) -> wpi::units::feet_per_second_t {
return self->frontRight;
},
@@ -62,7 +62,7 @@ inline_code: |
self->rearLeft = fps;
}
)
.def_property("rearRight_fps",
.def_property("rearRight_fps",
[](MecanumDriveWheelVelocities * self) -> wpi::units::feet_per_second_t {
return self->rearRight;
},

View File

@@ -41,7 +41,7 @@ inline_code: |-
"\n"
":param kinematics: The swerve drive kinematics.")
)
.def("setKinematics", static_cast<void (wpi::math::TrajectoryConfig::*)(wpi::math::SwerveDriveKinematics<3>&)>(
&wpi::math::TrajectoryConfig::SetKinematics<3>),
py::arg("kinematics"), release_gil(), py::doc(
@@ -50,7 +50,7 @@ inline_code: |-
"\n"
":param kinematics: The swerve drive kinematics.")
)
.def("setKinematics", static_cast<void (wpi::math::TrajectoryConfig::*)(wpi::math::SwerveDriveKinematics<4>&)>(
&wpi::math::TrajectoryConfig::SetKinematics<4>),
py::arg("kinematics"), release_gil(), py::doc(
@@ -59,7 +59,7 @@ inline_code: |-
"\n"
":param kinematics: The swerve drive kinematics.")
)
.def("setKinematics", static_cast<void (wpi::math::TrajectoryConfig::*)(wpi::math::SwerveDriveKinematics<6>&)>(
&wpi::math::TrajectoryConfig::SetKinematics<6>),
py::arg("kinematics"), release_gil(), py::doc(

View File

@@ -19,4 +19,3 @@ classes:
- [CubicHermiteSpline]
- [QuinticHermiteSpline]
SetErrorHandler:

View File

@@ -22,7 +22,7 @@ inline_code: |
.def_static("fromFeet", [](wpi::units::foot_t dx, wpi::units::foot_t dy, wpi::units::radian_t dtheta){
return Twist2d{dx, dy, dtheta};
}, py::arg("dx") = 0, py::arg("dy") = 0, py::arg("dtheta") = 0)
.def_property("dx_feet",
.def_property("dx_feet",
[](Twist2d * self) -> wpi::units::foot_t {
return self->dx;
},
@@ -30,7 +30,7 @@ inline_code: |
self->dx = dx;
}
)
.def_property("dy_feet",
.def_property("dy_feet",
[](Twist2d * self) -> wpi::units::foot_t {
return self->dy;
},
@@ -38,7 +38,7 @@ inline_code: |
self->dy = dy;
}
)
.def_property("dtheta_degrees",
.def_property("dtheta_degrees",
[](Twist2d * self) -> wpi::units::degree_t {
return self->dtheta;
},

View File

@@ -30,7 +30,7 @@ inline_code: |-
},
py::arg("dx") = 0, py::arg("dy") = 0, py::arg("dz") = 0,
py::arg("rx") = 0, py::arg("ry") = 0, py::arg("rz") = 0)
.def_property("dx_feet",
.def_property("dx_feet",
[](Twist3d * self) -> wpi::units::foot_t {
return self->dx;
},
@@ -38,7 +38,7 @@ inline_code: |-
self->dx = dx;
}
)
.def_property("dy_feet",
.def_property("dy_feet",
[](Twist3d * self) -> wpi::units::foot_t {
return self->dy;
},
@@ -46,7 +46,7 @@ inline_code: |-
self->dy = dy;
}
)
.def_property("dz_feet",
.def_property("dz_feet",
[](Twist3d * self) -> wpi::units::foot_t {
return self->dz;
},
@@ -54,7 +54,7 @@ inline_code: |-
self->dz = dz;
}
)
.def_property("rx_degrees",
.def_property("rx_degrees",
[](Twist3d * self) -> wpi::units::degree_t {
return self->rx;
},
@@ -62,7 +62,7 @@ inline_code: |-
self->rx = rx;
}
)
.def_property("ry_degrees",
.def_property("ry_degrees",
[](Twist3d * self) -> wpi::units::degree_t {
return self->ry;
},
@@ -70,7 +70,7 @@ inline_code: |-
self->ry = ry;
}
)
.def_property("rz_degrees",
.def_property("rz_degrees",
[](Twist3d * self) -> wpi::units::degree_t {
return self->rz;
},

View File

@@ -1,37 +1,43 @@
#pragma once
#include "wpi/math/trajectory/constraint/TrajectoryConstraint.hpp"
#include <memory>
#include <utility>
#include <semiwrap.h>
#include "wpi/math/trajectory/constraint/TrajectoryConstraint.hpp"
namespace wpi::math {
struct PyTrajectoryConstraint : public TrajectoryConstraint {
PyTrajectoryConstraint() {}
wpi::units::meters_per_second_t
MaxVelocity(const Pose2d &pose, wpi::units::curvature_t curvature,
wpi::units::meters_per_second_t velocity) const override {
wpi::units::meters_per_second_t MaxVelocity(
const Pose2d& pose, wpi::units::curvature_t curvature,
wpi::units::meters_per_second_t velocity) const override {
return m_constraint->MaxVelocity(pose, curvature, velocity);
}
MinMax MinMaxAcceleration(const Pose2d &pose, wpi::units::curvature_t curvature,
wpi::units::meters_per_second_t velocity) const override {
MinMax MinMaxAcceleration(
const Pose2d& pose, wpi::units::curvature_t curvature,
wpi::units::meters_per_second_t velocity) const override {
return m_constraint->MinMaxAcceleration(pose, curvature, velocity);
}
std::shared_ptr<TrajectoryConstraint> m_constraint;
};
}; // namespace wpi::math
}; // namespace wpi::math
namespace pybind11 {
namespace detail {
namespace pybind11::detail {
template <> struct type_caster<wpi::math::PyTrajectoryConstraint> {
using value_conv = make_caster<std::shared_ptr<wpi::math::TrajectoryConstraint>>;
template <>
struct type_caster<wpi::math::PyTrajectoryConstraint> {
using value_conv =
make_caster<std::shared_ptr<wpi::math::TrajectoryConstraint>>;
PYBIND11_TYPE_CASTER(wpi::math::PyTrajectoryConstraint, _("wpimath._wpimath.TrajectoryConstraint"));
PYBIND11_TYPE_CASTER(wpi::math::PyTrajectoryConstraint,
_("wpimath._wpimath.TrajectoryConstraint"));
bool load(handle src, bool convert) {
value_conv conv;
@@ -40,15 +46,15 @@ template <> struct type_caster<wpi::math::PyTrajectoryConstraint> {
}
value.m_constraint =
cast_op<std::shared_ptr<wpi::math::TrajectoryConstraint>>(std::move(conv));
cast_op<std::shared_ptr<wpi::math::TrajectoryConstraint>>(
std::move(conv));
return true;
}
static handle cast(const wpi::math::PyTrajectoryConstraint &src,
static handle cast(const wpi::math::PyTrajectoryConstraint& src,
return_value_policy policy, handle parent) {
return value_conv::cast(src.m_constraint, policy, parent);
}
};
}; // namespace detail
}; // namespace pybind11
} // namespace pybind11::detail

View File

@@ -1,3 +1,5 @@
#pragma once
#include <string>
#include "wpi/math/geometry/Ellipse2d.hpp"
@@ -11,11 +13,11 @@
namespace rpy {
inline std::string toString(const wpi::math::Rotation2d &self) {
inline std::string toString(const wpi::math::Rotation2d& self) {
return "Rotation2d(" + std::to_string(self.Radians()()) + ")";
}
inline std::string toString(const wpi::math::Rotation3d &self) {
inline std::string toString(const wpi::math::Rotation3d& self) {
return "Rotation3d("
"x=" +
std::to_string(self.X()()) +
@@ -27,7 +29,7 @@ inline std::string toString(const wpi::math::Rotation3d &self) {
std::to_string(self.Z()()) + ")";
}
inline std::string toString(const wpi::math::Translation2d &self) {
inline std::string toString(const wpi::math::Translation2d& self) {
return "Translation2d("
"x=" +
std::to_string(self.X()()) +
@@ -36,7 +38,7 @@ inline std::string toString(const wpi::math::Translation2d &self) {
std::to_string(self.Y()()) + ")";
}
inline std::string toString(const wpi::math::Translation3d &self) {
inline std::string toString(const wpi::math::Translation3d& self) {
return "Translation3d("
"x=" +
std::to_string(self.X()()) +
@@ -48,7 +50,7 @@ inline std::string toString(const wpi::math::Translation3d &self) {
std::to_string(self.Z()()) + ")";
}
inline std::string toString(const wpi::math::Quaternion &self) {
inline std::string toString(const wpi::math::Quaternion& self) {
return "Quaternion("
"w=" +
std::to_string(self.W()) +
@@ -63,37 +65,36 @@ inline std::string toString(const wpi::math::Quaternion &self) {
std::to_string(self.Z()) + ")";
}
inline std::string toString(const wpi::math::Transform2d &self) {
inline std::string toString(const wpi::math::Transform2d& self) {
return "Transform2d(" + rpy::toString(self.Translation()) + ", " +
rpy::toString(self.Rotation()) + ")";
}
inline std::string toString(const wpi::math::Transform3d &self) {
inline std::string toString(const wpi::math::Transform3d& self) {
return "Transform3d(" + rpy::toString(self.Translation()) + ", " +
rpy::toString(self.Rotation()) + ")";
}
inline std::string toString(const wpi::math::Pose2d &self) {
inline std::string toString(const wpi::math::Pose2d& self) {
return "Pose2d(" + rpy::toString(self.Translation()) + ", " +
rpy::toString(self.Rotation()) + ")";
}
inline std::string toString(const wpi::math::Pose3d &self) {
inline std::string toString(const wpi::math::Pose3d& self) {
return "Pose3d(" + rpy::toString(self.Translation()) + ", " +
rpy::toString(self.Rotation()) + ")";
}
inline std::string toString(const wpi::math::Rectangle2d &self) {
inline std::string toString(const wpi::math::Rectangle2d& self) {
return "Rectangle2d(center=" + rpy::toString(self.Center()) +
", xWidth=" + std::to_string(self.XWidth()()) +
", yWidth=" + std::to_string(self.YWidth()()) + ")";
", xWidth=" + std::to_string(self.XWidth()()) +
", yWidth=" + std::to_string(self.YWidth()()) + ")";
}
inline std::string toString(const wpi::math::Ellipse2d &self) {
inline std::string toString(const wpi::math::Ellipse2d& self) {
return "Ellipse2d(center=" + rpy::toString(self.Center()) +
", xSemiAxis=" + std::to_string(self.XSemiAxis()()) +
", ySemiAxis=" + std::to_string(self.YSemiAxis()()) + ")";
", xSemiAxis=" + std::to_string(self.XSemiAxis()()) +
", ySemiAxis=" + std::to_string(self.YSemiAxis()()) + ")";
}
} // namespace rpy
} // namespace rpy

View File

@@ -1,4 +1,6 @@
#include "semiwrap_init.wpimath._wpimath.hpp"
SEMIWRAP_PYBIND11_MODULE(m) { initWrapper(m); }
SEMIWRAP_PYBIND11_MODULE(m) {
initWrapper(m);
}

View File

@@ -1,24 +1,24 @@
#pragma once
#include "wpi/units/time.hpp"
#include "wpi/units/length.hpp"
#include "wpi/units/time.hpp"
struct SomeClass {
static constexpr auto s_constant = 2_s;
static constexpr auto ms_constant1 = 20_ms;
static constexpr wpi::units::second_t ms_constant2 = 50_ms;
static constexpr wpi::units::millisecond_t ms_constant3 = 0.20_s;
static constexpr auto s_constant = 2_s;
static constexpr auto ms_constant1 = 20_ms;
static constexpr wpi::units::second_t ms_constant2 = 50_ms;
static constexpr wpi::units::millisecond_t ms_constant3 = 0.20_s;
bool checkDefaultByName1(wpi::units::second_t period = ms_constant1);
bool checkDefaultByName2(wpi::units::second_t period = ms_constant2);
bool checkDefaultByNum1(wpi::units::second_t period = 50_ms);
bool checkDefaultByNum2(wpi::units::second_t period = 0.5_s);
bool checkDefaultByName1(wpi::units::second_t period = ms_constant1);
bool checkDefaultByName2(wpi::units::second_t period = ms_constant2);
bool checkDefaultByNum1(wpi::units::second_t period = 50_ms);
bool checkDefaultByNum2(wpi::units::second_t period = 0.5_s);
wpi::units::second_t ms2s(wpi::units::millisecond_t ms);
wpi::units::millisecond_t s2ms(wpi::units::second_t s);
wpi::units::second_t ms2s(wpi::units::millisecond_t ms);
wpi::units::millisecond_t s2ms(wpi::units::second_t s);
static constexpr wpi::units::foot_t five_ft = 5_ft;
static constexpr wpi::units::foot_t five_ft = 5_ft;
wpi::units::meter_t ft2m(wpi::units::foot_t f);
};
wpi::units::meter_t ft2m(wpi::units::foot_t f);
};

View File

@@ -1,53 +1,50 @@
#include "semiwrap_init.wpimath_test._wpimath_test.hpp"
#include <module.h>
#include <stdexcept>
SEMIWRAP_PYBIND11_MODULE(m)
{
initWrapper(m);
#include <module.h>
#include "semiwrap_init.wpimath_test._wpimath_test.hpp"
SEMIWRAP_PYBIND11_MODULE(m) {
initWrapper(m);
}
bool SomeClass::checkDefaultByName1(wpi::units::second_t period)
{
if (period != SomeClass::ms_constant1) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
bool SomeClass::checkDefaultByName1(wpi::units::second_t period) {
if (period != SomeClass::ms_constant1) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
}
bool SomeClass::checkDefaultByName2(wpi::units::second_t period)
{
if (period != SomeClass::ms_constant2) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
bool SomeClass::checkDefaultByName2(wpi::units::second_t period) {
if (period != SomeClass::ms_constant2) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
}
bool SomeClass::checkDefaultByNum1(wpi::units::second_t period)
{
if (period != 50_ms) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
bool SomeClass::checkDefaultByNum1(wpi::units::second_t period) {
if (period != 50_ms) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
}
bool SomeClass::checkDefaultByNum2(wpi::units::second_t period)
{
if (period != 50_ms) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
bool SomeClass::checkDefaultByNum2(wpi::units::second_t period) {
if (period != 50_ms) {
throw std::runtime_error(wpi::units::to_string(period));
}
return true;
}
wpi::units::meter_t SomeClass::ft2m(wpi::units::foot_t f) {
return f;
return f;
}
wpi::units::second_t SomeClass::ms2s(wpi::units::millisecond_t ms) {
return ms;
return ms;
}
wpi::units::millisecond_t SomeClass::s2ms(wpi::units::second_t s) {
return s;
return s;
}