Skip to content

[wpical] Refactor to use WPILib libraries, modern C++ conventions, and LGPL libraries #7796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen

On macOS ARM, run `softwareupdate --install-rosetta`. This is necessary to be able to use the macOS x86 roboRIO toolchain on ARM.

On linux, run `sudo apt install gfortran`. This is necessary to be able to build WPIcal on linux platforms.

## Setup

Clone the WPILib repository and follow the instructions above for installing any required tooling. The build process uses versioning information from git. Downloading the source is not sufficient to run the build.
Expand Down
6 changes: 4 additions & 2 deletions shared/ceres.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
nativeUtils {
nativeDependencyContainer {
ceres(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2024.ceres"
groupId = "edu.wpi.first.thirdparty.frc2025.ceres"
artifactId = "ceres-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '2.2-3'
version = '2.2-2'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
targetPlatforms.addAll("linuxarm32", "linuxarm64")
}
}
}
2 changes: 2 additions & 0 deletions upstream_utils/eigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def eigen_inclusions(dp: Path, f: str):
modules = [
"Cholesky",
"Core",
"Dense",
"Eigenvalues",
"Geometry",
"Householder",
Expand All @@ -64,6 +65,7 @@ def eigen_inclusions(dp: Path, f: str):
"SparseCore",
"SparseLU",
"SparseQR",
"StdVector",
"misc",
"plugins",
]
Expand Down
3 changes: 3 additions & 0 deletions upstream_utils/mrcal_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def copy_upstream_src(wpilib_root: Path):
with open(f) as file:
content = file.read()
content = content.replace("#include <malloc.h>", "")
content = content.replace(
"suitesparse/cholmod_core.h", "suitesparse/cholmod.h"
)
content = content.replace(
"// mrcal_point3_t *c_observations_point_pool = observations_point;",
"mrcal_point3_t *c_observations_point_pool = observations_point;",
Expand Down
4 changes: 3 additions & 1 deletion wpical/.styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cppSrcFileInclude {
}

generatedFileExclude {
src/main/native/assets/
src/main/native/resources/
src/main/native/thirdparty/
src/main/native/win/wpical.ico
Expand All @@ -20,6 +21,7 @@ repoRootNameOverride {
}

includeOtherLibs {
^Eigen/
^GLFW
^ceres/
^fmt/
Expand All @@ -30,7 +32,7 @@ includeOtherLibs {
^mrcal_wrapper\.h$
^opencv2\.h$
^portable-file-dialogs\.h$
^tagpose\.h$
^units/
^wpi/
^wpigui
}
2 changes: 1 addition & 1 deletion wpical/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ else()
-Wno-missing-field-initializers
)
endif()
target_compile_options(wpical PRIVATE ${compile_flags})
set_target_properties(${wpical_thirdparty_src} PROPERTIES COMPILE_FLAGS ${compile_flags})

find_package(OpenCV REQUIRED)
find_package(Ceres CONFIG REQUIRED)
Expand Down
732 changes: 732 additions & 0 deletions wpical/WPICalThirdPartyNotices.txt

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions wpical/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem

if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64')) {
if (project.hasProperty('onlylinuxathena')) {
return;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ nativeUtils.platformConfigs.each {
it.cppCompiler.args.add("-fpermissive")
}
}
def testResources = "\"$rootDir/wpical/src/main/native/resources\"".replace("\\", "/")
def testResources = "\"$rootDir/wpical/src/main/native/assets\"".replace("\\", "/")
model {
components {
"${nativeName}"(NativeExecutableSpec) {
Expand Down Expand Up @@ -152,16 +152,18 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name.startsWith("linuxarm")) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
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')
it.cppCompiler.define 'OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT'
it.cppCompiler.define 'GLOG_USE_GLOG_EXPORT'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.cppCompiler.define('GLOG_DEPRECATED', '__declspec(deprecated)')
Expand All @@ -175,7 +177,7 @@ 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.linker.args << '-lX11' << "-lgfortran"
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
Expand Down Expand Up @@ -203,16 +205,18 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name.startsWith("linuxarm")) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
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')
it.cppCompiler.define 'OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT'
it.cppCompiler.define('PROJECT_ROOT_PATH', testResources)
it.cppCompiler.define 'GLOG_USE_GLOG_EXPORT'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.windowsarm64) {
Expand All @@ -236,7 +240,7 @@ 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.linker.args << '-lX11' << '-lgfortran'
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
Expand Down
4 changes: 4 additions & 0 deletions wpical/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ model {
into '/'
}

from(file("$rootDir/wpical/WPICalThirdPartyNotices.txt")) {
into '/'
}

if (binary.targetPlatform.operatingSystem.isWindows()) {
def exePath = binary.executable.file.absolutePath
exePath = exePath.substring(0, exePath.length() - 4)
Expand Down
5 changes: 5 additions & 0 deletions wpical/src/main/native/cpp/VideoProcessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 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.

namespace cameracalibration {} // namespace cameracalibration
Loading
Loading