Skip to content

Commit 0fdd4b0

Browse files
committed
download whippymath
1 parent 7d1e76f commit 0fdd4b0

File tree

4 files changed

+38
-48
lines changed

4 files changed

+38
-48
lines changed

CMakeLists.txt

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,46 @@ include(FetchContent)
2222
# https://github.com/PhotonVision/photonvision/blob/main/build.gradle
2323
set(OPENCV_YEAR "frc2025")
2424
set(OPENCV_VERSION "4.10.0-3")
25+
set(WPIMATH_VERSION "2026.2.1")
2526

2627
# type can be "", "debug", "static", or "staticdebug"
2728
set(OPENCV_TYPE "")
2829

29-
# Check if OPENCV_ARCH is set to determine OpenCV source
30-
if(DEFINED OPENCV_ARCH AND NOT OPENCV_ARCH STREQUAL "")
31-
# Download opencv from FRC maven repository
32-
message(STATUS "Using FRC OpenCV for architecture: ${OPENCV_ARCH}")
30+
message(STATUS "Using FRC OpenCV for architecture: ${OPENCV_ARCH}")
3331

34-
FetchContent_Declare(
35-
opencv_lib
36-
URL
37-
https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR}/opencv/opencv-cpp/${OPENCV_VERSION}/opencv-cpp-${OPENCV_VERSION}-${OPENCV_ARCH}${OPENCV_TYPE}.zip
38-
)
39-
FetchContent_MakeAvailable(opencv_lib)
32+
FetchContent_Declare(
33+
opencv_lib
34+
URL
35+
https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR}/opencv/opencv-cpp/${OPENCV_VERSION}/opencv-cpp-${OPENCV_VERSION}-${OPENCV_ARCH}${OPENCV_TYPE}.zip
36+
)
37+
FetchContent_MakeAvailable(opencv_lib)
4038

41-
# download OpenCV headers
42-
FetchContent_Declare(
43-
opencv_header
44-
URL
45-
https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR}/opencv/opencv-cpp/${OPENCV_VERSION}/opencv-cpp-${OPENCV_VERSION}-headers.zip
46-
)
47-
FetchContent_MakeAvailable(opencv_header)
48-
49-
# This probably doesn't work great with shared libraries, but I don't care about those right now
50-
file(
51-
GLOB_RECURSE OPENCV_LIB_PATH
52-
"${opencv_lib_SOURCE_DIR}/**/*.lib"
53-
"${opencv_lib_SOURCE_DIR}/**/*.so*"
54-
"${opencv_lib_SOURCE_DIR}/**/*.*.dylib"
55-
)
56-
set(OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR})
57-
set(OPENCV_LIBRARIES ${OPENCV_LIB_PATH})
58-
message(STATUS "Using FRC OpenCV libraries: ${OPENCV_LIB_PATH}")
59-
else()
60-
# Use system OpenCV
61-
message(STATUS "OPENCV_ARCH not set, using system OpenCV")
62-
find_package(OpenCV REQUIRED)
63-
64-
set(OPENCV_INCLUDE_PATH ${OpenCV_INCLUDE_DIRS})
65-
set(OPENCV_LIBRARIES ${OpenCV_LIBS})
66-
message(STATUS "Found system OpenCV version: ${OpenCV_VERSION}")
67-
message(STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS}")
68-
message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")
69-
endif()
39+
# download OpenCV headers
40+
FetchContent_Declare(
41+
opencv_header
42+
URL
43+
https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR}/opencv/opencv-cpp/${OPENCV_VERSION}/opencv-cpp-${OPENCV_VERSION}-headers.zip
44+
)
45+
FetchContent_MakeAvailable(opencv_header)
46+
47+
file(
48+
GLOB_RECURSE OPENCV_LIB_PATH
49+
"${opencv_lib_SOURCE_DIR}/**/*.lib"
50+
"${opencv_lib_SOURCE_DIR}/**/*.so*"
51+
"${opencv_lib_SOURCE_DIR}/**/*.*.dylib"
52+
)
53+
set(OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR})
54+
set(OPENCV_LIBRARIES ${OPENCV_LIB_PATH})
55+
message(STATUS "Using FRC OpenCV libraries: ${OPENCV_LIB_PATH}")
56+
57+
# Also download wpimath
58+
FetchContent_Declare(
59+
wpimath_header
60+
URL
61+
https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpimath/wpimath-cpp/${WPIMATH_VERSION}/wpimath-cpp-${WPIMATH_VERSION}-headers.zip
62+
)
63+
FetchContent_MakeAvailable(wpimath_header)
64+
set(WPIMATH_INCLUDE_PATH ${wpimath_header_SOURCE_DIR})
7065

7166
# Openblas/suitesparse/friends
7267
# From https://github.com/wpilibsuite/thirdparty-ceres/blob/main/CMakeLists.txt
@@ -193,7 +188,7 @@ add_library(mrcal_jni SHARED ${INCLUDE_HPP} ${SRC_HPP} ${SRC_CPP})
193188
target_include_directories(
194189
mrcal_jni
195190
SYSTEM
196-
PUBLIC ${JNI_INCLUDE_DIRS} ${OPENCV_INCLUDE_PATH} mrcal libdogleg
191+
PUBLIC ${JNI_INCLUDE_DIRS} ${OPENCV_INCLUDE_PATH} mrcal libdogleg ${WPIMATH_INCLUDE_PATH}
197192
)
198193
add_dependencies(mrcal_jni generate_minimath)
199194

@@ -206,7 +201,6 @@ target_link_libraries(
206201
${OPENBLAS_TARGET}
207202
lapack
208203
fmt
209-
Eigen3::Eigen # TODO link against wpilib or hide these symbols
210204
)
211205

212206
# vnlog for the test script
@@ -216,11 +210,9 @@ target_include_directories(vnlog SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/vnlog)
216210

217211
# Test script for checking our linker
218212

219-
find_package(Eigen3 REQUIRED NO_MODULE)
220-
221213
add_executable(mrcal_jni_test src/mrcal_test.cpp)
222214

223-
target_link_libraries(mrcal_jni_test PUBLIC mrcal_jni Eigen3::Eigen)
215+
target_link_libraries(mrcal_jni_test PUBLIC mrcal_jni)
224216

225217
target_include_directories(
226218
mrcal_jni_test

src/mrcal-uncertainty.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <memory>
2121
#include <utility>
2222
#include <vector>
23+
#include <Eigen/SparseLU>
2324

2425
using namespace cv;
2526

src/mrcal-uncertainty.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
#pragma once
1919

2020
#include "spy.hpp"
21-
#include <Eigen/CholmodSupport>
2221
#include <Eigen/Dense>
23-
#include <Eigen/Sparse>
2422
#include <cholmod.h>
2523
#include <fmt/core.h>
2624
#include <fmt/ranges.h>
@@ -29,7 +27,6 @@
2927
#include <poseutils.h>
3028
#include <ranges>
3129
#include <span>
32-
#include <unsupported/Eigen/SparseExtra>
3330
#include <vector>
3431

3532
std::vector<mrcal_point3_t> compute_uncertainty(

src/spy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <string>
2727
#include <string_view>
2828

29-
#include <Eigen/Sparse>
29+
#include <Eigen/SparseCore>
3030

3131
namespace slp {
3232

0 commit comments

Comments
 (0)