How should we best execute a path planner generated command from within one of our commands?

In cases where we want to produce a ppl command (for a dynamic path from points that are not previously known) in the initialization method of one of our commands, how should we best execute that command. We started with:

ourCmd {
  initialization() {
    make points;
    make path;
    cmd = AutoBuilder.followPath(path);
    cmd.schedule();
  }
  end(...) {
    cmd.cancel();
  }
}

we the bind:
joystick.a().whileTrue(new ourCmd());

Which worked for a while, but after a number of updates fails to call end() when button A is released. The followPath command will run to completion regardless of releasing the button. This is not good for testing with things go awry. So we have shifted to:

ourCmd {
  initialization() {
    make points;
    make path;
    cmd = AutoBuilder.followPath(path);
    cmd.initialize();
  }
  execute(){
    execute();
  }
  end(...) {
    cmd.end();
  }
  isfinished {
    return cmd.isfinished();
  }
}

This works, but… I feel that there should be some better way. I don’t see an AutoBuilder.followPath(Supplier) method.
What is the best practice for doing this?

Thanks,
Rich

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.