How do I make a NamedCommand that actually works?

This is my current code


              NamedCommands.registerCommand("CollectNote", CollectorCommands.getSetTargetStateCommand(CollectorConstants.CollectorState.COLLECTING).alongWith(RollerCommands.getSetTargetStateCommand(RollerConstants.RollerState.COLLECTION)).withTimeout(1));


every time it runs this part, the autonomous freezes and doesn’t continue to the next action. How do I make it work?

1 Like

Just to make sure the autonomous just freezes, no errors?

There are no errors. I’m pretty sure the command never stops so the path never continues.

1 Like

Try that. Also you seem to have a lot of command composition. PathPlanner supports defining command composition in the GUI.

I don’t know how to fix it to make it stop after a few seconds. I tried adding the .withTimeout() but it didn’t work.

Maybe try replacing the command with another one (like one that just prints “hi”), and see if the auto still doesn’t work. This isn’t really a solution, just trying to find a cause.

.alongWith makes the commands run in parallel. I think the .withTimeout is only impacting 1 of the 2 commands you are running parallel.

2 Likes

I think this was the problem. I split it into 2 commands and it looks like it’s working now

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