ParallelCommandGroup
The ParallelCommandGroup
class runs a group of commands all at the same time. Since the commands in CommandScheduler
are already run in parallel, the primary functional use for this class is to place parallel groups inside SequentialCommandGroups
, like this
val mySequentialCommandGroup: SequentialCommandGroup
get() = sequential {
+FirstCommand()
+SecondCommand()
+parallel {
+FirstParallelCommand()
+SecondParallelCommand()
}
}
The above code will run FirstCommand
until it finishes, then SecondCommand
until it finishes, and then will run both FirstParallelCommand
and SecondParallelCommand
at the same time until they are both finished.
Root
- Extends:
CommandGroup
- Declaration:
class
- Package:
com.atomicrobotics.cflib
Variables
commandsToCancel
- Default Value:
mutableMapOf()
- Type:
MutableMap<Command, Boolean>
- Declaration:
private val
Functions
start()
Starts each command in the list (at the same time)
- Declaration:
override fun
- Parameters: none
- Returns:
Unit
execute()
Starts each command in the list (if it hasn't been started already), then runs its execute()
functionm then adds it to the commandsToCancel
list if it's finished. The reason the commands can't be cancelled right away is because removing an item from a ist while iterating through the list leads to all sorts of problems.
- Declaration:
override fun
- Parameters: none
- Returns:
Unit
clearCommands()
Clears the commands that need to be cancelled. The reason the commands can't be cancelled in the execute
function is because removing items from a list while iterating through the list leads to all sorts of problems.
- Declaration:
private fun
- Parameters: none
- Returns:
Unit
Definition in com.atomicrobotics.cflib/CommandGroup.kt