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

Segfault when trying to save a trajectory in CSV or raw format #37

Open
vampjaz opened this issue Feb 17, 2018 · 3 comments
Open

Segfault when trying to save a trajectory in CSV or raw format #37

vampjaz opened this issue Feb 17, 2018 · 3 comments

Comments

@vampjaz
Copy link

vampjaz commented Feb 17, 2018

Trying to make code that saves the trajectory to a file and then reads from that file as a cache. I discovered that the Pathfinder.writeToFile and Pathfinder.writeToCSV methods both cause a segfault during the call to the C++ library. This is running on the roboRio. Here is the crash log.

The path generated just fine, but after, when we try to save it, it crashes.

		Waypoint[] points = new Waypoint[] {
			new Waypoint(-4, -1, Pathfinder.d2r(-45)),
			new Waypoint(-2, -2, 0),
			new Waypoint(0, 0, 0) 
		};

		Trajectory.Config config = 
				new Trajectory.Config(
						Trajectory.FitMethod.HERMITE_CUBIC, 
						Trajectory.Config.SAMPLES_HIGH, 
						0.05, 
						RobotMap.MAX_VELOCITY, 
						2.0, 
						60.0);
		
		File saveFile = new File(RobotMap.TRAJECTORY_CACHE);
		if(saveFile.exists() && !saveFile.isDirectory()) {
			log.add("trajectory file already found, usng cached paths", LOG_LEVEL);
			trajectory = Pathfinder.readFromFile(saveFile);
		} else {
			log.add("trajectory file not found, generating new path", LOG_LEVEL);
			trajectory = Pathfinder.generate(points, config);
			log.add("saving path to cache", LOG_LEVEL);
			Pathfinder.writeToFile(saveFile,trajectory);
		}
vampjaz added a commit to MRT3216/MRT3216-2018-PowerUp that referenced this issue Feb 17, 2018
@JaciBrunning
Copy link
Owner

Does the parent folder you're trying to save to exist?

@vampjaz
Copy link
Author

vampjaz commented Feb 18, 2018

The path we specified was just a filename, so I assume that it would be placed in the same folder as the executing program. Would you recommend an absolute path instead of a relative one?

@JaciBrunning
Copy link
Owner

The files are relative to the executing directory of the program. I would recommend instead using a relative path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants