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

Commit

Permalink
Fix test compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Feb 16, 2024
1 parent 299aea8 commit 8879766
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
rust-target: x86_64-apple-darwin

- artifact-name: Rust Native - macOS arm64 (CasADi)
os: macOS-13
os: macOS-14
rust-target: aarch64-apple-darwin

- artifact-name: Rust Native - Linux x86_64 (CasADi)
Expand All @@ -47,7 +47,7 @@ jobs:
targets: ${{matrix.rust-target}}

- name: Set up Clang
if: matrix.os != 'macOS-13'
if: !startsWith(matrix.os, 'macOS')
uses: egor-tensin/setup-clang@v1
with:
version: latest
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
optimizer: casadi
os: windows-2022
- artifact-name: Native - macOS x86_64 (CasADi)
cmake-config-env-vars: CFLAGS="$CFLAGS -arch x86_64" CXXFLAGS="$CXXFLAGS -arch x86_64"
cmake-config-env-vars:
cmake-flags: "-DCMAKE_APPLE_SILICON_PROCESSOR=x86_64"
optimizer: casadi
os: macOS-13
- artifact-name: Native - macOS arm64 (CasADi)
cmake-config-env-vars: CFLAGS="$CFLAGS -arch arm64" CXXFLAGS="$CXXFLAGS -arch arm64"
cmake-config-env-vars:
cmake-flags: "-DCMAKE_APPLE_SILICON_PROCESSOR=arm64"
optimizer: casadi
os: macOS-13
os: macOS-14
- artifact-name: Native - Linux (CasADi)
cmake-config-env-vars:
cmake-flags:
Expand All @@ -37,11 +37,16 @@ jobs:
cmake-flags:
optimizer: sleipnir
os: windows-2022
- artifact-name: Native - macOS universal (Sleipnir)
cmake-config-env-vars: CFLAGS="$CFLAGS -arch x86_64 -arch arm64" CXXFLAGS="$CXXFLAGS -arch x86_64 -arch arm64"
- artifact-name: Native - macOS x86_64 (Sleipnir)
cmake-config-env-vars:
cmake-flags:
optimizer: sleipnir
os: macOS-13
- artifact-name: Native - macOS arm64 (Sleipnir)
cmake-config-env-vars:
cmake-flags:
optimizer: sleipnir
os: macOS-14
- artifact-name: Native - Linux (Sleipnir)
cmake-config-env-vars:
cmake-flags:
Expand All @@ -67,6 +72,10 @@ jobs:
- name: build
run: cmake --build build --config RelWithDebInfo --parallel $(nproc)

- name: test
working-directory: build
run: ctest -C RelWithDebInfo --output-on-failure

