Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Load path file from single location only #3

Merged
merged 1 commit into from
Apr 6, 2022
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
48 changes: 12 additions & 36 deletions pathplannerlib/src/sources.patch
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
--- orig/pathplanner/lib/PathPlanner.cpp 2022-04-03 03:30:25.000000000 -0500
+++ patched/pathplanner/lib/PathPlanner.cpp 2022-04-03 03:30:37.000000000 -0500
@@ -16,18 +16,35 @@
@@ -10,6 +10,8 @@
#include <units/velocity.h>
#include <vector>

+#include <rpy/Filesystem.h>
+
using namespace pathplanner;

double PathPlanner::resolution = 0.004;
@@ -17,7 +19,8 @@ double PathPlanner::resolution = 0.004;
PathPlannerTrajectory PathPlanner::loadPath(std::string name, units::meters_per_second_t maxVel, units::meters_per_second_squared_t maxAccel, bool reversed){
std::string line;
+ wpi::json json;
+
+ std::vector<std::string> prefixes = {
+ frc::filesystem::GetDeployDirectory() + "/pathplanner/",
+ "./",
+ "/home/lvuser/py/"
+ };

- std::string filePath = frc::filesystem::GetDeployDirectory() + "/pathplanner/" + name + ".path";
+ bool fileFound = false;
+ std::string errorMessage = "Cannot open file: \n";

- std::error_code error_code;
- wpi::raw_fd_istream input{filePath, error_code};
+ for(auto prefix : prefixes){
+ std::string filePath = prefix + name + ".path";

- if(error_code){
- throw std::runtime_error(("Cannot open file: " + filePath));
+ std::error_code error_code;
+ wpi::raw_fd_istream input{filePath, error_code};
+
+ if(!error_code){
+ fileFound = true;
+ input >> json;
+ break;
+ }
+ std::string filePath = (robotpy::filesystem::GetDeployDirectoryFs() / "pathplanner" / (name + ".path")).string();
+
+ errorMessage += " - " + filePath + "\n";
}

- wpi::json json;
- input >> json;
+ if(!fileFound){
+ throw std::runtime_error(errorMessage);
+ }

std::vector<PathPlannerTrajectory::Waypoint> waypoints;
for (wpi::json::reference waypoint : json.at("waypoints")){
std::error_code error_code;
wpi::raw_fd_istream input{filePath, error_code};
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"robotpy-build<2023.0.0,>=2022.2.1",
"wpilib<2023.0.0,>=2022.4.1.0",
"wpilib<2023.0.0,>=2022.4.1.6",
"robotpy-wpimath<2023.0.0,>=2022.4.1.3",
]

Expand Down Expand Up @@ -60,5 +60,5 @@ author_email = "[email protected]"
url = "https://github.com/robotpy/robotpy-pathplannerlib"
license = "BSD-3-Clause"
install_requires = [
"wpilib<2023.0.0,>=2022.4.1.0",
"wpilib<2023.0.0,>=2022.4.1.6",
]