Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

Commit

Permalink
Allow FixedDrive to be continuous (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewda authored and SUPERCILEX committed Jan 30, 2018
1 parent 52a7c7d commit 5a339b7
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ import org.sertain.command.Command
class FixedDrive : Command {
private val leftSpeed: Double
private val rightSpeed: Double
private val continuous: Boolean

/**
* Sets both sides of the drivetrain to the same [speed].
*
* @param speed the speed at which to set both sides of the drivetrain
* @param continuous whether the command should be run continuously until interrupted
*/
constructor(speed: Double) : super() {
constructor(speed: Double, continuous: Boolean = false) : super() {
leftSpeed = speed
rightSpeed = speed
this.continuous = continuous
}

/**
* Sets the left and right sides of the drivetrain to different speeds.
*
* @param leftSpeed the speed at which to set the left side of the drivetrain
* @param rightSpeed the speed at which to set the right side of the drivetrain
* @param continuous whether the command should be run continuously until interrupted
*/
constructor(leftSpeed: Double, rightSpeed: Double) : super() {
constructor(leftSpeed: Double, rightSpeed: Double, continuous: Boolean = false) : super() {
this.leftSpeed = leftSpeed
this.rightSpeed = rightSpeed
this.continuous = continuous
}

init {
Expand All @@ -37,6 +42,6 @@ class FixedDrive : Command {

override fun execute(): Boolean {
Drivetrain.tank(leftSpeed, rightSpeed)
return true
return !continuous
}
}

0 comments on commit 5a339b7

Please sign in to comment.