mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -8,7 +8,7 @@
|
||||
#include "wpi/math/controller/ArmFeedforward.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -23,13 +23,13 @@ Java_org_wpilib_math_jni_ArmFeedforwardJNI_calculate
|
||||
jdouble currentAngle, jdouble currentVelocity, jdouble nextVelocity,
|
||||
jdouble dt)
|
||||
{
|
||||
return frc::ArmFeedforward{units::volt_t{ks}, units::volt_t{kg},
|
||||
units::unit_t<frc::ArmFeedforward::kv_unit>{kv},
|
||||
units::unit_t<frc::ArmFeedforward::ka_unit>{ka},
|
||||
units::second_t{dt}}
|
||||
.Calculate(units::radian_t{currentAngle},
|
||||
units::radians_per_second_t{currentVelocity},
|
||||
units::radians_per_second_t{nextVelocity})
|
||||
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})
|
||||
.value();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/math/linalg/DARE.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -46,7 +46,7 @@ Java_org_wpilib_math_jni_DAREJNI_dareNoPrecondABQR
|
||||
Rmat{nativeR.data(), inputs, inputs};
|
||||
|
||||
auto result =
|
||||
frc::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat, Rmat, false)
|
||||
wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat, Rmat, false)
|
||||
.value();
|
||||
|
||||
env->SetDoubleArrayRegion(S, 0, states * states, result.data());
|
||||
@@ -84,7 +84,7 @@ Java_org_wpilib_math_jni_DAREJNI_dareNoPrecondABQRN
|
||||
Eigen::RowMajor>>
|
||||
Nmat{nativeN.data(), states, inputs};
|
||||
|
||||
auto result = frc::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat,
|
||||
auto result = wpi::math::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat,
|
||||
Rmat, Nmat, false)
|
||||
.value();
|
||||
|
||||
@@ -120,21 +120,21 @@ Java_org_wpilib_math_jni_DAREJNI_dareABQR
|
||||
Rmat{nativeR.data(), inputs, inputs};
|
||||
|
||||
if (auto result =
|
||||
frc::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat, Rmat)) {
|
||||
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() == frc::DAREError::QNotSymmetric ||
|
||||
result.error() == frc::DAREError::QNotPositiveSemidefinite) {
|
||||
} else if (result.error() == wpi::math::DAREError::QNotSymmetric ||
|
||||
result.error() == wpi::math::DAREError::QNotPositiveSemidefinite) {
|
||||
illegalArgEx.Throw(
|
||||
env, fmt::format("{}\n\nQ =\n{}\n", to_string(result.error()), Qmat));
|
||||
} else if (result.error() == frc::DAREError::RNotSymmetric ||
|
||||
result.error() == frc::DAREError::RNotPositiveDefinite) {
|
||||
} else if (result.error() == wpi::math::DAREError::RNotSymmetric ||
|
||||
result.error() == wpi::math::DAREError::RNotPositiveDefinite) {
|
||||
illegalArgEx.Throw(
|
||||
env, fmt::format("{}\n\nR =\n{}\n", to_string(result.error()), Rmat));
|
||||
} else if (result.error() == frc::DAREError::ABNotStabilizable) {
|
||||
} else if (result.error() == wpi::math::DAREError::ABNotStabilizable) {
|
||||
illegalArgEx.Throw(env, fmt::format("{}\n\nA =\n{}\nB =\n{}\n",
|
||||
to_string(result.error()), Amat, Bmat));
|
||||
} else if (result.error() == frc::DAREError::ACNotDetectable) {
|
||||
} else if (result.error() == wpi::math::DAREError::ACNotDetectable) {
|
||||
illegalArgEx.Throw(env, fmt::format("{}\n\nA =\n{}\nQ =\n{}\n",
|
||||
to_string(result.error()), Amat, Qmat));
|
||||
}
|
||||
@@ -172,23 +172,23 @@ Java_org_wpilib_math_jni_DAREJNI_dareABQRN
|
||||
Eigen::RowMajor>>
|
||||
Nmat{nativeN.data(), states, inputs};
|
||||
|
||||
if (auto result = frc::DARE<Eigen::Dynamic, Eigen::Dynamic>(Amat, Bmat, Qmat,
|
||||
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() == frc::DAREError::QNotSymmetric ||
|
||||
result.error() == frc::DAREError::QNotPositiveSemidefinite) {
|
||||
} else if (result.error() == wpi::math::DAREError::QNotSymmetric ||
|
||||
result.error() == wpi::math::DAREError::QNotPositiveSemidefinite) {
|
||||
illegalArgEx.Throw(
|
||||
env, fmt::format("{}\n\nQ =\n{}\n", to_string(result.error()), Qmat));
|
||||
} else if (result.error() == frc::DAREError::RNotSymmetric ||
|
||||
result.error() == frc::DAREError::RNotPositiveDefinite) {
|
||||
} else if (result.error() == wpi::math::DAREError::RNotSymmetric ||
|
||||
result.error() == wpi::math::DAREError::RNotPositiveDefinite) {
|
||||
illegalArgEx.Throw(
|
||||
env, fmt::format("{}\n\nR =\n{}\n", to_string(result.error()), Rmat));
|
||||
} else if (result.error() == frc::DAREError::ABNotStabilizable) {
|
||||
} else if (result.error() == wpi::math::DAREError::ABNotStabilizable) {
|
||||
illegalArgEx.Throw(
|
||||
env,
|
||||
fmt::format("{}\n\nA =\n{}\nB =\n{}\n", to_string(result.error()),
|
||||
Amat - Bmat * Rmat.llt().solve(Nmat.transpose()), Bmat));
|
||||
} else if (result.error() == frc::DAREError::ACNotDetectable) {
|
||||
} else if (result.error() == wpi::math::DAREError::ACNotDetectable) {
|
||||
auto R_llt = Rmat.llt();
|
||||
illegalArgEx.Throw(
|
||||
env, fmt::format("{}\n\nA =\n{}\nQ =\n{}\n", to_string(result.error()),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "org_wpilib_math_jni_EigenJNI.h"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/array.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -25,13 +25,13 @@ Java_org_wpilib_math_jni_Ellipse2dJNI_nearest
|
||||
jdoubleArray nearestPoint)
|
||||
{
|
||||
auto point =
|
||||
frc::Ellipse2d{
|
||||
frc::Pose2d{units::meter_t{centerX}, units::meter_t{centerY},
|
||||
units::radian_t{centerHeading}},
|
||||
units::meter_t{xSemiAxis}, units::meter_t{ySemiAxis}}
|
||||
.Nearest({units::meter_t{pointX}, units::meter_t{pointY}});
|
||||
wpi::math::Ellipse2d{
|
||||
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}});
|
||||
|
||||
wpi::array buf{point.X().value(), point.Y().value()};
|
||||
wpi::util::array buf{point.X().value(), point.Y().value()};
|
||||
env->SetDoubleArrayRegion(nearestPoint, 0, 2, buf.data());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
//
|
||||
// Globals and load/unload
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
extern wpi::java::JException illegalArgEx;
|
||||
extern wpi::java::JException ioEx;
|
||||
extern wpi::java::JException trajectorySerializationEx;
|
||||
extern wpi::util::java::JException illegalArgEx;
|
||||
extern wpi::util::java::JException ioEx;
|
||||
extern wpi::util::java::JException trajectorySerializationEx;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/math/util/StateSpaceUtil.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -36,7 +36,7 @@ Java_org_wpilib_math_jni_StateSpaceUtilJNI_isStabilizable
|
||||
B{nativeB.data(), states, inputs};
|
||||
|
||||
bool isStabilizable =
|
||||
frc::IsStabilizable<Eigen::Dynamic, Eigen::Dynamic>(A, B);
|
||||
wpi::math::IsStabilizable<Eigen::Dynamic, Eigen::Dynamic>(A, B);
|
||||
|
||||
return isStabilizable;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -27,11 +27,11 @@ Java_org_wpilib_math_jni_Transform3dJNI_log
|
||||
(JNIEnv* env, jclass, jdouble relX, jdouble relY, jdouble relZ, jdouble relQw,
|
||||
jdouble relQx, jdouble relQy, jdouble relQz)
|
||||
{
|
||||
frc::Transform3d transform3d{
|
||||
units::meter_t{relX}, units::meter_t{relY}, units::meter_t{relZ},
|
||||
frc::Rotation3d{frc::Quaternion{relQw, relQx, relQy, relQz}}};
|
||||
wpi::math::Transform3d transform3d{
|
||||
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}}};
|
||||
|
||||
frc::Twist3d result = transform3d.Log();
|
||||
wpi::math::Twist3d result = transform3d.Log();
|
||||
|
||||
return MakeJDoubleArray(
|
||||
env, {{result.dx.value(), result.dy.value(), result.dz.value(),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/util/jni_util.hpp"
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -25,11 +25,11 @@ Java_org_wpilib_math_jni_Twist3dJNI_exp
|
||||
(JNIEnv* env, jclass, jdouble twistDx, jdouble twistDy, jdouble twistDz,
|
||||
jdouble twistRx, jdouble twistRy, jdouble twistRz)
|
||||
{
|
||||
frc::Twist3d twist{units::meter_t{twistDx}, units::meter_t{twistDy},
|
||||
units::meter_t{twistDz}, units::radian_t{twistRx},
|
||||
units::radian_t{twistRy}, 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}};
|
||||
|
||||
frc::Transform3d result = twist.Exp();
|
||||
wpi::math::Transform3d result = twist.Exp();
|
||||
|
||||
const auto& resultQuaternion = result.Rotation().GetQuaternion();
|
||||
return MakeJDoubleArray(
|
||||
|
||||
Reference in New Issue
Block a user