KCommand is a command library that adds various utilities, as well as the buildCommand DSL, to the existing WPILib command-based framework. All of the KCommand classes are designed to make coding command-based robots in kotlin a lot nicer and cleaner overall.
Read the wiki to get started with installation and usage.
Important features include:
- BuildCommand DSL: A revolutionary new way to write complex commands.
- Various command extensions, including cleaner RunCommand and InstantCommand syntax.
- Built-in logging of buildCommands, as well as through the LoggedCommand wrapper.
val builtCommand: Command = buildCommand("BuildCommandName", log = true){
require(shooter, groundIntake) // subystem requirements
realRobotOnly {
val value by getOnceDuringRun { arm.getPosition() }
loopUntil({noteObserver.state = State.NoteInShooter}){
shooter.run()
groundIntake.run()
}
}
loopForDuration(0.4){
shooter.run()
groundIntake.run()
}
onEnd {
shooter.setIdle()
groundIntake.setIdle()
}
}
val instantCommand = InstantCommand(drivetrain) {
println("hi")
}
// old syntax
val oldCommand = InstantCommand({
println("hi")
}, drivetrain)
Note: KCommand’s current syntax/features are subject to change, so if you have any suggestions, make sure to message FRC 5160.