Skip to content
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

WPIcal: Field Calibration Tool #6915

Merged
merged 126 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
0575cce
Update 10/20/2024.
ElliotScher Oct 21, 2024
f37c4a5
Remove unused dependencies.
ElliotScher Oct 21, 2024
a835dd7
Remove unused dependencies from CMakeLists.txt.
ElliotScher Oct 21, 2024
6acd803
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 21, 2024
106b174
Resolve final dependency errors.
ElliotScher Oct 22, 2024
c4666c3
Add mrcal, libdogleg, and mrcal-java
Gold856 Oct 22, 2024
d6381e9
Add ceres
Gold856 Oct 22, 2024
2ffe672
Merge pull request #2 from Gold856/mrcal
ElliotScher Oct 22, 2024
a9e1bf9
Update shared/ceres.gradle
ElliotScher Oct 22, 2024
9478a7d
Update shared/ceres.gradle
ElliotScher Oct 22, 2024
b8b0bcf
Update wpical/build.gradle
ElliotScher Oct 22, 2024
5092322
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 22, 2024
83d2c08
Format and lint.
ElliotScher Oct 22, 2024
8436c65
Link opencv.
ElliotScher Oct 22, 2024
7235462
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 23, 2024
955c3fb
C code compiles.
ElliotScher Oct 25, 2024
19403e0
Revert "Link opencv."
ElliotScher Oct 25, 2024
3035a17
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 25, 2024
8c8bcb5
Remove wpimath dependency.
ElliotScher Oct 25, 2024
e08f44e
Add stereo and remove const points array.
ElliotScher Oct 25, 2024
39efbba
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 26, 2024
130ab65
Merge branch 'wpilibsuite:main' into main
ElliotScher Oct 27, 2024
09919a4
Update to ceres 2.2-2
ElliotScher Oct 28, 2024
314d6c8
Add compiler suppressions.
ElliotScher Oct 28, 2024
18b3d15
Add Glog error suppression.
ElliotScher Oct 28, 2024
1cf076b
Fix GLOG_NO_EXPORT.
ElliotScher Oct 28, 2024
69f9ed1
Fix cholmod.h header path
ElliotScher Oct 28, 2024
4a4f742
Fix thirdparty upstream utils.
ElliotScher Oct 28, 2024
ac6c17c
Fix mrcal warnings.
ElliotScher Oct 28, 2024
3cc2b12
Add c/cpp compiler suppressions.
ElliotScher Oct 28, 2024
fb2c8b1
add deprecated declarations suppression.
ElliotScher Oct 29, 2024
16349be
Merge branch 'main' into main
ElliotScher Oct 29, 2024
b29e4c1
Fix glog errors.
ElliotScher Nov 1, 2024
a9aa0a1
Merge branch 'wpilibsuite:main' into main
ElliotScher Nov 5, 2024
7111eb2
Fix mrcal build errors.
ElliotScher Nov 6, 2024
b9e57b9
Merge branch 'wpilibsuite:main' into main
ElliotScher Nov 6, 2024
8ff3856
Update opencv.
ElliotScher Nov 7, 2024
2ef720a
Merge branch 'wpilibsuite:main' into main
ElliotScher Nov 7, 2024
138e592
Merge branch 'main' into main
ElliotScher Nov 11, 2024
f260ef5
fix opencv version.
ElliotScher Nov 11, 2024
a937a06
Update shared/config.gradle
ElliotScher Nov 11, 2024
f158766
Update shared/opencv.gradle
ElliotScher Nov 11, 2024
053ce55
Fix cameracalibration aruco includes.
ElliotScher Nov 11, 2024
ef8c59e
Add maybe-uninitialized suppression.
ElliotScher Nov 11, 2024
cd1959e
Merge branch 'wpilibsuite:main' into main
ElliotScher Nov 16, 2024
1b55089
More MSVC fixes
Gold856 Nov 11, 2024
f0ff201
Merge pull request #4 from Gold856/wpical
ElliotScher Nov 16, 2024
f3caf2c
fix glog errors on linux, bump opencv version
ElliotScher Nov 19, 2024
a2ceaff
update mrcal_java upstreamutil to prevent stack allocation errors.
ElliotScher Nov 21, 2024
94493a7
Merge branch 'main' into main
ElliotScher Dec 2, 2024
0e98e7e
update opencv and add link gfortran for linux.
ElliotScher Dec 4, 2024
32df468
Update ceres dependency to 2.2-3.
ElliotScher Dec 4, 2024
0241ac1
install gfortran during ci
ElliotScher Dec 4, 2024
b27ebe7
revert
ElliotScher Dec 4, 2024
b55f0d6
link gfortran.
ElliotScher Dec 5, 2024
e33cca9
Update .github/workflows/gradle.yml
ElliotScher Dec 5, 2024
e2dfc77
More MSVC fixes
Gold856 Nov 22, 2024
d92b321
Update mrcal-java to fix MSVC errors
Gold856 Nov 30, 2024
b8bca13
Finally compiling on Windows!
Gold856 Dec 1, 2024
c483898
Link missing libraries
Gold856 Dec 1, 2024
7a0c91b
Add wpical regression tests
mcm001 Dec 1, 2024
ab73d56
ooga booga
mcm001 Dec 4, 2024
a560a65
Fix Gradle test build
Gold856 Dec 5, 2024
871a7a3
fix the compiler errors
mcm001 Dec 5, 2024
56761a7
aaaaaaaaaaa
mcm001 Dec 5, 2024
bd64630
ayyyyy mrcal fixes
mcm001 Dec 5, 2024
3793241
tests pass!
mcm001 Dec 5, 2024
b834349
remove comment
mcm001 Dec 5, 2024
66c73e9
Fix all the tests holy shit fucking finally
mcm001 Dec 5, 2024
bf24df0
run lint
mcm001 Dec 5, 2024
c2979bf
ez
mcm001 Dec 5, 2024
4dfcdab
Format tests and use PROJECT_ROOT_PATH macro to give tests access to …
Gold856 Dec 5, 2024
1d8e887
Move mrcal patch to upstream_utils
Gold856 Dec 5, 2024
8c128f1
Return early if targeting ARM Linux
Gold856 Dec 5, 2024
07f51ae
Ifdef main out if building for ARM Linux
Gold856 Dec 5, 2024
9812e15
Build fixes
Gold856 Dec 5, 2024
61d0b10
Don't show debug window during tests
Gold856 Dec 5, 2024
dd68cf5
Lint
Gold856 Dec 5, 2024
696ad00
Add camera calibration JSON to .gitignore
Gold856 Dec 5, 2024
deb13af
Don't include malloc.h
Gold856 Dec 5, 2024
08e4b98
Merge pull request #5 from Gold856/ElliotScher/main
ElliotScher Dec 5, 2024
97dce67
Move wpical in cmakelists.txt.
ElliotScher Dec 5, 2024
8fe34de
Update wpical/src/test/native/cpp/test_result_is_exact.cpp
ElliotScher Dec 5, 2024
0975f5f
Merge branch 'main' into main
ElliotScher Dec 10, 2024
bfb1153
Fix duplicated try catch.
ElliotScher Dec 13, 2024
bd78165
Link to Accelerate framework
Gold856 Dec 10, 2024
722bf1a
Format
Gold856 Dec 10, 2024
149a362
Patch up CMake build
Gold856 Dec 10, 2024
0fb9b18
Transcode videos to H264 and remove the audio tracks, fix linking and…
Gold856 Dec 11, 2024
be452e5
Add MJPEG variants of videos for Linux testing
Gold856 Dec 13, 2024
893a3df
Block out more highgui calls
Gold856 Dec 13, 2024
865c01f
Add more specific error
Gold856 Dec 13, 2024
a3f3575
Merge pull request #6 from Gold856/wpical
ElliotScher Dec 14, 2024
455d941
Fix mrcal camera calibration, add .mjpg as valid video file format, r…
ElliotScher Dec 14, 2024
6832afd
lint and format
ElliotScher Dec 14, 2024
623292e
Use AVI instead of raw MJPEG
Gold856 Dec 14, 2024
2269996
Merge pull request #7 from Gold856/ElliotScher/main
ElliotScher Dec 14, 2024
1cf2b04
add .avi as accepted video format
ElliotScher Dec 14, 2024
9986f4a
disable debug windows on linux
ElliotScher Dec 14, 2024
2cb4dc0
First review round.
ElliotScher Dec 15, 2024
172e3f5
Merge pull request #9 from ElliotScher/testing
ElliotScher Dec 15, 2024
4973655
Fix hardcoded field dimensions, fix fmap json.
ElliotScher Dec 16, 2024
29c2a31
Merge pull request #10 from ElliotScher/testing
ElliotScher Dec 16, 2024
87d5edb
pose to Pose.
ElliotScher Dec 22, 2024
4d70314
Static filter method.
ElliotScher Dec 22, 2024
58f66d5
Normalize angle under 2pi before wrapping between (-pi, pi), fieldmap…
ElliotScher Dec 22, 2024
6b79387
camera model tuple to struct, static field calibration helper functions.
ElliotScher Dec 23, 2024
d493010
Remove fieldcalibration function prototypes.
ElliotScher Dec 23, 2024
76125af
inline helper functions.
ElliotScher Dec 23, 2024
fadf4fc
Merge branch 'wpilibsuite:main' into main
ElliotScher Dec 23, 2024
b804150
Fix includes
ElliotScher Dec 24, 2024
241b47a
Fix icon.ico
ElliotScher Dec 24, 2024
a302034
Update wpical/build.gradle
ElliotScher Dec 25, 2024
7cc8191
Update wpical/build.gradle
ElliotScher Dec 25, 2024
5103d5f
Merge branch 'wpilibsuite:main' into main
ElliotScher Dec 25, 2024
c01b5cc
Update wpical/src/main/native/cpp/WPIcal.cpp
ElliotScher Dec 25, 2024
acacb8f
Regenerate ICO file
Gold856 Dec 25, 2024
8960c85
Merge pull request #12 from Gold856/ElliotScher/main
ElliotScher Dec 25, 2024
a24267a
tagsize constant
ElliotScher Dec 25, 2024
41a8fc6
format.
ElliotScher Dec 25, 2024
b0b6970
Fix wpical cmake.
ElliotScher Dec 26, 2024
c08dcb7
Separate saving json from camera calibration.
ElliotScher Dec 26, 2024
c7b0c71
add Fortran to wpical cmake.
ElliotScher Dec 27, 2024
375d674
Revert blank line removal
ElliotScher Dec 28, 2024
c0c286d
Check minimath generation
Gold856 Dec 28, 2024
960f697
Merge pull request #13 from Gold856/ElliotScher/main
ElliotScher Dec 28, 2024
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: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ networktables.json

