Skip to content

Commit

Permalink
[wombat] add pathplanner (#53)
Browse files Browse the repository at this point in the history
* Added skeleton for path planner

* Added pathweaver to wombat

* Fixed errors in pathplanner

* ran wpiformat

---------

Co-authored-by: Paul Hodges <paul.hodges@student.education.wa.edu.au>
  • Loading branch information
spacey-sooty and Superbro525Alt authored Jan 3, 2024
1 parent da92a90 commit b063d97
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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

0 comments on commit b063d97

Please sign in to comment.