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

@@ -23,10 +23,11 @@ Java_org_wpilib_math_jni_ArmFeedforwardJNI_calculate
jdouble currentAngle, jdouble currentVelocity, jdouble nextVelocity,
jdouble dt)
{
return wpi::math::ArmFeedforward{wpi::units::volt_t{ks}, wpi::units::volt_t{kg},
wpi::units::unit_t<wpi::math::ArmFeedforward::kv_unit>{kv},
wpi::units::unit_t<wpi::math::ArmFeedforward::ka_unit>{ka},
wpi::units::second_t{dt}}
return wpi::math::ArmFeedforward{
wpi::units::volt_t{ks}, wpi::units::volt_t{kg},
wpi::units::unit_t<wpi::math::ArmFeedforward::kv_unit>{kv},
wpi::units::unit_t<wpi::math::ArmFeedforward::ka_unit>{ka},
wpi::units::second_t{dt}}
.Calculate(wpi::units::radian_t{currentAngle},
wpi::units::radians_per_second_t{currentVelocity},
wpi::units::radians_per_second_t{nextVelocity})

View File

@@ -45,9 +45,9 @@ Java_org_wpilib_math_jni_DAREJNI_dareNoPrecondABQR
Eigen::RowMajor>>
Rmat{nativeR.data(), inputs, inputs};
auto result =
wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat, Rmat, false)
.value();
auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(
Amat, Bmat, Qmat, Rmat, false)
.value();
env->SetDoubleArrayRegion(S, 0, states * states, result.data());
}
@@ -84,8 +84,8 @@ Java_org_wpilib_math_jni_DAREJNI_dareNoPrecondABQRN
Eigen::RowMajor>>
Nmat{nativeN.data(), states, inputs};
auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat,
Rmat, Nmat, false)
auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(
Amat, Bmat, Qmat, Rmat, Nmat, false)
.value();
env->SetDoubleArrayRegion(S, 0, states * states, result.data());
@@ -119,8 +119,8 @@ Java_org_wpilib_math_jni_DAREJNI_dareABQR
Eigen::RowMajor>>
Rmat{nativeR.data(), inputs, inputs};
if (auto result =
wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat, Rmat)) {
if (auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(
Amat, Bmat, Qmat, Rmat)) {
env->SetDoubleArrayRegion(S, 0, states * states, result.value().data());
// K = (BᵀSB + R)⁻¹BᵀSA
} else if (result.error() == wpi::math::DAREError::QNotSymmetric ||
@@ -172,8 +172,8 @@ Java_org_wpilib_math_jni_DAREJNI_dareABQRN
Eigen::RowMajor>>
Nmat{nativeN.data(), states, inputs};
if (auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat,
Rmat, Nmat)) {
if (auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(
Amat, Bmat, Qmat, Rmat, Nmat)) {
env->SetDoubleArrayRegion(S, 0, states * states, result.value().data());
} else if (result.error() == wpi::math::DAREError::QNotSymmetric ||
result.error() == wpi::math::DAREError::QNotPositiveSemidefinite) {

View File

@@ -26,8 +26,9 @@ Java_org_wpilib_math_jni_Ellipse2dJNI_nearest
{
auto point =
wpi::math::Ellipse2d{
wpi::math::Pose2d{wpi::units::meter_t{centerX}, wpi::units::meter_t{centerY},
wpi::units::radian_t{centerHeading}},
wpi::math::Pose2d{wpi::units::meter_t{centerX},
wpi::units::meter_t{centerY},
wpi::units::radian_t{centerHeading}},
wpi::units::meter_t{xSemiAxis}, wpi::units::meter_t{ySemiAxis}}
.Nearest({wpi::units::meter_t{pointX}, wpi::units::meter_t{pointY}});

View File

@@ -28,7 +28,8 @@ Java_org_wpilib_math_jni_Transform3dJNI_log
jdouble relQx, jdouble relQy, jdouble relQz)
{
wpi::math::Transform3d transform3d{
wpi::units::meter_t{relX}, wpi::units::meter_t{relY}, wpi::units::meter_t{relZ},
wpi::units::meter_t{relX}, wpi::units::meter_t{relY},
wpi::units::meter_t{relZ},
wpi::math::Rotation3d{wpi::math::Quaternion{relQw, relQx, relQy, relQz}}};
wpi::math::Twist3d result = transform3d.Log();

View File

@@ -25,9 +25,10 @@ Java_org_wpilib_math_jni_Twist3dJNI_exp
(JNIEnv* env, jclass, jdouble twistDx, jdouble twistDy, jdouble twistDz,
jdouble twistRx, jdouble twistRy, jdouble twistRz)
{
wpi::math::Twist3d twist{wpi::units::meter_t{twistDx}, wpi::units::meter_t{twistDy},
wpi::units::meter_t{twistDz}, wpi::units::radian_t{twistRx},
wpi::units::radian_t{twistRy}, wpi::units::radian_t{twistRz}};
wpi::math::Twist3d twist{
wpi::units::meter_t{twistDx}, wpi::units::meter_t{twistDy},
wpi::units::meter_t{twistDz}, wpi::units::radian_t{twistRx},
wpi::units::radian_t{twistRy}, wpi::units::radian_t{twistRz}};
wpi::math::Transform3d result = twist.Exp();