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

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/manifold-robo…
Browse files Browse the repository at this point in the history
…t-heading
  • Loading branch information
shueja committed Jun 22, 2024
2 parents 37bf127 + 988bef6 commit 15437af
Show file tree
Hide file tree
Showing 71 changed files with 544 additions and 936 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build.yml → .github/workflows/build-cpp.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build C++

on: [pull_request, push]

Expand All @@ -13,23 +13,19 @@ jobs:
fail-fast: false
matrix:
include:
- artifact-name: Native - Windows x86_64 (Sleipnir)
- artifact-name: Windows x86_64
# FIXME: Tests give "Exit code 0xc0000135" for missing DLLs
cmake-args: "-DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_TESTING=OFF"
optimizer_backend: sleipnir
os: windows-2022
- artifact-name: Native - Windows aarch64 (Sleipnir)
- artifact-name: Windows aarch64
# FIXME: Tests give "Exit code 0xc0000135" for missing DLLs
cmake-args: "-DCMAKE_GENERATOR_PLATFORM=ARM64 -DBUILD_TESTING=OFF"
optimizer_backend: sleipnir
os: windows-2022
- artifact-name: Native - macOS universal (Sleipnir)
- artifact-name: macOS universal
cmake-args: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
optimizer_backend: sleipnir
os: macOS-14
- artifact-name: Native - Linux x86_64 (Sleipnir)
- artifact-name: Linux x86_64
cmake-args:
optimizer_backend: sleipnir
os: ubuntu-24.04

name: "${{ matrix.artifact-name }}"
Expand All @@ -47,7 +43,7 @@ jobs:
- run: sudo xcode-select -switch /Applications/Xcode_15.3.app
if: startsWith(matrix.os, 'macOS')

- run: cmake -B build -S . -DBUILD_EXAMPLES=ON ${{ matrix.cmake-args }} -DOPTIMIZER_BACKEND=${{ matrix.optimizer_backend }}
- run: cmake -B build -S . -DBUILD_EXAMPLES=ON ${{ matrix.cmake-args }}
- run: cmake --build build --config RelWithDebInfo --parallel 4
- run: ctest --test-dir build -C RelWithDebInfo --output-on-failure
- run: cmake --install build --config RelWithDebInfo --prefix pkg
Expand Down
31 changes: 11 additions & 20 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,21 @@ jobs:
fail-fast: false
matrix:
include:
- artifact-name: Rust Native - Windows x86_64 (Sleipnir)
optimizer_backend: sleipnir
- artifact-name: Windows x86_64
os: windows-2022
cmake-env:
cargo-build-flags:
- artifact-name: Rust Native - Windows aarch64 (Sleipnir)
optimizer_backend: sleipnir
- artifact-name: Windows aarch64
os: windows-2022
cmake-env:
cargo-build-flags: --target aarch64-pc-windows-msvc
- artifact-name: Rust Native - macOS universal (Sleipnir)
optimizer_backend: sleipnir
- artifact-name: macOS universal
os: macOS-14
cmake_env:
cargo-build-flags:
- artifact-name: Rust Native - Linux x86_64 (Sleipnir)
optimizer_backend: sleipnir
- artifact-name: Linux x86_64
os: ubuntu-24.04
cmake-env:
cargo-build-flags:
- artifact-name: Rust Native - Linux aarch64 (Sleipnir)
optimizer_backend: sleipnir
- artifact-name: Linux aarch64
os: ubuntu-24.04
cmake-env:
cargo-build-flags: --target aarch64-unknown-linux-gnu

name: "${{ matrix.artifact-name }}"
Expand All @@ -46,11 +37,11 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Windows aarch64 Rust compiler
if: matrix.artifact-name == 'Rust Native - Windows aarch64 (Sleipnir)'
if: matrix.artifact-name == 'Windows aarch64'
run: rustup target install aarch64-pc-windows-msvc

- name: Set up Linux aarch64 Rust compiler
if: matrix.artifact-name == 'Rust Native - Linux aarch64 (Sleipnir)'
if: matrix.artifact-name == 'Linux aarch64'
run: |
sudo apt-get update -q
sudo apt-get install -y g++-14-aarch64-linux-gnu
Expand All @@ -67,8 +58,8 @@ jobs:
- run: sudo xcode-select -switch /Applications/Xcode_15.3.app
if: startsWith(matrix.os, 'macOS')

- run: ${{matrix.cmake-env }} cargo build ${{ matrix.cargo-build-flags }} --features ${{ matrix.optimizer_backend }}
- run: cargo build ${{ matrix.cargo-build-flags }}

- run: cargo run --example swerve --features ${{ matrix.optimizer_backend }}
if: matrix.artifact-name != 'Rust Native - Windows aarch64 (Sleipnir)' &&
matrix.artifact-name != 'Rust Native - Linux aarch64 (Sleipnir)'
- run: cargo run --example swerve
if: matrix.artifact-name != 'Windows aarch64' &&
matrix.artifact-name != 'Linux aarch64'
2 changes: 1 addition & 1 deletion .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ jobs:
- run: cargo fmt --check

