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

Commit

Permalink
Reduce macro usage in OptimalTrajectoryGenerator.cpp (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul authored Jun 19, 2024
1 parent c54d877 commit ff475a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion include/trajopt/OptimalTrajectoryGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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

Expand Down
17 changes: 7 additions & 10 deletions src/OptimalTrajectoryGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@

#include "trajopt/OptimalTrajectoryGenerator.h"

#include <stdint.h>

#include "trajopt/expected"
#include "trajopt/path/SwervePathBuilder.h"

#if defined(OPTIMIZER_BACKEND_CASADI)
#include "optimization/CasADiOpti.h"
#define _OPTI_BACKEND casadi::MX, CasADiOpti
#elif defined(OPTIMIZER_BACKEND_SLEIPNIR)
#include "optimization/SleipnirOpti.h"
#define _OPTI_BACKEND SleipnirExpr, SleipnirOpti
#endif
#include "trajopt/drivetrain/SwerveDrivetrain.h"

#include "optimization/algorithms/SwerveDiscreteOptimal.h"
#include "trajopt/solution/SwerveSolution.h"

namespace trajopt {

expected<SwerveSolution, std::string> OptimalTrajectoryGenerator::Generate(
const SwervePathBuilder& path, bool diagnostics, int64_t handle) {
SwerveDiscreteOptimal<_OPTI_BACKEND> problem(
#if defined(OPTIMIZER_BACKEND_CASADI)
SwerveDiscreteOptimal<casadi::MX, CasADiOpti> problem(
#elif defined(OPTIMIZER_BACKEND_SLEIPNIR)
SwerveDiscreteOptimal<SleipnirExpr, SleipnirOpti> problem(
#endif
path.GetPath(), path.GetControlIntervalCounts(),
path.CalculateInitialGuess(), handle);
return problem.Generate(diagnostics);
}

} // namespace trajopt

0 comments on commit ff475a6

Please sign in to comment.