- name: install
run: cmake --install build --config RelWithDebInfo --prefix pkg

Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,21 @@ include(CMakeDependentOption)
cmake_dependent_option(
BUILD_TESTING
"Enable creation of tests."
OFF
ON
"PROJECT_IS_TOP_LEVEL"
OFF
)
if(BUILD_TESTING)
enable_testing()
include(GoogleTest)
if(
${OPTIMIZER_BACKEND} STREQUAL "casadi"
AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"
AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
)
target_compile_definitions(gtest PUBLIC "_GLIBCXX_USE_CXX11_ABI=0")
target_compile_definitions(gtest_main PUBLIC "_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()

# Build TrajoptLib tests
Expand Down
32 changes: 32 additions & 0 deletions examples/.styleguide
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cppHeaderFileInclude {
\.h$
\.hpp$
\.inc$
}

cppSrcFileInclude {
\.cpp$
}

modifiableFileExclude {
jni/jni\.h$
jni/darwin/jni_md\.h$
jni/linux/jni_md\.h$
jni/win32/jni_md\.h$
\.jar$
}

licenseUpdateExclude {
java/src/main/java/org/team2363/util/DependencyExtractor\.java$
java/src/main/java/org/team2363/util/RuntimeDetector\.java$
java/src/main/java/org/team2363/util/RuntimeLoader\.java$
}

includeOtherLibs {
^Eigen/
^fmt/
^casadi/
^sleipnir/
^trajopt/
^gtest/
}
28 changes: 14 additions & 14 deletions examples/Swerve/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
#include <vector>

#include <fmt/core.h>

#include "trajopt/IncompatibleTrajectoryException.h"
#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/IncompatibleTrajectoryException.h>
#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>

int main() {
using namespace trajopt;

SwerveDrivetrain swerveDrivetrain{.mass = 45,
.moi = 6,
.modules = {{+0.6, +0.6, 0.04, 70, 2},
Expand Down
2 changes: 2 additions & 0 deletions include/trajopt/path/SwervePathBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class TRAJOPT_DLLEXPORT SwervePathBuilder {
* @param heading the heading
*/
void PoseWpt(size_t idx, double x, double y, double heading);

/**
* Create a translation waypoint constraint on the waypoint at the
* provided index, and add an initial guess point with the same translation.
Expand Down Expand Up @@ -123,6 +124,7 @@ class TRAJOPT_DLLEXPORT SwervePathBuilder {
* @param vtheta velocity vector polar angle
*/
void WptVelocityPolar(size_t idx, double vr, double vtheta);

/**
* Specify the required angular velocity of the robot to be zero
* at a waypoint
Expand Down
32 changes: 32 additions & 0 deletions test/.styleguide
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cppHeaderFileInclude {
\.h$
\.hpp$
\.inc$
}

cppSrcFileInclude {
\.cpp$
}

modifiableFileExclude {
jni/jni\.h$
jni/darwin/jni_md\.h$
jni/linux/jni_md\.h$
jni/win32/jni_md\.h$
\.jar$
}

licenseUpdateExclude {
java/src/main/java/org/team2363/util/DependencyExtractor\.java$
java/src/main/java/org/team2363/util/RuntimeDetector\.java$
java/src/main/java/org/team2363/util/RuntimeLoader\.java$
}

includeOtherLibs {
^Eigen/
^fmt/
^casadi/
^sleipnir/
^trajopt/
^gtest/
}
48 changes: 14 additions & 34 deletions test/src/ObstacleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,26 @@
#include <vector>

#include <gtest/gtest.h>
#include <trajopt/OptimalTrajectoryGenerator.h>
#include <trajopt/path/InitialGuessPoint.h>
#include <trajopt/path/SwervePathBuilder.h>

#include "path/InitialGuessPoint.h"
#include "path/SwervePathBuilder.h"

TEST(ObstacleTest, GenerateLinearInitialGuess) {
TEST(ObstacleTest, DISABLED_GenerateLinearInitialGuess) {
using namespace trajopt;

SwerveDrivetrain swerveDrivetrain{.mass = 45,
.moi = 6,
.modules = {{+0.6, +0.6, 0.04, 70, 2},
{+0.6, -0.6, 0.04, 70, 2},
{-0.6, +0.6, 0.04, 70, 2},
{-0.6, -0.6, 0.04, 70, 2}}};

trajopt::SwervePathBuilder path;
path.SetDrivetrain({45, 6,
[{
x : 0.6,
y : 0.6,
wheel_radius : 0.04,
wheel_max_angular_velocity : 70.0,
wheel_max_torque : 2.0,
},
{
x : 0.6,
y : -0.6,
wheel_radius : 0.04,
wheel_max_angular_velocity : 70.0,
wheel_max_torque : 2.0,
},
{
x : -0.6,
y : 0.6,
wheel_radius : 0.04,
wheel_max_angular_velocity : 70.0,
wheel_max_torque : 2.0,
},
{
x : -0.6,
y : -0.6,
wheel_radius : 0.04,
wheel_max_angular_velocity : 70.0,
wheel_max_torque : 2.0,
}]});
path.PoseWpt(0, 0.0, 0.0, 0.0);
path.PoseWpt(1, 2.0, 2.0, 0.0);

const length = 0.7;
constexpr double length = 0.7;
constexpr double width = 0.7;
path.AddBumpers(trajopt::Bumpers{.safetyDistance = 0.1,
.points = {{+length / 2, +width / 2},
{-length / 2, +width / 2},
Expand Down
5 changes: 2 additions & 3 deletions test/src/SwervePathBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <vector>

#include <gtest/gtest.h>

#include "path/InitialGuessPoint.h"
#include "path/SwervePathBuilder.h"
#include <trajopt/path/InitialGuessPoint.h>
#include <trajopt/path/SwervePathBuilder.h>

TEST(SwervePathBuilderTest, GenerateLinearInitialGuess) {
using namespace trajopt;
Expand Down
4 changes: 2 additions & 2 deletions test/src/SwerveTrajoptProblemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <vector>

#include <gtest/gtest.h>
#include <trajopt/path/InitialGuessPoint.h>
#include <trajopt/set/IntervalSet1d.h>

#include "TestOpti.h"
#include "optimization/SwerveTrajoptUtil.h"
#include "optimization/TrajoptUtil.h"
#include "path/InitialGuessPoint.h"
#include "set/IntervalSet1d.h"

TEST(TrajoptUtilTest, ApplyKinematicsConstraints) {
TestOpti opti;
Expand Down
4 changes: 2 additions & 2 deletions test/src/TrajoptUtilTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include <vector>

#include <gtest/gtest.h>
#include <trajopt/path/InitialGuessPoint.h>
#include <trajopt/set/IntervalSet1d.h>

#include "TestOpti.h"
#include "optimization/TrajoptUtil.h"
#include "path/InitialGuessPoint.h"
#include "set/IntervalSet1d.h"

TEST(TrajoptUtilTest, GetIdx) {
auto result0 = trajopt::GetIdx({2, 3}, 0, 0);
Expand Down

0 comments on commit 8879766

Please sign in to comment.