ntcore/connectionlistenertest.json
ntcore/timesynctest.json

PeterJohnson marked this conversation as resolved.
Show resolved Hide resolved
wpical/src/main/native/resources/camera calibration.json
ElliotScher marked this conversation as resolved.
Show resolved Hide resolved
nanopb_pb2.py

# Created by the jenkins test script
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ cmake_dependent_option(
)
option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
option(WITH_NTCORE "Build ntcore" ON)
option(WITH_WPICAL "Build wpical" OFF)
option(WITH_WPIMATH "Build wpimath" ON)
cmake_dependent_option(
WITH_WPIUNITS
Expand Down Expand Up @@ -142,6 +143,7 @@ if(WITH_DOCS)
include(AddDoxygenDocs)
add_doxygen_docs()
endif()
find_package(Ceres CONFIG)
ElliotScher marked this conversation as resolved.
Show resolved Hide resolved
find_package(LIBSSH CONFIG 0.7.1)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
Expand Down Expand Up @@ -314,6 +316,9 @@ if(WITH_GUI)
add_subdirectory(glass)
add_subdirectory(outlineviewer)
add_subdirectory(sysid)
if(Ceres_FOUND AND WITH_WPICAL)
ElliotScher marked this conversation as resolved.
Show resolved Hide resolved
add_subdirectory(wpical)
endif()
if(LIBSSH_FOUND)
add_subdirectory(roborioteamnumbersetter)
add_subdirectory(datalogtool)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ 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.
ElliotScher marked this conversation as resolved.
Show resolved Hide resolved

## 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
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ include 'epilogue-processor'
include 'epilogue-runtime'
include 'thirdparty:googletest'
include 'thirdparty:imgui_suite'
include 'wpical'

buildCache {
def cred = {
Expand Down
13 changes: 13 additions & 0 deletions shared/ceres.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
nativeUtils {
nativeDependencyContainer {
ceres(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2024.ceres"
artifactId = "ceres-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '2.2-3'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
}
}
}
2 changes: 1 addition & 1 deletion shared/java/javastyle.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spotless {
target fileTree('.') {
include '**/*.json'
exclude '**/build/**', '**/build-*/**', '**/bin/**'
exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json', '**/*test.json'
exclude '**/simgui-ds.json', '**/simgui-window.json', '**/simgui.json', '**/networktables.json', '**/*test.json', '**/camera calibration.json'
ElliotScher marked this conversation as resolved.
Show resolved Hide resolved
}
gson()
.indentWithSpaces(2)
Expand Down
58 changes: 58 additions & 0 deletions upstream_utils/libdogleg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

import os
import shutil

from upstream_utils import Lib, walk_cwd_and_copy_if


def copy_upstream_src(wpilib_root):
wpical = os.path.join(wpilib_root, "wpical")

# Delete old install
for d in [
"src/main/native/thirdparty/libdogleg/src",
"src/main/native/thirdparty/libdogleg/include",
]:
shutil.rmtree(os.path.join(wpical, d), ignore_errors=True)

files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.h"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/include"),
)
for f in files:
with open(f) as file:
content = file.read()
content = content.replace(
"#include <cholmod.h>", "#include <suitesparse/cholmod.h>"
)
with open(f, "w") as file:
file.write(content)

files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.cpp"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/src"),
)
for f in files:
with open(f) as file:
content = file.read()
content = content.replace("#warning", "// #warning")
content = content.replace("__attribute__((unused))", "")
content = content.replace(
"#include <cholmod_function.h>", "#include <suitesparse/cholmod_function.h>"
)
with open(f, "w") as file:
file.write(content)


