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

Commit

Permalink
Stop driving forward without any joystick controls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewda committed May 22, 2018
1 parent 3fdcb7e commit a241cce
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ class TeleopDrive : Command() {

override fun execute(): Boolean {
val safe: Double.() -> Double = {
this * (GRADIENT.pow(
val speed = this * (GRADIENT.pow(
Elevator.SCALE_TARGET / (Elevator.SAFE_MAX_TARGET - Elevator.position)
) + MIN_SPEED)

if (speed < GRADIENT) {
if (speed > MIN_SPEED) {
MIN_SPEED
} else speed
} else {
MIN_SPEED
}

This comment has been minimized.

Copy link
@andrewda

andrewda May 22, 2018

Author Member

@evanmyersflow I'm not sure this makes any sense and it could cause severe problems:

Let's pseudocode it:

if speed is less than GRADIENT (i.e. maxSpeed)
    if speed is greater than minSpeed (<--- this part doesn't make sense)
        return minSpeed (<--- if we're going faster than our minimum speed, we should slow down to our minimum speed? this would make sense if that was maxSpeed, not minSpeed)
    else
        return speed
else
    return minSpeed

Also, the only reason we have a MIN_SPEED is so our original equation above makes sense (gotta look at it on Desmos for it to make sense). Not sure if you tested this, but it could be very bad. From what I can simulate in my mind, it would only allow people to go at speeds below MIN_SPEED (which, in that case would better be named MAX_SPEED), but given that MIN_SPEED is so low the robot likely won't move at all. I hope you tested this or will test it (with robot physically moving on the ground, not on a tote) before IHS celebration.

}

when (controlMode) {
Expand All @@ -53,7 +61,7 @@ class TeleopDrive : Command() {
override fun onDestroy() = Drivetrain.stop()

private companion object {
const val GRADIENT = 0.8
const val GRADIENT = 0.80

This comment has been minimized.

Copy link
@andrewda

andrewda May 22, 2018

Author Member

?

const val MIN_SPEED = 0.17
}
}

0 comments on commit a241cce

Please sign in to comment.