- run: cargo clippy --features sleipnir -- -D warnings
- run: cargo clippy -- -D warnings
7 changes: 2 additions & 5 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ jobs:
include:
- sanitizer-name: asan
cmake-args: "-DCMAKE_BUILD_TYPE=Asan"
optimizer_backend: sleipnir
- sanitizer-name: tsan
cmake-args: "-DCMAKE_BUILD_TYPE=Tsan"
optimizer_backend: sleipnir
- sanitizer-name: ubsan
cmake-args: "-DCMAKE_BUILD_TYPE=Ubsan"
optimizer_backend: sleipnir

name: "${{ matrix.sanitizer-name }} with ${{ matrix.optimizer_backend }}"
name: ${{ matrix.sanitizer-name }}
runs-on: ubuntu-24.04

steps:
Expand All @@ -34,6 +31,6 @@ jobs:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 200
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 200
- run: cmake -B build -S . -DBUILD_EXAMPLES=ON ${{ matrix.cmake-args }} -DOPTIMIZER_BACKEND=${{ matrix.optimizer_backend }}
- run: cmake -B build -S . -DBUILD_EXAMPLES=ON ${{ matrix.cmake-args }}
- run: cmake --build build --config RelWithDebInfo --parallel $(nproc)
- run: ctest --test-dir build -C RelWithDebInfo --output-on-failure
1 change: 0 additions & 1 deletion .styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ modifiableFileExclude {

includeOtherLibs {
^Eigen/
^casadi/
^sleipnir/
^trajopt/
}
47 changes: 19 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,36 +94,27 @@ if(BUILD_TESTING)
fetchcontent_makeavailable(Catch2)
endif()

set(OPTIMIZER_BACKEND "sleipnir" CACHE STRING "Optimizer backend")
set_property(CACHE OPTIMIZER_BACKEND PROPERTY STRINGS sleipnir)

if(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
message(STATUS "Using Sleipnir optimizer")

set(BUILD_TESTING_SAVE ${BUILD_TESTING})
set(BUILD_EXAMPLES_SAVE ${BUILD_EXAMPLES})

set(BUILD_TESTING OFF)
set(BUILD_EXAMPLES OFF)

fetchcontent_declare(
Sleipnir
GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir.git
# main on 2024-06-18
GIT_TAG affeafcd797ad1312b18172dbaed0a69cca6546e
PATCH_COMMAND
git apply
${CMAKE_CURRENT_SOURCE_DIR}/cmake/0001-Downgrade-to-C-20.patch
UPDATE_DISCONNECTED 1
)
fetchcontent_makeavailable(Sleipnir)
set(BUILD_TESTING_SAVE ${BUILD_TESTING})
set(BUILD_EXAMPLES_SAVE ${BUILD_EXAMPLES})

set(BUILD_TESTING OFF)
set(BUILD_EXAMPLES OFF)

fetchcontent_declare(
Sleipnir
GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir.git
# main on 2024-06-20
GIT_TAG b060d361b68d23a6499ebd9d08560c073dfac462
PATCH_COMMAND
git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/0001-Downgrade-to-C-20.patch
UPDATE_DISCONNECTED 1
)
fetchcontent_makeavailable(Sleipnir)

set(BUILD_TESTING ${BUILD_TESTING_SAVE})
set(BUILD_EXAMPLES ${BUILD_EXAMPLES_SAVE})
set(BUILD_TESTING ${BUILD_TESTING_SAVE})
set(BUILD_EXAMPLES ${BUILD_EXAMPLES_SAVE})

target_compile_definitions(TrajoptLib PRIVATE OPTIMIZER_BACKEND_SLEIPNIR)
target_link_libraries(TrajoptLib PRIVATE Sleipnir)
endif()
target_link_libraries(TrajoptLib PUBLIC Sleipnir)

target_include_directories(
TrajoptLib
Expand Down
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,5 @@ serde_json = "1.0"
cxx-build = "1.0"
cmake = "0.1"

[features]
default = []
sleipnir = []

[[example]]
name = "swerve"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ On Windows, open a [Developer PowerShell](https://learn.microsoft.com/en-us/visu
git clone [email protected]:SleipnirGroup/TrajoptLib
cd TrajoptLib

# Configure with Sleipnir backend; automatically downloads library dependencies
cmake -B build -S . -DOPTIMIZER_BACKEND=sleipnir
# Configure
cmake -B build -S .

# Build
cmake --build build
Expand Down Expand Up @@ -78,5 +78,5 @@ On Windows, open a [Developer PowerShell](https://learn.microsoft.com/en-us/visu
git clone [email protected]:SleipnirGroup/TrajoptLib
cd TrajoptLib

cargo build --features sleipnir # Sleipnir backend
cargo build
```
24 changes: 8 additions & 16 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ fn main() {
.profile("Release")
.define("BUILD_TESTING", "OFF");

if cfg!(feature = "sleipnir") {
cmake_config.define("BUILD_SHARED_LIBS", "OFF");

if cfg!(target_os = "windows") {
cmake_config
.define("OPTIMIZER_BACKEND", "sleipnir")
.define("BUILD_SHARED_LIBS", "OFF");

if cfg!(target_os = "windows") {
cmake_config
.generator("Visual Studio 17 2022")
.cxxflag("/EHsc");
}
} else {
panic!("Select an optimizer backend via cargo `--features sleipnir`.");
.generator("Visual Studio 17 2022")
.cxxflag("/EHsc");
}

let cmake_dest = cmake_config.build();
Expand All @@ -43,12 +37,10 @@ fn main() {
);
println!("cargo:rustc-link-lib=trajoptrust");
println!("cargo:rustc-link-lib=TrajoptLib");
if cfg!(feature = "sleipnir") {
println!("cargo:rustc-link-lib=Sleipnir");
println!("cargo:rustc-link-lib=fmt");
}
println!("cargo:rustc-link-lib=Sleipnir");
println!("cargo:rustc-link-lib=fmt");

println!("cargo:rerun-if-changed=src/trajoptlibrust.h");
println!("cargo:rerun-if-changed=src/trajoptlibrust.hpp");
println!("cargo:rerun-if-changed=src/trajoptlibrust.cpp");
println!("cargo:rerun-if-changed=src/lib.rs");
}
24 changes: 12 additions & 12 deletions examples/Swerve/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
#include <numbers>
#include <vector>

#include <trajopt/OptimalTrajectoryGenerator.h>
#include <trajopt/constraint/Constraint.h>
#include <trajopt/constraint/TranslationConstraint.h>
#include <trajopt/constraint/holonomic/HolonomicConstraint.h>
#include <trajopt/drivetrain/SwerveDrivetrain.h>
#include <trajopt/obstacle/Obstacle.h>
#include <trajopt/path/InitialGuessPoint.h>
#include <trajopt/path/Path.h>
#include <trajopt/path/SwervePathBuilder.h>
#include <trajopt/set/ConeSet2d.h>
#include <trajopt/solution/SwerveSolution.h>
#include <trajopt/trajectory/HolonomicTrajectory.h>
#include <trajopt/OptimalTrajectoryGenerator.hpp>
#include <trajopt/constraint/Constraint.hpp>
#include <trajopt/constraint/TranslationConstraint.hpp>
#include <trajopt/constraint/holonomic/HolonomicConstraint.hpp>
#include <trajopt/drivetrain/SwerveDrivetrain.hpp>
#include <trajopt/obstacle/Obstacle.hpp>
#include <trajopt/path/InitialGuessPoint.hpp>
#include <trajopt/path/Path.hpp>
#include <trajopt/path/SwervePathBuilder.hpp>
#include <trajopt/set/ConeSet2d.hpp>
#include <trajopt/solution/SwerveSolution.hpp>
#include <trajopt/trajectory/HolonomicTrajectory.hpp>

int main() {
using namespace trajopt;
Expand Down
1 change: 0 additions & 1 deletion include/.styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ modifiableFileExclude {

includeOtherLibs {
^Eigen/
^casadi/
^sleipnir/
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#include <string>

#include "trajopt/SymbolExports.h"
#include "trajopt/expected"
#include "trajopt/path/SwervePathBuilder.h"
#include "trajopt/solution/SwerveSolution.h"
#include "trajopt/path/SwervePathBuilder.hpp"
#include "trajopt/solution/SwerveSolution.hpp"
#include "trajopt/util/SymbolExports.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include "trajopt/SymbolExports.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/set/IntervalSet1d.hpp"
#include "trajopt/util/SymbolExports.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include <variant>

#include "trajopt/constraint/HeadingConstraint.h"
#include "trajopt/constraint/LinePointConstraint.h"
#include "trajopt/constraint/PointLineConstraint.h"
#include "trajopt/constraint/PointPointConstraint.h"
#include "trajopt/constraint/TranslationConstraint.h"
#include "trajopt/constraint/HeadingConstraint.hpp"
#include "trajopt/constraint/LinePointConstraint.hpp"
#include "trajopt/constraint/PointLineConstraint.hpp"
#include "trajopt/constraint/PointPointConstraint.hpp"
#include "trajopt/constraint/TranslationConstraint.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include "trajopt/SymbolExports.h"
#include "trajopt/set/ManifoldIntervalSet2d.h"
#include "trajopt/SymbolExports.hpp"
#include "trajopt/set/ManifoldIntervalSet2d.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include "trajopt/SymbolExports.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/set/IntervalSet1d.hpp"
#include "trajopt/util/SymbolExports.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include "trajopt/SymbolExports.h"
#include "trajopt/util/SymbolExports.hpp"

namespace trajopt {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include "trajopt/SymbolExports.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/set/IntervalSet1d.hpp"
#include "trajopt/util/SymbolExports.hpp"

namespace trajopt {

Expand Down
Loading

0 comments on commit 15437af

Please sign in to comment.