def main():
name = "libdogleg"
url = "https://github.com/dkogan/libdogleg"
tag = "c971ea43088d286a3683c1039b9a85f761f7df15"

libdogleg = Lib(name, url, tag, copy_upstream_src)
libdogleg.main()


if __name__ == "__main__":
main()
38 changes: 38 additions & 0 deletions upstream_utils/libdogleg_patches/0001-Convert-to-C.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gold856 <[email protected]>
Date: Fri, 29 Nov 2024 19:52:22 -0500
Subject: [PATCH 1/3] Convert to C++

---
dogleg.c => dogleg.cpp | 0
dogleg.h | 8 +++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
rename dogleg.c => dogleg.cpp (100%)

diff --git a/dogleg.c b/dogleg.cpp
similarity index 100%
rename from dogleg.c
rename to dogleg.cpp
diff --git a/dogleg.h b/dogleg.h
index 74337263a89d3448f55e125db6702ebfa7588b97..4a23b669a30642d290549bb94a1c787f079d0647 100644
--- a/dogleg.h
+++ b/dogleg.h
@@ -126,7 +126,9 @@ typedef struct

} dogleg_solverContext_t;

-
+#ifdef __cplusplus
+extern "C" {
+#endif
// Fills in the given structure with the default parameter set
void dogleg_getDefaultParameters(dogleg_parameters2_t* parameters);

@@ -293,3 +295,7 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
int NoutlierFeatures,
dogleg_operatingPoint_t* point,
dogleg_solverContext_t* ctx);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gold856 <[email protected]>
Date: Fri, 29 Nov 2024 19:54:54 -0500
Subject: [PATCH 2/3] Replace VLAs with vectors

