### QuickStart Example 2 Dynamic Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html A dynamic-sized matrix example from the Eigen QuickStart guide. ```cpp #include int main() { Eigen::MatrixXd m(2,2); m(0,0) = 3; m(0,1) = -2; m(1,0) = 1; m(1,1) = 0; std::cout << "m:\n" << m << std::endl; return 0; } ``` -------------------------------- ### Quick Start Example: Dynamic Size Matrix Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html A basic example demonstrating the creation and manipulation of a dynamically sized matrix. ```cpp #include #include int main() { Eigen::MatrixXd m(2,2); m(0,0) = 3; m(1,0) = 2.5; m(0,1) = -1; m(1,1) = m(0,0) + m(1,0); std::cout << m << std::endl; return 0; } ``` -------------------------------- ### QuickStart example2 fixed Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html A simple example demonstrating fixed-size vectors and matrices in Eigen, suitable for quick testing and learning. ```cpp #include #include int main() { Eigen::Vector2d v(1,2); Eigen::Matrix2d m; m << 1, 2, 3, 4; std::cout << "Vector: " << v.transpose() << std::endl; std::cout << "Matrix:\n" << m << std::endl; return 0; } ``` -------------------------------- ### MatrixBase template int start() Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Demonstrates creating a matrix with specific dimensions using template parameters. ```cpp #include int main() { // Create a 4x2 matrix of integers Eigen::Matrix mat; mat.setZero(); // Initialize with zeros std::cout << "4x2 integer matrix initialized to zero:\n" << mat << std::endl; return 0; } ``` -------------------------------- ### Add Examples with gtsamAddExamplesGlob Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/cmake/README.html Create executables for example files specified by glob patterns. These examples are not installed and can be built with 'make examples' or 'make all' if configured. ```cmake gtsamAddExamplesGlob("*.cpp" "BrokenExample.cpp" "gtsam;GeographicLib" ON) ``` -------------------------------- ### Install Documentation Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/doc/CMakeLists.txt Installs the generated HTML documentation to the specified installation directory. ```cmake install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${INSTALL_DOC_DIR}) ``` -------------------------------- ### Install Documentation Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/docs/source/CMakeLists.txt Installs the generated HTML documentation to the specified installation directory. It targets the 'Doc' component for installation. ```cmake install(DIRECTORY ${SPHINX_HTML_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT Doc PATTERN "${SPHINX_HTML_DIR}/*") ``` -------------------------------- ### Install GeographicLib from source Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/python/doc/index.md Install the GeographicLib Python package by downloading the source archive and running the setup script. This method is useful for development or when pip is not available. ```shell tar xpfz geographiclib-1.49.tar.gz cd geographiclib-1.49 python setup.py install ``` -------------------------------- ### Installation Rules Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/route_planner/boundary_handler/CMakeLists.txt Specifies how to install the built targets and associated files. ```cmake install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME} ) install(DIRECTORY launch/ DESTINATION share/${PROJECT_NAME}/launch ) install(DIRECTORY rviz DESTINATION share/${PROJECT_NAME}) install(DIRECTORY config DESTINATION share/${PROJECT_NAME}) ament_package() ``` -------------------------------- ### Include Livox SDK2 Example Subdirectories Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/samples/CMakeLists.txt Adds various example subdirectories to the build. Each subdirectory likely contains its own CMakeLists.txt for building specific examples. ```cmake add_subdirectory(livox_lidar_quick_start) ``` ```cmake add_subdirectory(multi_lidars_upgrade) ``` ```cmake add_subdirectory(logger) ``` ```cmake add_subdirectory(debug_point_cloud) ``` ```cmake add_subdirectory(lidar_cmd_observer) ``` ```cmake add_subdirectory(livox_lidar_rmc_time_sync) ``` -------------------------------- ### Compile and Install Livox-SDK2 on Ubuntu Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/README.md Clones the Livox-SDK2 repository, creates a build directory, and compiles and installs the SDK using CMake and make. Installs libraries to /usr/local/lib and headers to /usr/local/include. ```shell $ git clone https://github.com/Livox-SDK/Livox-SDK2.git $ cd ./Livox-SDK2/ $ mkdir build $ cd build $ cmake .. && make -j $ sudo make install ``` -------------------------------- ### Build and Install WRAP with CMake Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/wrap/README.md Standard CMake build and installation process for the WRAP library. Use sudo if root privileges are needed for installation. ```shell mkdir build && cd build cmake .. make install # use sudo if needed ``` -------------------------------- ### Creating a Custom Target for .NET Examples Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/dotnet/examples/ManagedCPP/CMakeLists.txt This command creates a custom target named 'netexamples' that depends on all the individual example executables. This allows the examples to be built collectively as a single target. ```cmake add_custom_target (netexamples DEPENDS ${EXAMPLES}) ``` -------------------------------- ### Install Executables Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/base_autonomy/vehicle_simulator/CMakeLists.txt Installs the compiled 'vehicleSimulator' and 'sim_image_repub' executables into the 'lib/vehicle_simulator' directory. ```cmake install(TARGETS vehicleSimulator sim_image_repub DESTINATION lib/${PROJECT_NAME}) ``` -------------------------------- ### Install Shared Library Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/dotnet/NETGeographicLib/CMakeLists.txt This command installs the target shared library. 'RUNTIME DESTINATION bin' specifies that the DLL should be placed in the 'bin' directory of the installation prefix. ```cmake install (TARGETS ${NETGEOGRAPHICLIB_LIBRARIES} EXPORT targets RUNTIME DESTINATION bin) ``` -------------------------------- ### Compile and Run C++ Example using CMake on Unix Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/exploration_planner/tare_planner/or-tools/README.md Compile and run a C++ example using CMake on Unix-like systems. Navigate to the example's directory and set the CMAKE_PREFIX_PATH correctly. ```shell cd examples/basic_example cmake -S . -B build -DCMAKE_PREFIX_PATH=../.. cmake --build build -v ``` -------------------------------- ### Build and Install GTSAM Python Wrapper Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/python/README.md Builds GTSAM and its Python wrapper, then installs the wrapper. This can be done directly with 'make python-install' or after a full build. Installation can be directed to a local subdirectory. ```bash make python-install ``` ```bash make make python-install ``` ```bash cmake .. -DCMAKE_INSTALL_PREFIX="./install" make python-install ``` -------------------------------- ### Installing Executable Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/base_autonomy/terrain_analysis_ext/CMakeLists.txt Installs the built 'terrainAnalysisExt' executable to the appropriate library directory. ```cmake install(TARGETS terrainAnalysisExt DESTINATION lib/${PROJECT_NAME}) ``` -------------------------------- ### Run Livox lidar quick start sample on Ubuntu Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/README.md Executes the 'livox_lidar_quick_start' sample program on Ubuntu. Requires navigating to the sample directory and providing a configuration file path. ```shell $ cd samples/livox_lidar_quick_start && ./livox_lidar_quick_start ../../../samples/livox_lidar_quick_start/[config file] ``` -------------------------------- ### Install Navigation Headers Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/navigation/CMakeLists.txt Installs all header files from the navigation directory to the include/gtsam/navigation destination. ```cmake file(GLOB navigation_headers "*.h") install(FILES ${navigation_headers} DESTINATION include/gtsam/navigation) ``` -------------------------------- ### Specify GeographicLib Installation Directory Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/wrapper/C/00README.txt Example of how to specify the GeographicLib installation directory when invoking CMake. ```bash -D GeographicLib_DIR=../../BUILD ``` -------------------------------- ### Conditional Installation with Build Type Postfixes Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/matlab/CMakeLists.txt Installs MATLAB example data. If build type postfixes are enabled, it iterates through configurations to append the build type to the installation path. Otherwise, it installs to a single destination. ```cmake if(GTSAM_BUILD_TYPE_POSTFIXES) foreach(build_type ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${build_type}" build_type_upper) if(${build_type_upper} STREQUAL "RELEASE") set(build_type_tag "") # Don't create release mode tag on installed # directory else() set(build_type_tag "${build_type}") endif() # Split up filename to strip trailing '/' in GTSAM_TOOLBOX_INSTALL_PATH if # there is one get_filename_component(location "${GTSAM_TOOLBOX_INSTALL_PATH}" PATH) get_filename_component(name "${GTSAM_TOOLBOX_INSTALL_PATH}" NAME) install( FILES ${matlab_examples_data} DESTINATION "${location}/${name}${build_type_tag}/gtsam_examples/Data" CONFIGURATIONS "${build_type}") endforeach() else() install(FILES ${matlab_examples_data} DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH}/gtsam_examples/Data) endif() ``` -------------------------------- ### Run Livox lidar quick start sample on Windows Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/README.md Executes the 'livox_lidar_quick_start.exe' program on Windows. Requires copying the configuration file to the executable's directory and running the executable with the config file as an argument. ```cmd > livox_lidar_quick_start.exe [config file] ``` -------------------------------- ### Tutorial commainit_01b Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Demonstrates comma initialization for matrices. ```cpp #include int main() { Eigen::Matrix3f m; m << 1, 2, 3, 4, 5, 6, 7, 8, 9; std::cout << "Comma initialized matrix:\n" << m << std::endl; return 0; } ``` -------------------------------- ### NETGeographicLib Geodesic Class Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/doc/NETGeographicLib.dox A simple C++ example demonstrating the use of the NETGeographicLib::Geodesic class to perform geodesic calculations. This code requires the NETGeographicLib library to be installed. ```cpp #include "NETGeographicLib/Geodesic.h" #include int main(int argc, char **argv) { NETGeographicLib::Geodesic g; double lat1 = 40.7128; // New York City double lon1 = -74.0060; double lat2 = 34.0522; // Los Angeles double lon2 = -118.2437; double s12, az1, az2; g.Inverse(lat1, lon1, lat2, lon2, s12, az1, az2); std::cout << "Distance: " << s12 << " meters\n"; std::cout << "Azimuth 1: " << az1 << " degrees\n"; std::cout << "Azimuth 2: " << az2 << " degrees\n"; return 0; } ``` -------------------------------- ### CMakeLists.txt for NETGeographicLib Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/doc/NETGeographicLib.dox A CMakeLists.txt file to build a C++ example using the installed NETGeographicLib library. This configuration is suitable for Visual Studio projects using the /clr compiler option. ```cmake project (geodesictest) cmake_minimum_required (VERSION 2.8.7) # required for VS_DOTNET_REFERENCES find_package (GeographicLib 1.35 REQUIRED COMPONENTS NETGeographicLib) add_executable (${PROJECT_NAME} example-Geodesic-small.cpp) set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/clr") string (REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string (REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ``` -------------------------------- ### Install GeographicLib Node.js Package Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/js/GeographicLib.md Install the geographiclib node package using npm for use in Node.js environments. This command also shows how to start a Node.js REPL and require the library. ```bash $ npm install geographiclib $ node > var GeographicLib = require("geographiclib"); ``` -------------------------------- ### Build and Run Inverse Example (Unix-like) Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/java/README.txt Demonstrates how to compile and execute the Inverse example program on Unix-like systems. Requires the GeographicLib Java source files. ```bash cd inverse/src/main/java javac -cp .:../../../../src/main/java Inverse.java echo -30 0 29.5 179.5 | java -cp .:../../../../src/main/java Inverse ``` -------------------------------- ### Globbing Example Sources Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/examples/CMakeLists.txt This snippet uses file(GLOB ...) to find C++ source files for examples, typically those starting with 'example-'. It's conditional on GEOGRAPHICLIB_PRECISION being set to 2. ```cmake if (GEOGRAPHICLIB_PRECISION EQUAL 2) # These examples all assume real = double file (GLOB EXAMPLE_SOURCES example-*.cpp) if (USE_BOOST_FOR_EXAMPLES AND Boost_FOUND) add_definitions (-DGEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION=1) include_directories ("${Boost_INCLUDE_DIRS}") endif () else () set (EXAMPLE_SOURCES) endif () ``` -------------------------------- ### Build and Run Inverse Example (Windows) Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/java/README.txt Demonstrates how to compile and execute the Inverse example program on Windows systems. Requires the GeographicLib Java source files. ```batch cd inverse\src\main\java javac -cp .;../../../../src/main/java Inverse.java echo -30 0 29.5 179.5 | java -cp .;../../../../src/main/java Inverse ``` -------------------------------- ### Tutorial: Advanced Initialization (Three Ways) Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Illustrates three different methods for initializing matrices in Eigen: direct assignment, comma initializer, and using expressions. ```cpp #include int main() { // Method 1: Direct assignment Eigen::Matrix3f m1; m1 << 1, 2, 3, 4, 5, 6, 7, 8, 9; // Method 2: Comma initializer Eigen::Matrix3f m2(3,3); m2 << 1, 2, 3, 4, 5, 6, 7, 8, 9; // Method 3: Using expressions Eigen::Matrix3f m3 = Eigen::Matrix3f::Identity() * 2; std::cout << "m1:\n" << m1 << std::endl; std::cout << "m2:\n" << m2 << std::endl; std::cout << "m3:\n" << m3 << std::endl; return 0; } ``` -------------------------------- ### Copy Data Directory to Python Site Package Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/python/CMakeLists.txt Copies the 'Data' directory from the GTSAM source examples to the Python site-packages directory. This makes example data accessible to the installed Python module. ```cmake file(COPY "${GTSAM_SOURCE_DIR}/examples/Data" DESTINATION "${GTSAM_MODULE_PATH}") ``` -------------------------------- ### Build and Install Livox-SDK2 Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/README.md Builds and installs the Livox-SDK2 library from source. Ensure you are in the correct directory within the cloned repository. ```bash mkdir build && cd build cmake .. make && sudo make install ``` -------------------------------- ### JavaScript: Find a Point Given a Starting Point, Azimuth, and Distance Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/js/GeographicLib.md Find the coordinates of a destination point given a starting point, an initial azimuth, and a distance along the geodesic using the GeographicLib.Geodesic.WGS84 instance. This example demonstrates the Direct method. ```javascript var geod = GeographicLib.Geodesic.WGS84, r; // Find the point 20000 km SW of Perth, Australia (32.06S, 115.74E)... r = geod.Direct(-32.06, 115.74, 225, 20000e3); console.log("The position is (" + r.lat2.toFixed(8) + ", " + r.lon2.toFixed(8) + ")."); // This prints "The position is (32.11195529, -63.95925278)." ``` -------------------------------- ### Installation Rules for Targets and Files Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/base_autonomy/local_planner/CMakeLists.txt Installs the built executables to the 'lib' directory and configuration files (config, launch, paths) to the 'share' directory. ```cmake install(TARGETS localPlanner pathFollower DESTINATION lib/${PROJECT_NAME}) install( DIRECTORY config launch paths DESTINATION share/${PROJECT_NAME}) ``` -------------------------------- ### Static Method Declaration Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/wrap/DOCS.md Example of declaring a static method. Static methods must start with a letter and use the 'static' keyword. ```cpp static void func(); ``` -------------------------------- ### Run GTSAM Docker Image Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/docker/README.md Starts a Docker container with GTSAM installed. You will be placed in a bash shell within the build directory. ```bash docker run -it borglab/ubuntu-gtsam:bionic ``` -------------------------------- ### Packageament_package() Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/route_planner/visibility_graph_msg/CMakeLists.txt Finalizes the package setup for ament, ensuring it's correctly registered and installable within the ROS 2 build system. ```cmake ament_package() ``` -------------------------------- ### Using Ceres with CMake Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/docs/source/installation.md Example CMakeLists.txt to compile a standalone project that uses the Ceres library. Ensure Ceres is installed or exported for find_package to work. ```cmake cmake_minimum_required(VERSION 3.5) project(helloworld) find_package(Ceres REQUIRED) # helloworld add_executable(helloworld helloworld.cc) target_link_libraries(helloworld Ceres::ceres) ``` -------------------------------- ### Build and Run GTSAM Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/examples/README.md Instructions on how to build and run a GTSAM C++ example. This typically involves creating a build directory, configuring with CMake, and then using make targets to build or build and run specific examples. ```bash mkdir build cd build cmake .. make CameraResectioning make CameraResectioning.run ``` -------------------------------- ### Run GTSAM with Python Wrapper Docker Image Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/docker/README.md Starts a Docker container with GTSAM and its Python wrapper installed. Allows interactive use of the Python interpreter. ```bash docker run -it borglab/ubuntu-gtsam-python:bionic ``` ```python python3 >>> import gtsam >>> gtsam.Pose2(1,2,3) (1, 2, 3) ``` -------------------------------- ### Compile and Run C++ Example using Makefile Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/exploration_planner/tare_planner/or-tools/README.md Use this command to compile and run a specific C++ example file using the provided Makefile. Ensure you are in the root OR-Tools directory. ```shell make run SOURCE=examples/basic_example/basic_example.cc ``` -------------------------------- ### BiCubicInterpolator Usage Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/docs/source/nnls_modeling.md Demonstrates how to use BiCubicInterpolator to interpolate a 2D array. It shows the setup of a Grid2D helper class and the evaluation of the interpolated function and its derivatives. ```c++ const double data[] = {1.0, 3.0, -1.0, 4.0, 3.6, 2.1, 4.2, 2.0, 2.0, 1.0, 3.1, 5.2}; Grid2D array(data, 0, 3, 0, 4); BiCubicInterpolator interpolator(array); double f, dfdr, dfdc; interpolator.Evaluate(1.2, 2.5, &f, &dfdr, &dfdc); ``` -------------------------------- ### GradientChecker Usage Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/docs/source/nnls_modeling.md Demonstrates how to use the GradientChecker class to compare analytical Jacobians with numerically estimated ones. Ensure correct manifold and parameter block setup. ```c++ CostFunction* my_cost_function = ... Manifold* my_manifold = ... NumericDiffOptions numeric_diff_options; std::vector manifolds; manifolds.push_back(my_manifold); manifolds.push_back(nullptr); std::vector parameter1; std::vector parameter2; // Fill parameter 1 & 2 with test data... std::vector parameter_blocks; parameter_blocks.push_back(parameter1.data()); parameter_blocks.push_back(parameter2.data()); GradientChecker gradient_checker(my_cost_function, manifolds, numeric_diff_options); GradientCheckResults results; if (!gradient_checker.Probe(parameter_blocks.data(), 1e-9, &results)) { LOG(ERROR) << "An error has occurred:\n" << results.error_log; } ``` -------------------------------- ### Build and Link Sparse Example with Qt4 Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/Eigen/doc/special_examples/CMakeLists.txt This snippet defines an executable for a sparse example, links it with necessary libraries including Qt4, and sets up a post-build custom command to generate an image. ```cmake if(QT4_FOUND) add_executable(Tutorial_sparse_example Tutorial_sparse_example.cpp Tutorial_sparse_example_details.cpp) target_link_libraries(Tutorial_sparse_example ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) add_custom_command( TARGET Tutorial_sparse_example POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/../html/ COMMAND Tutorial_sparse_example ARGS ${CMAKE_CURRENT_BINARY_DIR}/../html/Tutorial_sparse_example.jpeg ) add_dependencies(all_examples Tutorial_sparse_example) endif() ``` -------------------------------- ### Using GeographicLib Python Wrapper for Height Conversion Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/wrapper/python/00README.txt Example of using the PyGeographicLib wrapper to convert geoid height to ellipsoid height. Requires the 'egm2008-1' geoid data to be installed. ```python >>> from PyGeographicLib import Geoid >>> geoid = Geoid("egm2008-1") >>> geoid.EllipsoidHeight(42, -75, 20) -10.671887499999997 ``` -------------------------------- ### Building Executable for Each Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/examples/CMakeLists.txt This loop iterates through the identified example source files, creates an executable for each, and links necessary libraries. It also includes header files if they exist. ```cmake set (EXAMPLES) add_definitions (${PROJECT_DEFINITIONS}) foreach (EXAMPLE_SOURCE ${EXAMPLE_SOURCES}) get_filename_component (EXAMPLE ${EXAMPLE_SOURCE} NAME_WE) set (EXAMPLES ${EXAMPLES} ${EXAMPLE}) if (EXISTS ${EXAMPLE}.hpp) set (EXAMPLE_SOURCE ${EXAMPLE_SOURCE} ${EXAMPLE}.hpp) endif () add_executable (${EXAMPLE} EXCLUDE_FROM_ALL ${EXAMPLE_SOURCE}) target_link_libraries (${EXAMPLE} ${PROJECT_LIBRARIES} ${QUAD_LIBRARIES} ${MPFR_LIBRARIES}) endforeach () ``` -------------------------------- ### Tutorial Matrix Assignment Resizing Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html A tutorial example showing matrix assignment and resizing in Eigen. ```cpp #include int main() { Eigen::MatrixXf m(2,2); m << 1, 2, 3, 4; std::cout << "m:\n" << m << std::endl; m.resize(3,3); m << 1, 2, 3, 4, 5, 6, 7, 8, 9; std::cout << "m resized:\n" << m << std::endl; return 0; } ``` -------------------------------- ### Compile-Time Fixed Size Sequence Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/Eigen/doc/TutorialSlicingIndexing.dox Creates a sequence with a compile-time known size. This example demonstrates a sequence starting from 'last-7' and ending 2 elements before 'last', resulting in a compile-time size of 6. ```Eigen v(seq(last-fix<7>, last-fix<2>)) ``` -------------------------------- ### Tutorial: Sparse Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Provides a basic example of using sparse matrices in Eigen. This is crucial for handling large matrices where most elements are zero, saving memory and computation time. ```cpp #include #include int main() { // Create a sparse matrix Eigen::SparseMatrix spMat(3, 3); // Fill the sparse matrix spMat.insert(0, 0) = 1.0; spMat.insert(1, 1) = 2.0; spMat.insert(2, 2) = 3.0; // Make sure all values are set spMat.makeCompressed(); // Print the sparse matrix (will show non-zero elements) std::cout << "Sparse Matrix:\n" << spMat << std::endl; // Perform a sparse matrix-vector multiplication Eigen::VectorXd vec(3); vec << 1, 2, 3; Eigen::VectorXd result = spMat * vec; std::cout << "Result of sparse matrix-vector multiplication:\n" << result << std::endl; return 0; } ``` -------------------------------- ### Running Geodesic Test Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/doc/NETGeographicLib.dox Shows how to execute the geodesictest.exe example after building the project to verify the NETGeographicLib integration. ```bash Release\geodesictest.exe ``` -------------------------------- ### Calculate Relative Path for Install Config Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/CMakeLists.txt Calculates the relative path from the installed CeresConfig.cmake file to the install prefix, useful for relocatable installations. ```cmake # Save the relative path from the installed CeresConfig.cmake file to the # install prefix. We do not save an absolute path in case the installed package # is subsequently relocated after installation (on Windows). file(RELATIVE_PATH INSTALL_ROOT_REL_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${RELATIVE_CMAKECONFIG_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) ``` -------------------------------- ### Running GTSAM Examples GUI Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/matlab/README.md Navigate to the toolbox directory and run the GTSAM examples GUI to explore functionalities. ```matlab >> cd /Users/yourname/toolbox % Change to wherever you installed the toolbox >> cd gtsam_examples % Change to the examples directory >> gtsamExamples % Run the GTSAM examples GUI ``` -------------------------------- ### Install Python Files Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/python/geographiclib/CMakeLists.txt Installs the found Python files into the determined Python installation directory. ```cmake install (FILES ${PYTHON_FILES} DESTINATION ${INSTALL_PYTHON_DIR}/geographiclib) ``` -------------------------------- ### Install Partition Headers Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam_unstable/partition/CMakeLists.txt Finds all header files in the current directory and installs them to the specified include path. ```cmake file(GLOB partition_headers "*.h") install(FILES ${partition_headers} DESTINATION include/gtsam_unstable/partition) ``` -------------------------------- ### Sparse Matrix Initialization Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/Eigen/doc/SparseQuickReference.dox Demonstrates how to create sparse matrices with default (column-major) or specified storage orders. ```C++ SparseMatrix sm1(1000,1000); SparseMatrix,RowMajor> sm2; ``` -------------------------------- ### Install Configured Headers Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/CMakeLists.txt Installs the configured Ceres config.h and export.h into the installed headers directory. ```cmake # Also setup installation of Ceres config.h configured with the current # build options and export.h into the installed headers directory. install(DIRECTORY ${Ceres_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### Tutorial: Map Using Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Shows how to map existing data into an Eigen matrix or vector. This is efficient for working with data already allocated in memory without copying. ```cpp #include int main() { float data[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}; Eigen::Map> mat(data); std::cout << "Mapped matrix:\n" << mat << std::endl; return 0; } ``` -------------------------------- ### Conditional Install Setup.py Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/python/geographiclib/CMakeLists.txt Installs the setup.py file only on Windows when not using a common installation path to avoid conflicts. ```cmake if (NOT COMMON_INSTALL_PATH) install (FILES ../setup.py DESTINATION ${INSTALL_PYTHON_DIR}) endif () ``` -------------------------------- ### Install GTSAM Target Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/CMakeLists.txt Installs the 'gtsam' target, including libraries, archives, and runtime binaries, to their designated installation directories. ```cmake install( TARGETS gtsam EXPORT GTSAM-exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/samples/livox_lidar_quick_start/CMakeLists.txt Configures the build for the livox_lidar_quick_start executable, linking against the livox_lidar_sdk_static library. ```cmake cmake_minimum_required(VERSION 3.0) set(DEMO_NAME livox_lidar_quick_start) add_executable(${DEMO_NAME} main.cpp) target_link_libraries(${DEMO_NAME} PUBLIC livox_lidar_sdk_static ) ``` -------------------------------- ### Configure GKlib Installation Prefix Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/metis/GKlib/BUILD.txt Sets a custom installation prefix for GKlib. This allows you to choose a specific directory for installation. ```bash $ make config prefix=~/local ``` -------------------------------- ### MatrixBase set() Example Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/doc/stats.html Shows how to set all elements of a matrix to a specific value using MatrixBase::set(). ```cpp #include int main() { Eigen::MatrixXf mat(2, 3); mat.set(5.0f); std::cout << "Matrix set to 5.0:\n" << mat << std::endl; return 0; } ``` -------------------------------- ### Install Ceres Public Headers Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/CMakeLists.txt Installs Ceres public headers from the source directory to the installation's include directory. ```cmake file(GLOB CERES_HDRS ${Ceres_SOURCE_DIR}/include/ceres/*.h) install(FILES ${CERES_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ceres) ``` -------------------------------- ### Install PDB Files Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/dotnet/NETGeographicLib/CMakeLists.txt This loop iterates through different build configurations (Debug, Release, etc.) and installs the corresponding Program Database (.pdb) files to the 'bin' directory. This is done optionally for each configuration. ```cmake # Install pdb file. foreach (_c ${CMAKE_CONFIGURATION_TYPES}) string (TOUPPER ${_c} _C) get_target_property (_P ${NETGEOGRAPHICLIB_LIBRARIES} LOCATION_${_C}) get_filename_component (_D ${_P} PATH) get_filename_component (_N ${_P} NAME_WE) set (_PDB ${_D}/${_N}.pdb) install (FILES ${_PDB} DESTINATION bin CONFIGURATIONS ${_c} OPTIONAL) endforeach () ``` -------------------------------- ### Setting Installation Directory for JavaScript Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/GeographicLib/js/CMakeLists.txt Determines the installation directory for the JavaScript files based on whether a common install path is defined. ```cmake if (COMMON_INSTALL_PATH) set (INSTALL_JS_DIR "lib${LIB_SUFFIX}/node_modules/geographiclib") else () set (INSTALL_JS_DIR "node_modules/geographiclib") endif () ``` -------------------------------- ### Run logger sample on Ubuntu Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/utilities/livox_ros_driver2/Livox-SDK2/README.md Executes the 'logger' sample program on Ubuntu. Requires navigating to the sample directory and providing a configuration file path. ```shell $ cd samples/logger && ./logger ../../../samples/logger/[config file] ``` -------------------------------- ### Installing Package Configuration Files Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/gtsam/3rdparty/Eigen/CMakeLists.txt Installs the necessary CMake package configuration files (UseEigen3.cmake, Eigen3Config.cmake, Eigen3ConfigVersion.cmake) to the installation directory. ```cmake install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UseEigen3.cmake ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} ) ``` -------------------------------- ### Install Miniglog Header Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/ceres-solver/CMakeLists.txt Installs the miniglog header if miniglog is being used and its include paths appear in installed public Ceres headers. ```cmake if (MINIGLOG) # Install miniglog header if being used as logging #includes appear in # installed public Ceres headers. install(FILES ${Ceres_SOURCE_DIR}/internal/ceres/miniglog/glog/logging.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ceres/internal/miniglog/glog) endif (MINIGLOG) ``` -------------------------------- ### Basic GTSAM Build and Install (Linux/macOS) Source: https://github.com/jizhang-cmu/autonomy_stack_mecanum_wheel_platform/blob/jazzy/src/slam/dependency/gtsam/INSTALL.md Standard commands to build, test, and install GTSAM from the root library folder using an out-of-source build. Includes an optional step to run unit tests. ```sh mkdir build cd build cmake .. make check # (optional, runs unit tests) make install ```