diff --git a/.github/workflows/trajoptlib-cpp.yml b/.github/workflows/trajoptlib-cpp.yml index e12e46012..b6d44ef71 100644 --- a/.github/workflows/trajoptlib-cpp.yml +++ b/.github/workflows/trajoptlib-cpp.yml @@ -67,6 +67,10 @@ jobs: working-directory: trajoptlib - run: cmake --install build --config RelWithDebInfo --prefix pkg working-directory: trajoptlib + - run: ./build/Swerve + working-directory: trajoptlib + - run: ./build/Differential + working-directory: trajoptlib - uses: actions/upload-artifact@v4 with: diff --git a/trajoptlib/examples/Differential/src/Main.cpp b/trajoptlib/examples/Differential/src/Main.cpp index 1828345c0..4243d9cef 100644 --- a/trajoptlib/examples/Differential/src/Main.cpp +++ b/trajoptlib/examples/Differential/src/Main.cpp @@ -2,8 +2,11 @@ #include +#include #include +#include "fmt/base.h" + // DifferentialPathBuilder is used to build paths that are optimized into full // trajectories. // @@ -36,8 +39,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 1: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 2: Differential, basic curve @@ -51,8 +60,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 2: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 3: Differential, three waypoints @@ -67,8 +82,14 @@ int main() { path.ControlIntervalCounts({50, 50}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 3: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 4: Differential, ending velocity @@ -81,8 +102,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 4: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 5: Differential, circle obstacle @@ -100,8 +127,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 5: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 6: Approach a pick up station at a certain direction @@ -136,8 +169,14 @@ int main() { path.ControlIntervalCounts({40, 30, 30, 40}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 6: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 7: Circular path with a point-point constraint @@ -167,7 +206,13 @@ int main() { path.ControlIntervalCounts({50}); trajopt::DifferentialTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 7: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } } diff --git a/trajoptlib/examples/Swerve/src/Main.cpp b/trajoptlib/examples/Swerve/src/Main.cpp index c43f95978..e8e972ceb 100644 --- a/trajoptlib/examples/Swerve/src/Main.cpp +++ b/trajoptlib/examples/Swerve/src/Main.cpp @@ -36,8 +36,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 1: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 2: Swerve, basic curve @@ -51,8 +57,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 2 {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 3: Swerve, three waypoints @@ -67,8 +79,14 @@ int main() { path.ControlIntervalCounts({40, 40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 3 {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 4: Swerve, ending velocity @@ -81,8 +99,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 4: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 5: Swerve, circle obstacle @@ -100,8 +124,14 @@ int main() { path.ControlIntervalCounts({40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 5: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 6: Approach a pick up station at a certain direction @@ -136,8 +166,14 @@ int main() { path.ControlIntervalCounts({40, 30, 30, 40}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 6: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } // Example 7: Circular path with a point-point constraint @@ -167,7 +203,13 @@ int main() { path.ControlIntervalCounts({30}); trajopt::SwerveTrajectoryGenerator generator{path}; - [[maybe_unused]] auto solution = generator.Generate(true); + if (!(solution.error() == sleipnir::SolverExitCondition::kSuccess || + solution.error() == + sleipnir::SolverExitCondition::kSolvedToAcceptableTolerance)) { + fmt::println("Error in example 7: {}", + sleipnir::ToMessage(solution.error())); + return static_cast(solution.error()); + } } }