36
36
37
37
import javafx .beans .property .BooleanProperty ;
38
38
import javafx .beans .property .ObjectProperty ;
39
+ import javafx .beans .property .ReadOnlyBooleanProperty ;
39
40
import javafx .beans .property .SimpleBooleanProperty ;
40
41
import javafx .beans .property .SimpleObjectProperty ;
41
42
import javafx .beans .value .ObservableValue ;
@@ -409,9 +410,16 @@ protected Task<HolonomicTrajectory> createTask() {
409
410
Task <HolonomicTrajectory > optimizeTask = new Task <HolonomicTrajectory >() {
410
411
@ Override
411
412
protected HolonomicTrajectory call () throws PluginLoadException , InvalidPathException , TrajectoryGenerationException {
413
+ // Thread generationThread = Thread.currentThread();
412
414
System .out .println ("Path optimizing: " + path .toString ());
413
415
if (drive != null && path != null ) {
414
- return OptimalTrajectoryGenerator .generate (drive , path );
416
+ // new Thread(() -> {
417
+ // while (!isCancelled()) {}
418
+ // generationThread.stop();
419
+ // }).start();
420
+ HolonomicTrajectory traj = OptimalTrajectoryGenerator .generate (drive , path );
421
+ System .out .println ("Generation complete, closing task..." );
422
+ return traj ;
415
423
} else {
416
424
throw new TrajectoryGenerationException ("No path specified for optimization service." );
417
425
}
@@ -423,6 +431,7 @@ protected HolonomicTrajectory call() throws PluginLoadException, InvalidPathExce
423
431
}
424
432
425
433
private static final TrajectoryGenerationService SERVICE = new TrajectoryGenerationService ();
434
+ public static final ReadOnlyBooleanProperty IS_GENERATION_RUNNING = SERVICE .runningProperty ();
426
435
public void generateTrajectory () {
427
436
if (documentManager .getIsDocumentOpen () && documentManager .getDocument ().isPathSelected ()) {
428
437
HDocument hDocument = documentManager .getDocument ();
@@ -444,15 +453,20 @@ public void generateTrajectory() {
444
453
}
445
454
}
446
455
}
447
- public void toggleTrajectoryGeneration () {
448
- if (SERVICE .isRunning ()) {
449
- System .out .println ("Cancelling trajopt" );
450
- SERVICE .cancel ();
451
- } else {
452
- System .out .println ("Restarting trajopt" );
453
- generateTrajectory ();
454
- }
455
- }
456
+ // public void toggleTrajectoryGeneration() {
457
+ // if (SERVICE.isRunning()) {
458
+ // System.out.println("Cancelling trajopt");
459
+ // SERVICE.cancel();
460
+ // } else {
461
+ // System.out.println("Restarting trajopt");
462
+ // generateTrajectory();
463
+ // }
464
+ // }
465
+ // public void cancelTrajectoryGeneration() {
466
+ // if (SERVICE.isRunning()) {
467
+ // SERVICE.cancel();
468
+ // }
469
+ // }
456
470
457
471
private static final Rotate ROTATE_90_CLOCKWISE = new Rotate (-90 );
458
472
private static final Rotate ROTATE_90_COUNTERCLOCKWISE = new Rotate (90 );
0 commit comments