---
dogleg.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/dogleg.cpp b/dogleg.cpp
index 7e4259c303e21a9f4c63ba16f1bf5df131935057..9ed95f64b232f41a51fe23d72885ecadd86dc065 100644
--- a/dogleg.cpp
+++ b/dogleg.cpp
@@ -6,6 +6,7 @@
// Apparently I need this in MSVC to get constants
#define _USE_MATH_DEFINES

+#include <vector>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
@@ -1907,7 +1908,7 @@ static bool getOutliernessFactors_dense( // output
// where A = Jo inv(JtJ) Jot
//
// A is symmetric. I store the upper triangle
- double A[featureSize*(featureSize+1)/2];
+ std::vector<double> A(featureSize*(featureSize+1)/2);
int iA=0;
for(int i=0; i<featureSize; i++)
for(int j=i; j<featureSize; j++, iA++)
@@ -1921,7 +1922,7 @@ static bool getOutliernessFactors_dense( // output
}
accum_outlierness_factor(&factors[i_feature],
&point->x[i_measurement],
- A, featureSize, *scale);
+ A.data(), featureSize, *scale);
}

result = true;
@@ -2008,7 +2009,7 @@ static bool getOutliernessFactors_sparse( // output
// where A = Jo inv(JtJ) Jot
//
// A is symmetric. I store the upper triangle
- double A[featureSize*(featureSize+1)/2];
+ std::vector<double> A(featureSize*(featureSize+1)/2);
int iA=0;
for(int i=0; i<featureSize; i++)
for(int j=i; j<featureSize; j++, iA++)
@@ -2027,7 +2028,7 @@ static bool getOutliernessFactors_sparse( // output
}
accum_outlierness_factor(&factors[i_feature],
&point->x[i_measurement],
- A, featureSize, *scale);
+ A.data(), featureSize, *scale);
}

result = true;
@@ -2212,8 +2213,8 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu

// This is Jt because cholmod thinks in terms of col-first instead of
// row-first
- int Jt_p[featureSize+1];
- int Jt_i[NstateActive*featureSize];
+ std::vector<int> Jt_p(featureSize+1);
+ std::vector<int> Jt_i(NstateActive*featureSize);
for(int i=0; i<=featureSize; i++)
{
Jt_p[i] = i*NstateActive;
@@ -2224,8 +2225,8 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
cholmod_sparse Jt_query_sparse = {.nrow = ctx->Nstate,
.ncol = featureSize,
.nzmax = NstateActive*featureSize,
- .p = (void*)Jt_p,
- .i = (void*)Jt_i,
+ .p = (void*)Jt_p.data(),
+ .i = (void*)Jt_i.data(),
.x = (double*)JqueryFeature,
.sorted = 1,
.packed = 1,
Loading
Loading