This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge OptimalTrajectoryGenerator and SwerveDiscreteOptimal classes
The geometry classes now overload operator== to produce equality constraints.
- Loading branch information
Showing
31 changed files
with
1,083 additions
and
1,184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) TrajoptLib contributors | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
#include <functional> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <sleipnir/optimization/OptimizationProblem.hpp> | ||
|
||
#include "trajopt/path/SwervePathBuilder.hpp" | ||
#include "trajopt/solution/SwerveSolution.hpp" | ||
#include "trajopt/util/SymbolExports.hpp" | ||
#include "trajopt/util/expected" | ||
|
||
namespace trajopt { | ||
|
||
/** | ||
* This trajectory generator class contains functions to generate | ||
* time-optimal trajectories for several drivetrain types. | ||
*/ | ||
class TRAJOPT_DLLEXPORT SwerveTrajectoryGenerator { | ||
public: | ||
/** | ||
* Construct a new swerve trajectory optimization problem. | ||
* | ||
* @param pathBuilder The path builder. | ||
* @param handle An identifier for state callbacks. | ||
*/ | ||
explicit SwerveTrajectoryGenerator(const SwervePathBuilder& pathBuilder, | ||
int64_t handle = 0); | ||
|
||
/** | ||
* Generates an optimal trajectory. | ||
* | ||
* This function may take a long time to complete. | ||
* | ||
* @param diagnostics Enables diagnostic prints. | ||
* @return Returns a holonomic trajectory on success, or a string containing a | ||
* failure reason. | ||
*/ | ||
expected<SwerveSolution, std::string> Generate(bool diagnostics = false); | ||
|
||
private: | ||
/** | ||
* The swerve drivetrain. | ||
*/ | ||
SwervePath path; | ||
|
||
/// State Variables | ||
std::vector<sleipnir::Variable> x; | ||
std::vector<sleipnir::Variable> y; | ||
std::vector<sleipnir::Variable> thetacos; | ||
std::vector<sleipnir::Variable> thetasin; | ||
std::vector<sleipnir::Variable> vx; | ||
std::vector<sleipnir::Variable> vy; | ||
std::vector<sleipnir::Variable> omega; | ||
std::vector<sleipnir::Variable> ax; | ||
std::vector<sleipnir::Variable> ay; | ||
std::vector<sleipnir::Variable> alpha; | ||
|
||
/// Input Variables | ||
std::vector<std::vector<sleipnir::Variable>> Fx; | ||
std::vector<std::vector<sleipnir::Variable>> Fy; | ||
|
||
/// Time Variables | ||
std::vector<sleipnir::Variable> dt; | ||
|
||
/// Discretization Constants | ||
std::vector<size_t> N; | ||
|
||
sleipnir::OptimizationProblem problem; | ||
std::vector<std::function<void()>> callbacks; | ||
|
||
void ApplyInitialGuess(const SwerveSolution& solution); | ||
|
||
SwerveSolution ConstructSwerveSolution(); | ||
}; | ||
|
||
} // namespace trajopt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.