Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wombat] add pathplanner #53

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions wombat/src/main/cpp/utils/Pathplanner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#include "utils/Pathplanner.h"

using namespace wom;

utils::Pathplanner::Pathplanner() {}

frc::Trajectory utils::Pathplanner::getTrajectory(std::string_view path) {
try {
fs::path path_location = deploy_directory / path;
return frc::TrajectoryUtil::FromPathweaverJson(path_location.string());
} catch (std::exception& e) {
return getTrajectory(path);
}
}
25 changes: 25 additions & 0 deletions wombat/src/main/include/utils/Pathplanner.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2023-2024 CurtinFRC
// Open Source Software, you can modify it according to the terms
// of the MIT License at the root of this project

#pragma once

#include <frc/Filesystem.h>
#include <frc/trajectory/TrajectoryUtil.h>
#include <wpi/fs.h>

#include "utils/Util.h"

namespace wom {
namespace utils {
class Pathplanner {
public:
Pathplanner();

frc::Trajectory getTrajectory(std::string_view path);

private:
fs::path deploy_directory = frc::filesystem::GetDeployDirectory();
};
} // namespace utils
} // namespace wom