Skip to content

Commit

Permalink
Switch wpical backend to GTSAM
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 29, 2024
1 parent 35476da commit d34b60f
Show file tree
Hide file tree
Showing 18 changed files with 974 additions and 353 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ wpilibVersioning.releaseMode = project.hasProperty('releaseMode')
allprojects {
repositories {
maven {
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
}
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
}
maven {
url = "https://maven.photonvision.org/snapshots"
}
}
if (project.hasProperty('releaseMode')) {
wpilibRepositories.addAllReleaseRepositories(it)
Expand Down
13 changes: 13 additions & 0 deletions shared/gtsam.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
nativeUtils {
nativeDependencyContainer {
gtsam(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2025.gtsam"
artifactId = "gtsam-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '4.3-1'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
}
}
}
1 change: 1 addition & 0 deletions wpical/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ target_link_libraries(
${OpenCV_LIBS}
wpigui
wpiutil
wpimath
Ceres::ceres
)

Expand Down
14 changes: 13 additions & 1 deletion wpical/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")

apply from: "${rootDir}/shared/ceres.gradle"
apply from: "${rootDir}/shared/gtsam.gradle"
apply from: "${rootDir}/shared/opencv.gradle"

task generateCppVersion() {
Expand Down Expand Up @@ -156,12 +157,14 @@ model {
it.buildable = false
return
}
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'ceres')
nativeUtils.useRequiredLibrary(it, 'opencv_static')
nativeUtils.useRequiredLibrary(it, 'gtsam')
nativeUtils.useRequiredLibrary(it, 'ceres')
it.cppCompiler.define 'GLOG_USE_GLOG_EXPORT'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.cppCompiler.define('GLOG_DEPRECATED', '__declspec(deprecated)')
Expand All @@ -175,6 +178,9 @@ model {
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore' << '-framework' << 'Accelerate'
} else {
it.cppCompiler.args.add("-Wno-deprecated-copy")
it.cppCompiler.args.add("-Wno-redundant-move")

it.linker.args << '-lX11' << "-lgfortran"
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
Expand Down Expand Up @@ -211,10 +217,13 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'ceres')
nativeUtils.useRequiredLibrary(it, 'opencv_static')
nativeUtils.useRequiredLibrary(it, 'gtsam')
it.cppCompiler.define('PROJECT_ROOT_PATH', testResources)
it.cppCompiler.define 'GLOG_USE_GLOG_EXPORT'

if (it.targetPlatform.name == nativeUtils.wpi.platforms.windowsarm64) {
// https://developercommunity.visualstudio.com/t/-imp-std-init-once-complete-unresolved-external-sy/1684365#T-N10041864
it.linker.args << '/alternatename:__imp___std_init_once_complete=__imp_InitOnceComplete'
Expand All @@ -240,6 +249,9 @@ model {
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}

it.cppCompiler.args.add("-Wno-deprecated-copy")
it.cppCompiler.args.add("-Wno-redundant-move")
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions wpical/src/main/native/cpp/cameracalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ int cameracalibration::calibrate(const std::string& input_video,
cv::Size boardSize(board_width - 1, board_height - 1);
cv::Size imagerSize(imagerWidthPixels, imagerHeightPixels);

int frameIdx = 0;
while (video_capture.grab()) {
std::cout << "Frame index " << frameIdx << std::endl;
frameIdx++;

cv::Mat frame;
video_capture.retrieve(frame);

Expand Down
Loading

0 comments on commit d34b60f

Please sign in to comment.