Skip to content

Commit

Permalink
fix issues with running scripts/trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
varun7654 committed Jan 7, 2024
1 parent fd1c604 commit 07bca72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -52,6 +53,9 @@ public TrajectoryAutonomousStep(@JsonProperty(required = true, value = "states")
super(closed);
this.reversed = reversed;
this.color = color;
if (controlVectors == null) {
controlVectors = new ArrayList<>();
}
this.controlVectors = controlVectors;
this.rotations = rotations;

Expand Down Expand Up @@ -124,6 +128,7 @@ public boolean execute(@NotNull List<SendableScript> scriptsToExecuteByTime,
.apply(new TrajectoryBuilderInfo(trajectory, this::getTargetRotation));
pathDriveCommand.schedule();
timer.restart();
isFirstRun = false;
}

final double elapsedTime = timer.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ public boolean execute() throws CommandExecutionFailedException, ExecutionExcept
return true;
}

SendableCommand command = executionQueue.peek();
SendableCommand command = executionQueue.pollFirst();


// Keep executing commands until we reach one we need to wait at.
while (command.execute()) {
executionQueue.remove();
if (executionQueue.isEmpty()) {
return true;
}
command = executionQueue.pollFirst();
}

return executionQueue.isEmpty();
Expand Down

0 comments on commit 07bca72

Please sign in to comment.