githubEdit

RetryCommand

package com.skeletonarmy.marrow.<command_library>

Overview

RetryCommand is a powerful command for building adaptable and reliable command sequences. It executes a command and, if the specified condition is not met upon completion, automatically retries up to the specified amount of times.

This is especially useful for actions that may fail on the first attempt, such as vision-based alignment, object grabbing, or precise mechanism positioning.

Check out the "Retries" page to learn how to use RetryCommand for autonomous behaviors.

circle-info

Available in:

🟢 SolversLibarrow-up-right - included natively (Marrow not required) 🟠 FTCLibarrow-up-right - provided through Marrow 🟠 NextFTCarrow-up-right - provided through Marrow


Usage

Setup

To use RetryCommand, you need to provide the constructor with:

  • Command to run - the initial action you want to execute.

  • (Optional) Alternative command to run on retries - lets you customize the retry behavior per attempt (e.g., switching to a vision-assisted command if the initial attempt fails).

  • Success condition - a boolean supplier that checks whether the action was successful. If this condition returns false, the command will be retried.

  • Maximum number of retries - defines the maximum number of times the command can be retried.

new RetryCommand(
    new GrabCommand(claw),   // Command to run.
    () -> claw.isGrabbed(),  // If this condition is false
    5                        // retry up to 5 times.
)

Or with an alternative retry command:


Example Usage

Here’s an example autonomous that uses RetryCommand together with SolversLib’s command system:

circle-info

This is by no means a functional autonomous program.


Source Code

You can check out the source code on the GitHub repositoryarrow-up-right.

If you are using an unsupported command-based library and want to implement this command in your codebase, you may do so.

Last updated