[wpimath] Disambiguate wpimath JNI functions (#6695)

Each collection of JNI functions now has its own class.
This commit is contained in:
Tyler Veness
2024-06-05 12:26:58 -07:00
committed by GitHub
parent df4694c9df
commit 5221069bcc
32 changed files with 1038 additions and 543 deletions

View File

@@ -0,0 +1,44 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include <Eigen/Core>
#include <wpi/jni_util.h>
#include "edu_wpi_first_math_jni_StateSpaceUtilJNI.h"
#include "frc/StateSpaceUtil.h"
using namespace wpi::java;
extern "C" {
/*
* Class: edu_wpi_first_math_jni_StateSpaceUtilJNI
* Method: isStabilizable
* Signature: (II[D[D)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_math_jni_StateSpaceUtilJNI_isStabilizable
(JNIEnv* env, jclass, jint states, jint inputs, jdoubleArray aSrc,
jdoubleArray bSrc)
{
JSpan<const jdouble> nativeA{env, aSrc};
JSpan<const jdouble> nativeB{env, bSrc};
Eigen::Map<const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic,
Eigen::RowMajor>>
A{nativeA.data(), states, states};
Eigen::Map<const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic,
Eigen::RowMajor>>
B{nativeB.data(), states, inputs};
bool isStabilizable =
frc::IsStabilizable<Eigen::Dynamic, Eigen::Dynamic>(A, B);
return isStabilizable;
}
} // extern "C"