Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Use cubic spline for initial guess #148

Closed

Conversation

bruingineer
Copy link
Contributor

use wpi spline generator to create the initial guess translation. heading is interpolated separately between each waypoint and initial guess point.

Copy link
Contributor

@spacey-sooty spacey-sooty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this should manually copy in Eigen or wpimath....

@calcmogul
Copy link
Member

calcmogul commented Apr 9, 2024

Instead, after fetching Sleipnir, it could set the following then fetch allwpilib via FetchContent:

set(USE_SYSTEM_EIGEN ON)
set(USE_SYSTEM_FMTLIB ON)
set(WITH_JAVA OFF)
set(WITH_CSCORE OFF)
set(WITH_NTCORE OFF)
set(WITH_WPIMATH ON)
set(WITH_WPILIB OFF)
set(WITH_TESTS OFF)
set(WITH_GUI OFF)
set(WITH_SIMULATION_MODULES OFF)

@calcmogul
Copy link
Member

calcmogul commented Apr 9, 2024

I tried the thing I suggested, and WPILib's CMake setup is kinda broken. Here's the changes I had to make to WPILib:

diff --git a/wpimath/CMakeLists.txt b/wpimath/CMakeLists.txt
index a22ffc0b8..c7a99729c 100644
--- a/wpimath/CMakeLists.txt
+++ b/wpimath/CMakeLists.txt
@@ -200,6 +200,7 @@ target_include_directories(
 )
 
 install(TARGETS wpimath EXPORT wpimath)
+export(TARGETS wpimath FILE wpimath.cmake NAMESPACE wpimath::)
 
 configure_file(wpimath-config.cmake.in ${WPILIB_BINARY_DIR}/wpimath-config.cmake)
 install(FILES ${WPILIB_BINARY_DIR}/wpimath-config.cmake DESTINATION share/wpimath)
diff --git a/wpiutil/CMakeLists.txt b/wpiutil/CMakeLists.txt
index 4caa3521b..e01203f6c 100644
--- a/wpiutil/CMakeLists.txt
+++ b/wpiutil/CMakeLists.txt
@@ -258,6 +258,7 @@ target_include_directories(
 )
 
 install(TARGETS wpiutil EXPORT wpiutil)
+export(TARGETS wpiutil FILE wpiutil.cmake NAMESPACE wpiutil::)
 
 configure_file(wpiutil-config.cmake.in ${WPILIB_BINARY_DIR}/wpiutil-config.cmake)
 install(FILES ${WPILIB_BINARY_DIR}/wpiutil-config.cmake DESTINATION share/wpiutil)

Here's the TrajoptLib CMake changes:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02e4ad4..f952f55 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,9 @@ set(CMAKE_MODULE_PATH
     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
 )
 
+# Allow overriding options in parent projects
+cmake_policy(SET CMP0077 NEW)
+
 project(TrajoptLib LANGUAGES CXX)
 
 # Use, i.e. don't skip the full RPATH for the build tree
@@ -146,6 +149,25 @@ elseif(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
     target_link_libraries(TrajoptLib PRIVATE Sleipnir)
 endif()
 
+# wpimath dependency
+set(WITH_CSCORE OFF CACHE INTERNAL "With CSCore")
+set(WITH_GUI OFF CACHE INTERNAL "With GUI")
+set(WITH_JAVA OFF CACHE INTERNAL "With Java")
+set(WITH_NTCORE OFF CACHE INTERNAL "With NTCore")
+set(WITH_SIMULATION_MODULES OFF CACHE INTERNAL "With Simulation Modules")
+set(WITH_TESTS OFF CACHE INTERNAL "With Tests")
+set(WITH_WPIMATH ON CACHE INTERNAL "With WPIMath")
+set(WITH_WPILIB OFF CACHE INTERNAL "With WPILib")
+fetchcontent_declare(
+    wpilib
+    #GIT_REPOSITORY https://github.com/wpilibsuite/allwpilib.git
+    #GIT_TAG v2024.3.2
+    GIT_REPOSITORY file:///home/tav/frc/wpilib/allwpilib
+    GIT_TAG 9ffce38bf71b1a96c009fc7e46c79b3beb6468a9
+)
+fetchcontent_makeavailable(wpilib)
+target_link_libraries(TrajoptLib PRIVATE Eigen3::Eigen wpimath)
+
 target_include_directories(
     TrajoptLib
     PUBLIC

I changed the fetchcontent target to a file:// repo and local commit hash for testing. I'll make a PR to your PR.

@calcmogul
Copy link
Member

calcmogul commented Apr 9, 2024

Here's the cleanup PR: bruingineer#1

@calcmogul
Copy link
Member

With regard to the merge conflicts, the linear initial guess generator moved to https://github.com/SleipnirGroup/TrajoptLib/blob/main/include/trajopt/util/GenerateLinearInitialGuess.hpp, so this PR can mirror that structure.

@calcmogul
Copy link
Member

TrajoptLib has moved to a subfolder within SleipnirGroup/Choreo. The changes here should be merged into SleipnirGroup/Choreo#478.

@calcmogul calcmogul closed this Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants