diff --git a/.gersemirc b/.gersemirc index d102ccb5a4..9d9238b7cc 100644 --- a/.gersemirc +++ b/.gersemirc @@ -1,6 +1,4 @@ -color: false definitions: [cmake/modules] line_length: 100 list_expansion: favour-inlining -quiet: false unsafe: false diff --git a/.github/workflows/lint-format.yml b/.github/workflows/lint-format.yml index d7b295d1b5..ef8cf10c56 100644 --- a/.github/workflows/lint-format.yml +++ b/.github/workflows/lint-format.yml @@ -36,7 +36,7 @@ jobs: - name: Install wpiformat run: | python -m venv ${{ runner.temp }}/wpiformat - ${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2025.33 + ${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2025.34 - name: Run run: ${{ runner.temp }}/wpiformat/bin/wpiformat - name: Check output @@ -78,7 +78,7 @@ jobs: - name: Install wpiformat run: | python -m venv ${{ runner.temp }}/wpiformat - ${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2025.33 + ${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2025.34 - name: Create compile_commands.json run: | ./gradlew generateCompileCommands -Ptoolchain-optional-roboRio diff --git a/.github/workflows/upstream-utils.yml b/.github/workflows/upstream-utils.yml index 2c99c08965..dbad7c1e7e 100644 --- a/.github/workflows/upstream-utils.yml +++ b/.github/workflows/upstream-utils.yml @@ -141,4 +141,11 @@ jobs: - name: Add untracked files to index so they count as changes run: git add -A - name: Check output - run: git --no-pager diff --exit-code HEAD ':!*.bazel' + run: | + set +e + git --no-pager diff --exit-code HEAD ':!*.bazel' + git_exit_code=$? + if test "$git_exit_code" -ne "0"; then + echo "::error ::upstream_utils check failed. This is usually caused by a bad script or the copied files differing from what the script outputs. You can learn more about using upstream_utils to modify thirdparty libraries at https://github.com/wpilibsuite/allwpilib/blob/main/upstream_utils/README.md" + exit $git_exit_code + fi diff --git a/cscore/src/main/native/cpp/MjpegServerImpl.cpp b/cscore/src/main/native/cpp/MjpegServerImpl.cpp index 5ce5c39a52..e303ca54da 100644 --- a/cscore/src/main/native/cpp/MjpegServerImpl.cpp +++ b/cscore/src/main/native/cpp/MjpegServerImpl.cpp @@ -773,8 +773,7 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) { lastFrameTime = thisFrameTime; double timestamp = lastFrameTime / 1000000.0; header.clear(); - oss << "\r\n--" BOUNDARY "\r\n" - << "Content-Type: image/jpeg\r\n"; + oss << "\r\n--" BOUNDARY "\r\n" << "Content-Type: image/jpeg\r\n"; wpi::print(oss, "Content-Length: {}\r\n", size); wpi::print(oss, "X-Timestamp: {}\r\n", timestamp); oss << "\r\n"; diff --git a/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h b/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h index dc753175b4..fc8191bf08 100644 --- a/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h +++ b/hal/src/main/native/include/hal/simulation/SimCallbackRegistry.h @@ -102,7 +102,7 @@ class SimCallbackRegistry : public impl::SimCallbackRegistryBase { */ #define HAL_SIMCALLBACKREGISTRY_DEFINE_NAME(NAME) \ static LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr const char* \ - Get##NAME##Name() { \ + Get##NAME##Name() { \ return #NAME; \ } diff --git a/hal/src/main/native/include/hal/simulation/SimDataValue.h b/hal/src/main/native/include/hal/simulation/SimDataValue.h index 8c909fae28..69270075fd 100644 --- a/hal/src/main/native/include/hal/simulation/SimDataValue.h +++ b/hal/src/main/native/include/hal/simulation/SimDataValue.h @@ -127,7 +127,7 @@ class SimDataValue final : public impl::SimDataValueBase { */ #define HAL_SIMDATAVALUE_DEFINE_NAME(NAME) \ static LLVM_ATTRIBUTE_ALWAYS_INLINE constexpr const char* \ - Get##NAME##Name() { \ + Get##NAME##Name() { \ return #NAME; \ } diff --git a/hal/src/main/native/systemcore/CTREPCM.cpp b/hal/src/main/native/systemcore/CTREPCM.cpp index 41259d7ae4..91fd4c6171 100644 --- a/hal/src/main/native/systemcore/CTREPCM.cpp +++ b/hal/src/main/native/systemcore/CTREPCM.cpp @@ -409,8 +409,9 @@ void HAL_SetCTREPCMOneShotDuration(HAL_CTREPCMHandle handle, int32_t index, message.dataSize = 8; std::scoped_lock lock{pcm->lock}; - pcm->oneShot.sol10MsPerUnit[index] = (std::min)( - static_cast(durMs) / 10, static_cast(0xFF)); + pcm->oneShot.sol10MsPerUnit[index] = + (std::min)(static_cast(durMs) / 10, + static_cast(0xFF)); std::memcpy(message.data, pcm->oneShot.sol10MsPerUnit, 8); HAL_WriteCANPacketRepeating(pcm->canHandle, Control3, &message, SendPeriod, status); diff --git a/shared/ceres.gradle b/shared/ceres.gradle index beaaa113f3..c9a9276369 100644 --- a/shared/ceres.gradle +++ b/shared/ceres.gradle @@ -1,12 +1,14 @@ nativeUtils { nativeDependencyContainer { ceres(getNativeDependencyTypeClass('WPIStaticMavenDependency')) { - groupId = "edu.wpi.first.thirdparty.frc2024.ceres" + groupId = "edu.wpi.first.thirdparty.frc2026.ceres" artifactId = "ceres-cpp" headerClassifier = "headers" + sourceClassifier = "sources" ext = "zip" - version = '2.2-3' + version = '2.2-1' targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms) + targetPlatforms.addAll("linuxarm32", "linuxarm64") } } } diff --git a/simulation/halsim_gui/src/main/native/cpp/main.cpp b/simulation/halsim_gui/src/main/native/cpp/main.cpp index 2a0c92d9f3..ebb4e49513 100644 --- a/simulation/halsim_gui/src/main/native/cpp/main.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/main.cpp @@ -61,6 +61,12 @@ __declspec(dllexport) reinterpret_cast((AddGuiEarlyExecuteFn)&AddGuiEarlyExecute)); HAL_RegisterExtension(HALSIMGUI_EXT_GUIEXIT, reinterpret_cast((GuiExitFn)&GuiExit)); + HAL_RegisterExtension( + HALSIMGUI_EXT_GETGUICONTEXT, + reinterpret_cast((GetGuiContextFn)&gui::GetCurrentContext)); + HAL_RegisterExtension( + HALSIMGUI_EXT_GETGLASSCONTEXT, + reinterpret_cast((GetGlassContextFn)&glass::GetCurrentContext)); HALSimGui::GlobalInit(); DriverStationGui::GlobalInit(); @@ -150,6 +156,9 @@ __declspec(dllexport) ImGuiConfigFlags_DockingEnable)) { return 0; } + HAL_RegisterExtension( + HALSIMGUI_EXT_GETIMGUICONTEXT, + reinterpret_cast((GetImguiContextFn)&ImGui::GetCurrentContext)); HAL_RegisterExtensionListener( nullptr, [](void*, const char* name, void* data) { if (std::string_view{name} == "ds_socket") { diff --git a/simulation/halsim_gui/src/main/native/include/HALSimGuiExt.h b/simulation/halsim_gui/src/main/native/include/HALSimGuiExt.h index e60976e346..377518f6db 100644 --- a/simulation/halsim_gui/src/main/native/include/HALSimGuiExt.h +++ b/simulation/halsim_gui/src/main/native/include/HALSimGuiExt.h @@ -6,6 +6,16 @@ #include +struct ImGuiContext; + +namespace glass { +class Context; +} // namespace glass + +namespace wpi::gui { +struct Context; +} // namespace wpi::gui + namespace halsimgui { // These functions can be used to hook into the GUI, and can be accessed @@ -23,4 +33,13 @@ using AddGuiEarlyExecuteFn = void (*)(std::function execute); #define HALSIMGUI_EXT_GUIEXIT "halsimgui::GuiExit" using GuiExitFn = void (*)(); +#define HALSIMGUI_EXT_GETIMGUICONTEXT "halsimgui::GetImguiContext" +using GetImguiContextFn = ImGuiContext* (*)(); + +#define HALSIMGUI_EXT_GETGUICONTEXT "halsimgui::GetGuiContext" +using GetGuiContextFn = wpi::gui::Context* (*)(); + +#define HALSIMGUI_EXT_GETGLASSCONTEXT "halsimgui::GetGlassContext" +using GetGlassContextFn = glass::Context* (*)(); + } // namespace halsimgui diff --git a/upstream_utils/eigen.py b/upstream_utils/eigen.py index 93f68f79d5..fdd9f580f9 100755 --- a/upstream_utils/eigen.py +++ b/upstream_utils/eigen.py @@ -47,10 +47,18 @@ def eigen_inclusions(dp: Path, f: str): or "SSE" in dp.parts ) + if ( + "StlSupport" in dp.parts + and not f.endswith("StdList.h") + and not f.endswith("StdDeque.h") + ): + return True + # Include the following modules modules = [ "Cholesky", "Core", + "Dense", "Eigenvalues", "Geometry", "Householder", @@ -64,6 +72,7 @@ def eigen_inclusions(dp: Path, f: str): "SparseCore", "SparseLU", "SparseQR", + "StdVector", "misc", "plugins", ] diff --git a/upstream_utils/mrcal_java.py b/upstream_utils/mrcal_java.py index 11f3e120e9..5545411834 100755 --- a/upstream_utils/mrcal_java.py +++ b/upstream_utils/mrcal_java.py @@ -32,6 +32,9 @@ def copy_upstream_src(wpilib_root: Path): with open(f) as file: content = file.read() content = content.replace("#include ", "") + 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;", diff --git a/wpical/.styleguide b/wpical/.styleguide index afaf7a1075..19766ff2c6 100644 --- a/wpical/.styleguide +++ b/wpical/.styleguide @@ -9,6 +9,7 @@ cppSrcFileInclude { } generatedFileExclude { + src/main/native/assets/ src/main/native/resources/ src/main/native/thirdparty/ src/main/native/win/wpical.ico diff --git a/wpical/CMakeLists.txt b/wpical/CMakeLists.txt index f07d52755a..185bcf036c 100644 --- a/wpical/CMakeLists.txt +++ b/wpical/CMakeLists.txt @@ -83,12 +83,17 @@ target_compile_options(wpical PRIVATE ${compile_flags}) find_package(OpenCV REQUIRED) find_package(Ceres CONFIG REQUIRED) +find_package(CHOLMOD CONFIG REQUIRED) +find_package(SuiteSparse_config CONFIG REQUIRED) + target_link_libraries( wpical apriltag ${OpenCV_LIBS} wpigui wpiutil + SuiteSparse::CHOLMOD_static + SuiteSparse::SuiteSparseConfig_static Ceres::ceres ) @@ -124,6 +129,8 @@ if(WITH_TESTS) ${OpenCV_LIBS} wpigui wpiutil + SuiteSparse::CHOLMOD_static + SuiteSparse::SuiteSparseConfig_static Ceres::ceres ) endif() diff --git a/wpical/WPICalThirdPartyNotices.txt b/wpical/WPICalThirdPartyNotices.txt new file mode 100644 index 0000000000..9c22d6d58c --- /dev/null +++ b/wpical/WPICalThirdPartyNotices.txt @@ -0,0 +1,732 @@ +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with WPICal +============================================================================== +The WPICal software contains code written by third parties. The copyrights, +license, and restrictions which apply to each piece of software is included +later in this file and/or inside of the individual applicable source files. + +The disclaimer of warranty in the WPILib license above applies to all code in +WPILib, including WPICal and nothing in any of the other licenses gives +permission to use the names of FIRST nor the names of the WPILib contributors +to endorse or promote products derived from this software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Locations +------- --------- +AMD https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/DrTimothyAldenDavis/SuiteSparse +CAMD https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/DrTimothyAldenDavis/SuiteSparse +CCOLAMD https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/DrTimothyAldenDavis/SuiteSparse +Ceres https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/ceres-solver/ceres-solver +CHOLMOD https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/DrTimothyAldenDavis/SuiteSparse +OpenBLAS (non-Mac only) https://github.com/wpilibsuite/thirdparty-ceres, https://github.com/OpenMathLib/OpenBLAS + +AMD, Copyright (c), 1996-2022, Timothy A. Davis, +Patrick R. Amestoy, and Iain S. Duff. All Rights Reserved. + +Availability: + + http://www.suitesparse.com + +------------------------------------------------------------------------------- +AMD License: BSD 3-clause: +------------------------------------------------------------------------------- + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the organizations to which the authors are + affiliated, nor the names of its contributors may be used to endorse + or promote products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +CAMD, Copyright (c) by Timothy A. Davis, +Yanqing Chen, +Patrick R. Amestoy, and Iain S. Duff. All Rights Reserved. +CAMD is available under alternate licenses, contact T. Davis for details. + +Availability: + + http://www.suitesparse.com + +------------------------------------------------------------------------------- +CAMD License: BSD 3-clause: +------------------------------------------------------------------------------- + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the organizations to which the authors are + affiliated, nor the names of its contributors may be used to endorse + or promote products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +CCOLAMD: constrained column approximate minimum degree ordering +Copyright (C) 2005-2016, Univ. of Florida. Authors: Timothy A. Davis, +Sivasankaran Rajamanickam, and Stefan Larimore. Closely based on COLAMD by +Davis, Stefan Larimore, in collaboration with Esmond Ng, and John Gilbert. +http://www.suitesparse.com + +-------------------------------------------------------------------------------- + +CCOLAMD license: BSD 3-clause: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the organizations to which the authors are + affiliated, nor the names of its contributors may be used to endorse + or promote products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +Ceres Solver - A fast non-linear least squares minimizer +Copyright 2023 Google Inc. All rights reserved. +http://ceres-solver.org/ + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +* Neither the name of Google Inc. nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------------------------------------------------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +------------------------------------------------------------------------------------------------------------------------------- + +Some of the code in the examples directory derives from libmv, which is +distributed under the MIT license as described below + + +Copyright (c) 2007-2011 libmv authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + +-------------------------------------------------------------------------------- +==> Check/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Check Module. Copyright (C) 2005-2022, Timothy A. Davis CHOLMOD is + also available under other licenses; contact authors for details. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Check module only. + All CHOLMOD modules are licensed separately. + + ---------------------------------------------------------------------------- + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +-------------------------------------------------------------------------------- +==> Cholesky/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Cholesky module, Copyright (C) 2005-2022, Timothy A. Davis. + CHOLMOD is also available under other licenses; contact authors for + details. http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Cholesky module only. + All CHOLMOD modules are licensed separately. + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +-------------------------------------------------------------------------------- +==> Utility/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Utility Module. Copyright (C) 2023, Timothy A. Davis, All Rights + Reserved. CHOLMOD is also available under other licenses; contact authors + for details. http://www.suitesparse.com + + ---------------------------------------------------------------------------- + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +-------------------------------------------------------------------------------- +==> Demo/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Demo Module. Copyright (C) 2005-2022, Timothy A. Davis. CHOLMOD + is also available under other licenses; contact authors for details. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Demo module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +-------------------------------------------------------------------------------- +==> MATLAB/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/MATLAB Module. Copyright (C) 2005-2022, Timothy A. Davis. CHOLMOD + is also available under other licenses; contact authors for details. + MATLAB(tm) is a Registered Trademark of The MathWorks, Inc. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/MATLAB module only. + All CHOLMOD modules are licensed separately. + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +-------------------------------------------------------------------------------- +==> MatrixOps/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/MatrixOps Module. Copyright (C) 2005-2022, Timothy A. Davis. + CHOLMOD is also available under other licenses; contact authors for + details. http://www.suitesparse.com + + Note that this license is for the CHOLMOD/MatrixOps module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +-------------------------------------------------------------------------------- +==> Modify/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Modify Module. Copyright (C) 2005-2022, Timothy A. Davis and + William W. Hager. CHOLMOD is also available under other licenses; contact + authors for details. http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Modify module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +-------------------------------------------------------------------------------- +==> Partition/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Partition Module. + Copyright (C) 2005-2022, Univ. of Florida. Author: Timothy A. Davis + CHOLMOD is also available under other licenses; contact authors for details. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Partition module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +-------------------------------------------------------------------------------- +==> Supernodal/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Supernodal Module. + Copyright (C) 2005-2022, Timothy A. Davis + CHOLMOD is also available under other licenses; contact authors for details. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Supernodal module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +-------------------------------------------------------------------------------- +==> Tcov/License.txt <== +-------------------------------------------------------------------------------- + + CHOLMOD/Tcov Module. Copyright (C) 2005-2022, Timothy A. Davis + CHOLMOD is also available under other licenses; contact authors for details. + http://www.suitesparse.com + + Note that this license is for the CHOLMOD/Tcov module only. + All CHOLMOD modules are licensed separately. + + + ---------------------------------------------------------------------------- + + + This Module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This Module is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this Module; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +COLAMD, Copyright 1998-2022, Timothy A. Davis. http://www.suitesparse.com +http://www.suitesparse.com + +-------------------------------------------------------------------------------- + +COLAMD License: BSD 3-clause + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the organizations to which the authors are + affiliated, nor the names of its contributors may be used to endorse + or promote products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +Copyright (c) 2011-2014, The OpenBLAS Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/wpical/build.gradle b/wpical/build.gradle index ffa8f8b606..daf85a6595 100644 --- a/wpical/build.gradle +++ b/wpical/build.gradle @@ -1,6 +1,6 @@ import org.gradle.internal.os.OperatingSystem -if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64')) { +if (project.hasProperty('onlylinuxsystemcore')) { return; } @@ -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) { @@ -152,16 +152,18 @@ model { } } binaries.all { - if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore || it.targetPlatform.name.startsWith("linuxarm")) { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) { 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)') @@ -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' } @@ -203,16 +205,18 @@ model { } } binaries.all { - if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore || it.targetPlatform.name.startsWith("linuxarm")) { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) { 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) { @@ -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' } diff --git a/wpical/publish.gradle b/wpical/publish.gradle index d00f47aafb..5af5956239 100644 --- a/wpical/publish.gradle +++ b/wpical/publish.gradle @@ -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) diff --git a/wpical/src/main/native/resources/2024-crescendo.json b/wpical/src/main/native/assets/2024-crescendo.json similarity index 100% rename from wpical/src/main/native/resources/2024-crescendo.json rename to wpical/src/main/native/assets/2024-crescendo.json diff --git a/wpical/src/main/native/resources/altfieldvideo/long.avi b/wpical/src/main/native/assets/altfieldvideo/long.avi similarity index 100% rename from wpical/src/main/native/resources/altfieldvideo/long.avi rename to wpical/src/main/native/assets/altfieldvideo/long.avi diff --git a/wpical/src/main/native/resources/altfieldvideo/short.avi b/wpical/src/main/native/assets/altfieldvideo/short.avi similarity index 100% rename from wpical/src/main/native/resources/altfieldvideo/short.avi rename to wpical/src/main/native/assets/altfieldvideo/short.avi diff --git a/wpical/src/main/native/resources/fieldvideo/long.mp4 b/wpical/src/main/native/assets/fieldvideo/long.mp4 similarity index 100% rename from wpical/src/main/native/resources/fieldvideo/long.mp4 rename to wpical/src/main/native/assets/fieldvideo/long.mp4 diff --git a/wpical/src/main/native/resources/fieldvideo/short.mp4 b/wpical/src/main/native/assets/fieldvideo/short.mp4 similarity index 100% rename from wpical/src/main/native/resources/fieldvideo/short.mp4 rename to wpical/src/main/native/assets/fieldvideo/short.mp4 diff --git a/wpical/src/main/native/resources/lifecam_1280p_10x10.vnl b/wpical/src/main/native/assets/lifecam_1280p_10x10.vnl similarity index 100% rename from wpical/src/main/native/resources/lifecam_1280p_10x10.vnl rename to wpical/src/main/native/assets/lifecam_1280p_10x10.vnl diff --git a/wpical/src/main/native/resources/testcalibration.avi b/wpical/src/main/native/assets/testcalibration.avi similarity index 100% rename from wpical/src/main/native/resources/testcalibration.avi rename to wpical/src/main/native/assets/testcalibration.avi diff --git a/wpical/src/main/native/resources/testcalibration.mp4 b/wpical/src/main/native/assets/testcalibration.mp4 similarity index 100% rename from wpical/src/main/native/resources/testcalibration.mp4 rename to wpical/src/main/native/assets/testcalibration.mp4 diff --git a/wpical/src/main/native/cpp/tagpose.cpp b/wpical/src/main/native/cpp/tagpose.cpp index 38977f0961..ec871d5651 100644 --- a/wpical/src/main/native/cpp/tagpose.cpp +++ b/wpical/src/main/native/cpp/tagpose.cpp @@ -3,7 +3,9 @@ // the WPILib BSD license file in the root directory of this project. #include +#include +WPI_IGNORE_DEPRECATED namespace tag { Pose::Pose(int tag_id, double xpos, double ypos, double zpos, double w, double x, double y, double z, double field_length_meters, diff --git a/wpical/src/main/native/thirdparty/mrcal_java/include/mrcal_wrapper.h b/wpical/src/main/native/thirdparty/mrcal_java/include/mrcal_wrapper.h index 0a36d4702d..dc7e02eb2d 100644 --- a/wpical/src/main/native/thirdparty/mrcal_java/include/mrcal_wrapper.h +++ b/wpical/src/main/native/thirdparty/mrcal_java/include/mrcal_wrapper.h @@ -24,7 +24,7 @@ extern "C" { // Seems like these people don't properly extern-c their headers either extern "C" { #include -#include +#include } // extern "C" #include diff --git a/wpical/src/test/native/cpp/test_calibrate.cpp b/wpical/src/test/native/cpp/test_calibrate.cpp index 0e48bcf018..a7837e7e17 100644 --- a/wpical/src/test/native/cpp/test_calibrate.cpp +++ b/wpical/src/test/native/cpp/test_calibrate.cpp @@ -12,8 +12,7 @@ const std::string projectRootPath = PROJECT_ROOT_PATH; const std::string calSavePath = - projectRootPath.substr(0, - projectRootPath.find("/src/main/native/resources")) + + projectRootPath.substr(0, projectRootPath.find("/src/main/native/assets")) + "/build"; cameracalibration::CameraModel cameraModel = { .intrinsic_matrix = Eigen::Matrix::Identity(), diff --git a/wpigui/src/main/native/cpp/wpigui.cpp b/wpigui/src/main/native/cpp/wpigui.cpp index 0fe3f24104..71e6ab5700 100644 --- a/wpigui/src/main/native/cpp/wpigui.cpp +++ b/wpigui/src/main/native/cpp/wpigui.cpp @@ -169,6 +169,14 @@ void gui::DestroyContext() { gContext = nullptr; } +Context* gui::GetCurrentContext() { + return gContext; +} + +void gui::SetCurrentContext(Context* context) { + gContext = context; +} + static void UpdateFontScale() { // Scale based on OS window content scaling float windowScale = 1.0; diff --git a/wpigui/src/main/native/include/wpigui.h b/wpigui/src/main/native/include/wpigui.h index 6c3315fc55..761e02b2f8 100644 --- a/wpigui/src/main/native/include/wpigui.h +++ b/wpigui/src/main/native/include/wpigui.h @@ -14,6 +14,8 @@ extern "C" struct GLFWwindow; namespace wpi::gui { +struct Context; + /** * Creates GUI context. Must be called prior to calling any other functions. */ @@ -24,6 +26,20 @@ void CreateContext(); */ void DestroyContext(); +/** + * Gets GUI context. + * + * @return context + */ +Context* GetCurrentContext(); + +/** + * Sets GUI context. + * + * @param context context + */ +void SetCurrentContext(Context* context); + /** * Initializes the GUI. * diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/ExtendedKalmanFilter.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/ExtendedKalmanFilter.java index 78bc3d1335..b142ae4064 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/ExtendedKalmanFilter.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/ExtendedKalmanFilter.java @@ -372,7 +372,11 @@ public class ExtendedKalmanFilter K = S.transpose().solve(C.times(m_P.transpose())).transpose(); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + final Matrix K = S.solve(C.times(m_P)).transpose(); // x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + K(y − h(x̂ₖ₊₁⁻, uₖ₊₁)) m_xHat = addFuncX.apply(m_xHat, K.times(residualFuncY.apply(y, h.apply(m_xHat, u)))); diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilter.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilter.java index 8302cd554b..7f03f86ac9 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilter.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/KalmanFilter.java @@ -230,7 +230,11 @@ public class KalmanFilter K = S.transpose().solve(C.times(m_P.transpose())).transpose(); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + final Matrix K = S.solve(C.times(m_P)).transpose(); // x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + K(y − (Cx̂ₖ₊₁⁻ + Duₖ₊₁)) m_xHat = m_xHat.plus(K.times(y.minus(C.times(m_xHat).plus(D.times(u))))); diff --git a/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java b/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java index 1b85e4385e..a2db490316 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java +++ b/wpimath/src/main/java/edu/wpi/first/math/estimator/SteadyStateKalmanFilter.java @@ -100,9 +100,11 @@ public class SteadyStateKalmanFilter( - S.transpose().getStorage().solve(C.times(P.transpose()).getStorage()).transpose()); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + m_K = new Matrix<>(S.getStorage().solve(C.times(P).getStorage()).transpose()); reset(); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java index 1612a5e5fa..10c7c123bd 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java @@ -109,6 +109,22 @@ public class Translation2d return Math.hypot(other.m_x - m_x, other.m_y - m_y); } + /** + * Calculates the square of the distance between two translations in 2D space. This is equivalent + * to squaring the result of {@link #getDistance(Translation2d)}, but avoids computing a square + * root. + * + *

The square of the distance between translations is defined as (x₂−x₁)²+(y₂−y₁)². + * + * @param other The translation to compute the squared distance to. + * @return The square of the distance between the two translations, in square meters. + */ + public double getSquaredDistance(Translation2d other) { + double dx = other.m_x - m_x; + double dy = other.m_y - m_y; + return dx * dx + dy * dy; + } + /** * Returns the X component of the translation. * @@ -165,6 +181,16 @@ public class Translation2d return Math.hypot(m_x, m_y); } + /** + * Returns the squared norm, or squared distance from the origin to the translation. This is + * equivalent to squaring the result of {@link #getNorm()}, but avoids computing a square root. + * + * @return The squared norm of the translation, in square meters. + */ + public double getSquaredNorm() { + return m_x * m_x + m_y * m_y; + } + /** * Returns the angle this translation forms with the positive X axis. * @@ -214,6 +240,30 @@ public class Translation2d (m_x - other.getX()) * rot.getSin() + (m_y - other.getY()) * rot.getCos() + other.getY()); } + /** + * Computes the dot product between this translation and another translation in 2D space. + * + *

The dot product between two translations is defined as x₁x₂+y₁y₂. + * + * @param other The translation to compute the dot product with. + * @return The dot product between the two translations, in square meters. + */ + public double dot(Translation2d other) { + return m_x * other.m_x + m_y * other.m_y; + } + + /** + * Computes the cross product between this translation and another translation in 2D space. + * + *

The 2D cross product between two translations is defined as x₁y₂-x₂y₁. + * + * @param other The translation to compute the cross product with. + * @return The cross product between the two translations, in square meters. + */ + public double cross(Translation2d other) { + return m_x * other.m_y - m_y * other.m_x; + } + /** * Returns the sum of two translations in 2D space. * diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java index a929661ee9..ff7eb01de6 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java @@ -125,8 +125,26 @@ public class Translation3d * @return The distance between the two translations. */ public double getDistance(Translation3d other) { - return Math.sqrt( - Math.pow(other.m_x - m_x, 2) + Math.pow(other.m_y - m_y, 2) + Math.pow(other.m_z - m_z, 2)); + double dx = other.m_x - m_x; + double dy = other.m_y - m_y; + double dz = other.m_z - m_z; + return Math.sqrt(dx * dx + dy * dy + dz * dz); + } + + /** + * Calculates the squared distance between two translations in 3D space. This is equivalent to + * squaring the result of {@link #getDistance(Translation3d)}, but avoids computing a square root. + * + *

The squared distance between translations is defined as (x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)². + * + * @param other The translation to compute the squared distance to. + * @return The squared distance between the two translations. + */ + public double getSquaredDistance(Translation3d other) { + double dx = other.m_x - m_x; + double dy = other.m_y - m_y; + double dz = other.m_z - m_z; + return dx * dx + dy * dy + dz * dz; } /** @@ -204,6 +222,16 @@ public class Translation3d return Math.sqrt(m_x * m_x + m_y * m_y + m_z * m_z); } + /** + * Returns the squared norm, or squared distance from the origin to the translation. This is + * equivalent to squaring the result of {@link #getNorm()}, but avoids computing a square root. + * + * @return The squared norm of the translation. + */ + public double getSquaredNorm() { + return m_x * m_x + m_y * m_y + m_z * m_z; + } + /** * Applies a rotation to the translation in 3D space. * @@ -230,6 +258,35 @@ public class Translation3d return this.minus(other).rotateBy(rot).plus(other); } + /** + * Computes the dot product between this translation and another translation in 3D space. + * + *

The dot product between two translations is defined as x₁x₂+y₁y₂+z₁z₂. + * + * @param other The translation to compute the dot product with. + * @return The dot product between the two translations, in square meters. + */ + public double dot(Translation3d other) { + return m_x * other.m_x + m_y * other.m_y + m_z * other.m_z; + } + + /** + * Computes the cross product between this translation and another translation in 3D space. The + * resulting translation will be perpendicular to both translations. + * + *

The 3D cross product between two translations is defined as <y₁z₂-y₂z₁, z₁x₂-z₂x₁, + * x₁y₂-x₂y₁>. + * + * @param other The translation to compute the cross product with. + * @return The cross product between the two translations. + */ + public Vector cross(Translation3d other) { + return VecBuilder.fill( + m_y * other.m_z - other.m_y * m_z, + m_z * other.m_x - other.m_z * m_x, + m_x * other.m_y - other.m_x * m_y); + } + /** * Returns a Translation2d representing this Translation3d projected into the X-Y plane. * diff --git a/wpimath/src/main/native/include/frc/DARE.h b/wpimath/src/main/native/include/frc/DARE.h index fba06ccb0a..feca99a1fd 100644 --- a/wpimath/src/main/native/include/frc/DARE.h +++ b/wpimath/src/main/native/include/frc/DARE.h @@ -128,7 +128,11 @@ Eigen::Matrix DARE( // // V₂ᵀ = W.solve(Gₖᵀ) // V₂ = W.solve(Gₖᵀ)ᵀ - StateMatrix V_2 = W_solver.solve(G_k.transpose()).transpose(); + // + // Since W, Gₖ, and Hₖ are symmetric, drop the transposes on Gₖ and V₂. + // + // V₂ = W.solve(Gₖ) + StateMatrix V_2 = W_solver.solve(G_k); // Gₖ₊₁ = Gₖ + AₖV₂Aₖᵀ // Hₖ₊₁ = Hₖ + V₁ᵀHₖAₖ diff --git a/wpimath/src/main/native/include/frc/estimator/ExtendedKalmanFilter.h b/wpimath/src/main/native/include/frc/estimator/ExtendedKalmanFilter.h index ccf8f935c4..22eddbc281 100644 --- a/wpimath/src/main/native/include/frc/estimator/ExtendedKalmanFilter.h +++ b/wpimath/src/main/native/include/frc/estimator/ExtendedKalmanFilter.h @@ -397,8 +397,11 @@ class ExtendedKalmanFilter { // // Kᵀ = Sᵀ.solve(CPᵀ) // K = (Sᵀ.solve(CPᵀ))ᵀ - Matrixd K = - S.transpose().ldlt().solve(C * m_P.transpose()).transpose(); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + Matrixd K = S.ldlt().solve(C * m_P).transpose(); // x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + Kₖ₊₁(y − h(x̂ₖ₊₁⁻, uₖ₊₁)) m_xHat = addFuncX(m_xHat, K * residualFuncY(y, h(m_xHat, u))); diff --git a/wpimath/src/main/native/include/frc/estimator/KalmanFilter.h b/wpimath/src/main/native/include/frc/estimator/KalmanFilter.h index 5f52c810ac..aa169368bb 100644 --- a/wpimath/src/main/native/include/frc/estimator/KalmanFilter.h +++ b/wpimath/src/main/native/include/frc/estimator/KalmanFilter.h @@ -235,8 +235,11 @@ class KalmanFilter { // // Kᵀ = Sᵀ.solve(CPᵀ) // K = (Sᵀ.solve(CPᵀ))ᵀ - Matrixd K = - S.transpose().ldlt().solve(C * m_P.transpose()).transpose(); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + Matrixd K = S.ldlt().solve(C * m_P).transpose(); // x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + K(y − (Cx̂ₖ₊₁⁻ + Duₖ₊₁)) m_xHat += K * (y - (C * m_xHat + D * u)); diff --git a/wpimath/src/main/native/include/frc/estimator/SteadyStateKalmanFilter.h b/wpimath/src/main/native/include/frc/estimator/SteadyStateKalmanFilter.h index a705de92bf..734c70c7e0 100644 --- a/wpimath/src/main/native/include/frc/estimator/SteadyStateKalmanFilter.h +++ b/wpimath/src/main/native/include/frc/estimator/SteadyStateKalmanFilter.h @@ -114,7 +114,11 @@ class SteadyStateKalmanFilter { // // Kᵀ = Sᵀ.solve(CPᵀ) // K = (Sᵀ.solve(CPᵀ))ᵀ - m_K = S.transpose().ldlt().solve(C * P.value().transpose()).transpose(); + // + // Drop the transposes on symmetric matrices S and P. + // + // K = (S.solve(CP))ᵀ + m_K = S.ldlt().solve(C * P.value()).transpose(); } else if (P.error() == DAREError::QNotSymmetric || P.error() == DAREError::QNotPositiveSemidefinite) { std::string msg = diff --git a/wpimath/src/main/native/include/frc/geometry/Translation2d.h b/wpimath/src/main/native/include/frc/geometry/Translation2d.h index a859743988..f6775ff2eb 100644 --- a/wpimath/src/main/native/include/frc/geometry/Translation2d.h +++ b/wpimath/src/main/native/include/frc/geometry/Translation2d.h @@ -13,6 +13,7 @@ #include #include "frc/geometry/Rotation2d.h" +#include "units/area.h" #include "units/length.h" #include "units/math.h" @@ -75,6 +76,23 @@ class WPILIB_DLLEXPORT Translation2d { return units::math::hypot(other.m_x - m_x, other.m_y - m_y); } + /** + * Calculates the square of the distance between two translations in 2D space. + * This is equivalent to squaring the result of Distance(Translation2d), but + * avoids computing a square root. + * + * The square of the distance between translations is defined as + * (x₂−x₁)²+(y₂−y₁)². + * + * @param other The translation to compute the squared distance to. + * @return The square of the distance between the two translations. + */ + constexpr units::square_meter_t SquaredDistance( + const Translation2d& other) const { + return units::math::pow<2>(other.m_x - m_x) + + units::math::pow<2>(other.m_y - m_y); + } + /** * Returns the X component of the translation. * @@ -105,6 +123,17 @@ class WPILIB_DLLEXPORT Translation2d { */ constexpr units::meter_t Norm() const { return units::math::hypot(m_x, m_y); } + /** + * Returns the squared norm, or squared distance from the origin to the + * translation. This is equivalent to squaring the result of Norm(), but + * avoids computing a square root. + * + * @return The squared norm of the translation. + */ + constexpr units::square_meter_t SquaredNorm() const { + return units::math::pow<2>(m_x) + units::math::pow<2>(m_y); + } + /** * Returns the angle this translation forms with the positive X axis. * @@ -157,6 +186,32 @@ class WPILIB_DLLEXPORT Translation2d { other.Y()}; } + /** + * Computes the dot product between this translation and another translation + * in 2D space. + * + * The dot product between two translations is defined as x₁x₂+y₁y₂. + * + * @param other The translation to compute the dot product with. + * @return The dot product between the two translations. + */ + constexpr units::square_meter_t Dot(const Translation2d& other) const { + return m_x * other.X() + m_y * other.Y(); + } + + /** + * Computes the cross product between this translation and another translation + * in 2D space. + * + * The 2D cross product between two translations is defined as x₁y₂-x₂y₁. + * + * @param other The translation to compute the cross product with. + * @return The cross product between the two translations. + */ + constexpr units::square_meter_t Cross(const Translation2d& other) const { + return m_x * other.Y() - m_y * other.X(); + } + /** * Returns the sum of two translations in 2D space. * diff --git a/wpimath/src/main/native/include/frc/geometry/Translation3d.h b/wpimath/src/main/native/include/frc/geometry/Translation3d.h index b9876c05a3..166f871c59 100644 --- a/wpimath/src/main/native/include/frc/geometry/Translation3d.h +++ b/wpimath/src/main/native/include/frc/geometry/Translation3d.h @@ -14,6 +14,7 @@ #include "frc/geometry/Rotation3d.h" #include "frc/geometry/Translation2d.h" +#include "units/area.h" #include "units/length.h" #include "units/math.h" @@ -96,6 +97,24 @@ class WPILIB_DLLEXPORT Translation3d { units::math::pow<2>(other.m_z - m_z)); } + /** + * Calculates the squared distance between two translations in 3D space. This + * is equivalent to squaring the result of Distance(Translation3d), but avoids + * computing a square root. + * + * The squared distance between translations is defined as + * (x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)². + * + * @param other The translation to compute the squared distance to. + * @return The squared distance between the two translations. + */ + constexpr units::square_meter_t SquaredDistance( + const Translation3d& other) const { + return units::math::pow<2>(other.m_x - m_x) + + units::math::pow<2>(other.m_y - m_y) + + units::math::pow<2>(other.m_z - m_z); + } + /** * Returns the X component of the translation. * @@ -135,6 +154,17 @@ class WPILIB_DLLEXPORT Translation3d { return units::math::sqrt(m_x * m_x + m_y * m_y + m_z * m_z); } + /** + * Returns the squared norm, or squared distance from the origin to the + * translation. This is equivalent to squaring the result of Norm(), but + * avoids computing a square root. + * + * @return The squared norm of the translation. + */ + constexpr units::square_meter_t SquaredNorm() const { + return m_x * m_x + m_y * m_y + m_z * m_z; + } + /** * Applies a rotation to the translation in 3D space. * @@ -164,6 +194,38 @@ class WPILIB_DLLEXPORT Translation3d { return (*this - other).RotateBy(rot) + other; } + /** + * Computes the dot product between this translation and another translation + * in 3D space. + * + * The dot product between two translations is defined as x₁x₂+y₁y₂+z₁z₂. + * + * @param other The translation to compute the dot product with. + * @return The dot product between the two translations. + */ + constexpr units::square_meter_t Dot(const Translation3d& other) const { + return m_x * other.X() + m_y * other.Y() + m_z * other.Z(); + } + + /** + * Computes the cross product between this translation and another + * translation in 3D space. The resulting translation will be perpendicular to + * both translations. + * + * The 3D cross product between two translations is defined as . + * + * @param other The translation to compute the cross product with. + * @return The cross product between the two translations. + */ + constexpr Eigen::Vector Cross( + const Translation3d& other) const { + return Eigen::Vector{ + {m_y * other.Z() - other.Y() * m_z}, + {m_z * other.X() - other.Z() * m_x}, + {m_x * other.Y() - other.X() * m_y}}; + } + /** * Returns a Translation2d representing this Translation3d projected into the * X-Y plane. diff --git a/wpimath/src/main/native/include/units/math.h b/wpimath/src/main/native/include/units/math.h index a5cf357b5f..727aee62fb 100644 --- a/wpimath/src/main/native/include/units/math.h +++ b/wpimath/src/main/native/include/units/math.h @@ -482,11 +482,10 @@ constexpr dimensionless::scalar_t log2(const ScalarUnit x) noexcept { template < class UnitType, std::enable_if_t::value, int> = 0> -inline constexpr auto sqrt(const UnitType& value) noexcept - -> unit_t< - square_root::unit_type>, - typename units::traits::unit_t_traits::underlying_type, - linear_scale> { +inline constexpr auto sqrt(const UnitType& value) noexcept -> unit_t< + square_root::unit_type>, + typename units::traits::unit_t_traits::underlying_type, + linear_scale> { return unit_t< square_root::unit_type>, typename units::traits::unit_t_traits::underlying_type, @@ -742,8 +741,8 @@ template ::value && traits::is_unit_t::value && traits::is_unit_t::value>> -auto fma(const UnitTypeLhs x, const UnitMultiply y, - const UnitAdd z) noexcept -> decltype(x * y) { +auto fma(const UnitTypeLhs x, const UnitMultiply y, const UnitAdd z) noexcept + -> decltype(x * y) { using resultType = decltype(x * y); static_assert( traits::is_convertible_unit_t< diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/Dense b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/Dense new file mode 100644 index 0000000000..5768910bd8 --- /dev/null +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/Dense @@ -0,0 +1,7 @@ +#include "Core" +#include "LU" +#include "Cholesky" +#include "QR" +#include "SVD" +#include "Geometry" +#include "Eigenvalues" diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/StdVector b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/StdVector new file mode 100644 index 0000000000..711a654eab --- /dev/null +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/StdVector @@ -0,0 +1,30 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// Copyright (C) 2009 Hauke Heibel +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef EIGEN_STDVECTOR_MODULE_H +#define EIGEN_STDVECTOR_MODULE_H + +#include "Core" +#include + +#if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && \ + (EIGEN_MAX_STATIC_ALIGN_BYTES <= 16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ + +#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) + +#else + +// IWYU pragma: begin_exports +#include "src/StlSupport/StdVector.h" +// IWYU pragma: end_exports + +#endif + +#endif // EIGEN_STDVECTOR_MODULE_H diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/StdVector.h b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/StdVector.h new file mode 100644 index 0000000000..dd538e9541 --- /dev/null +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/StdVector.h @@ -0,0 +1,51 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// Copyright (C) 2009 Hauke Heibel +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef EIGEN_STDVECTOR_H +#define EIGEN_STDVECTOR_H + +#ifndef EIGEN_STDVECTOR_MODULE_H +#error "Please include Eigen/StdVector instead of including this file directly." +#endif + +#include "details.h" + +/** + * This section contains a convenience MACRO which allows an easy specialization of + * std::vector such that for data types with alignment issues the correct allocator + * is used automatically. + */ +#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \ + namespace std { \ + template <> \ + class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> > \ + : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > { \ + typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \ + \ + public: \ + typedef __VA_ARGS__ value_type; \ + typedef vector_base::allocator_type allocator_type; \ + typedef vector_base::size_type size_type; \ + typedef vector_base::iterator iterator; \ + explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \ + template \ + vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \ + : vector_base(first, last, a) {} \ + vector(const vector& c) : vector_base(c) {} \ + explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \ + vector(iterator start_, iterator end_) : vector_base(start_, end_) {} \ + vector& operator=(const vector& x) { \ + vector_base::operator=(x); \ + return *this; \ + } \ + }; \ + } + +#endif // EIGEN_STDVECTOR_H diff --git a/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/details.h b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/details.h new file mode 100644 index 0000000000..9bc9d21074 --- /dev/null +++ b/wpimath/src/main/native/thirdparty/eigen/include/Eigen/src/StlSupport/details.h @@ -0,0 +1,82 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2009 Gael Guennebaud +// Copyright (C) 2009 Hauke Heibel +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef EIGEN_STL_DETAILS_H +#define EIGEN_STL_DETAILS_H + +#ifndef EIGEN_ALIGNED_ALLOCATOR +#define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator +#endif + +namespace Eigen { + +// This one is needed to prevent reimplementing the whole std::vector. +template +class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR { + public: + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef T value_type; + + template + struct rebind { + typedef aligned_allocator_indirection other; + }; + + aligned_allocator_indirection() {} + aligned_allocator_indirection(const aligned_allocator_indirection&) : EIGEN_ALIGNED_ALLOCATOR() {} + aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR&) {} + template + aligned_allocator_indirection(const aligned_allocator_indirection&) {} + template + aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR&) {} + ~aligned_allocator_indirection() {} +}; + +#if EIGEN_COMP_MSVC + +// sometimes, MSVC detects, at compile time, that the argument x +// in std::vector::resize(size_t s,T x) won't be aligned and generate an error +// even if this function is never called. Whence this little wrapper. +#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ + std::conditional_t::value, T, Eigen::internal::workaround_msvc_stl_support > + +namespace internal { +template +struct workaround_msvc_stl_support : public T { + inline workaround_msvc_stl_support() : T() {} + inline workaround_msvc_stl_support(const T& other) : T(other) {} + inline operator T&() { return *static_cast(this); } + inline operator const T&() const { return *static_cast(this); } + template + inline T& operator=(const OtherT& other) { + T::operator=(other); + return *this; + } + inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) { + T::operator=(other); + return *this; + } +}; +} // namespace internal + +#else + +#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T + +#endif + +} // namespace Eigen + +#endif // EIGEN_STL_DETAILS_H diff --git a/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation2dTest.java b/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation2dTest.java index 82ea7ab866..5514b90213 100644 --- a/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation2dTest.java +++ b/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation2dTest.java @@ -86,6 +86,12 @@ class Translation2dTest { assertEquals(Math.hypot(3.0, 5.0), one.getNorm(), kEpsilon); } + @Test + void testSquaredNorm() { + var one = new Translation2d(3.0, 5.0); + assertEquals(34.0, one.getSquaredNorm(), kEpsilon); + } + @Test void testDistance() { var one = new Translation2d(1, 1); @@ -93,6 +99,13 @@ class Translation2dTest { assertEquals(5.0 * Math.sqrt(2.0), one.getDistance(two), kEpsilon); } + @Test + void testSquaredDistance() { + var one = new Translation2d(1, 1); + var two = new Translation2d(6, 6); + assertEquals(50.0, one.getSquaredDistance(two), kEpsilon); + } + @Test void testUnaryMinus() { var original = new Translation2d(-4.5, 7); @@ -154,4 +167,18 @@ class Translation2dTest { assertEquals(vec, translation.toVector()); } + + @Test + void testDot() { + var one = new Translation2d(2.0, 3.0); + var two = new Translation2d(3.0, 4.0); + assertEquals(18.0, one.dot(two), kEpsilon); + } + + @Test + void testCross() { + var one = new Translation2d(2.0, 3.0); + var two = new Translation2d(3.0, 4.0); + assertEquals(-1.0, one.cross(two), kEpsilon); + } } diff --git a/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation3dTest.java b/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation3dTest.java index 95a970ba6f..a8efcde086 100644 --- a/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation3dTest.java +++ b/wpimath/src/test/java/edu/wpi/first/math/geometry/Translation3dTest.java @@ -149,6 +149,12 @@ class Translation3dTest { assertEquals(Math.sqrt(83.0), one.getNorm(), kEpsilon); } + @Test + void testSquaredNorm() { + var one = new Translation3d(3.0, 5.0, 7.0); + assertEquals(83.0, one.getSquaredNorm(), kEpsilon); + } + @Test void testDistance() { var one = new Translation3d(1.0, 1.0, 1.0); @@ -156,6 +162,13 @@ class Translation3dTest { assertEquals(5.0 * Math.sqrt(3.0), one.getDistance(two), kEpsilon); } + @Test + void testSquaredDistance() { + var one = new Translation3d(1.0, 1.0, 1.0); + var two = new Translation3d(6.0, 6.0, 6.0); + assertEquals(75.0, one.getSquaredDistance(two), kEpsilon); + } + @Test void testUnaryMinus() { var original = new Translation3d(-4.5, 7.0, 9.0); @@ -225,4 +238,23 @@ class Translation3dTest { assertEquals(translation1, origin.nearest(List.of(translation1, translation2, translation3))); assertEquals(translation2, origin.nearest(List.of(translation4, translation2, translation3))); } + + @Test + void testDot() { + var one = new Translation3d(1.0, 2.0, 3.0); + var two = new Translation3d(4.0, 5.0, 6.0); + assertEquals(32.0, one.dot(two)); + } + + @Test + void testCross() { + var one = new Translation3d(1.0, 2.0, 3.0); + var two = new Translation3d(4.0, 5.0, 6.0); + + var cross = one.cross(two); + assertAll( + () -> assertEquals(-3.0, cross.get(0, 0), kEpsilon), + () -> assertEquals(6.0, cross.get(1, 0), kEpsilon), + () -> assertEquals(-3.0, cross.get(2, 0), kEpsilon)); + } } diff --git a/wpimath/src/test/native/cpp/geometry/Translation2dTest.cpp b/wpimath/src/test/native/cpp/geometry/Translation2dTest.cpp index 294c213a3d..e44e334aec 100644 --- a/wpimath/src/test/native/cpp/geometry/Translation2dTest.cpp +++ b/wpimath/src/test/native/cpp/geometry/Translation2dTest.cpp @@ -68,12 +68,23 @@ TEST(Translation2dTest, Norm) { EXPECT_DOUBLE_EQ(std::hypot(3.0, 5.0), one.Norm().value()); } +TEST(Translation2dTest, SquaredNorm) { + const Translation2d one{3_m, 5_m}; + EXPECT_DOUBLE_EQ(34.0, one.SquaredNorm().value()); +} + TEST(Translation2dTest, Distance) { const Translation2d one{1_m, 1_m}; const Translation2d two{6_m, 6_m}; EXPECT_DOUBLE_EQ(5.0 * std::sqrt(2.0), one.Distance(two).value()); } +TEST(Translation2dTest, SquaredDistance) { + const Translation2d one{1_m, 1_m}; + const Translation2d two{6_m, 6_m}; + EXPECT_DOUBLE_EQ(50.0, one.SquaredDistance(two).value()); +} + TEST(Translation2dTest, UnaryMinus) { const Translation2d original{-4.5_m, 7_m}; const auto inverted = -original; @@ -162,3 +173,15 @@ TEST(Translation2dTest, Constexpr) { static_assert(multiplied.X() == 2_m); static_assert(divided.Y() == 1_m); } + +TEST(Translation2dTest, Dot) { + const Translation2d one{2_m, 3_m}; + const Translation2d two{3_m, 4_m}; + EXPECT_DOUBLE_EQ(18.0, one.Dot(two).value()); +} + +TEST(Translation2dTest, Cross) { + const Translation2d one{2_m, 3_m}; + const Translation2d two{3_m, 4_m}; + EXPECT_DOUBLE_EQ(-1.0, one.Cross(two).value()); +} diff --git a/wpimath/src/test/native/cpp/geometry/Translation3dTest.cpp b/wpimath/src/test/native/cpp/geometry/Translation3dTest.cpp index b297f1217c..cdc7a6ebb7 100644 --- a/wpimath/src/test/native/cpp/geometry/Translation3dTest.cpp +++ b/wpimath/src/test/native/cpp/geometry/Translation3dTest.cpp @@ -114,12 +114,23 @@ TEST(Translation3dTest, Norm) { EXPECT_NEAR(one.Norm().value(), std::hypot(3, 5, 7), kEpsilon); } +TEST(Translation3dTest, SquaredNorm) { + const Translation3d one{3_m, 5_m, 7_m}; + EXPECT_NEAR(one.SquaredNorm().value(), 83.0, kEpsilon); +} + TEST(Translation3dTest, Distance) { const Translation3d one{1_m, 1_m, 1_m}; const Translation3d two{6_m, 6_m, 6_m}; EXPECT_NEAR(one.Distance(two).value(), 5 * std::sqrt(3), kEpsilon); } +TEST(Translation3dTest, SquaredDistance) { + const Translation3d one{1_m, 1_m, 1_m}; + const Translation3d two{6_m, 6_m, 6_m}; + EXPECT_NEAR(one.SquaredDistance(two).value(), 75.0, kEpsilon); +} + TEST(Translation3dTest, UnaryMinus) { const Translation3d original{-4.5_m, 7_m, 9_m}; const auto inverted = -original; @@ -214,3 +225,19 @@ TEST(Translation3dTest, Nearest) { EXPECT_DOUBLE_EQ(nearest3.Y().value(), translation2.Y().value()); EXPECT_DOUBLE_EQ(nearest3.Z().value(), translation2.Z().value()); } + +TEST(Translation3dTest, Dot) { + const Translation3d one{1_m, 2_m, 3_m}; + const Translation3d two{4_m, 5_m, 6_m}; + EXPECT_NEAR(one.Dot(two).value(), 32.0, kEpsilon); +} + +TEST(Translation3dTest, Cross) { + const Translation3d one{1_m, 2_m, 3_m}; + const Translation3d two{4_m, 5_m, 6_m}; + + auto cross = one.Cross(two); + EXPECT_NEAR(cross[0].value(), -3.0, kEpsilon); + EXPECT_NEAR(cross[1].value(), 6.0, kEpsilon); + EXPECT_NEAR(cross[2].value(), -3.0, kEpsilon); +}