Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions async/EventTarget.kt

This file was deleted.

279 changes: 0 additions & 279 deletions async/Promise.kt

This file was deleted.

7 changes: 0 additions & 7 deletions async/Thenable.kt

This file was deleted.

3 changes: 2 additions & 1 deletion controls/ClosedLoopConstantsClasses.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ fun SimpleMotorFeedForwardConstants.toFeedForward() : SimpleMotorFeedforward {
*/
fun PIDConstants.toPID() : Controller.PID {
return Controller.PID(this.P, this.I, this.D)
}
}
val PIDConstants.PathPlannerPID : com.pathplanner.lib.config.PIDConstants get() = com.pathplanner.lib.config.PIDConstants(this.P, this.I, this.D)
1 change: 1 addition & 0 deletions controls/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import edu.wpi.first.math.controller.SimpleMotorFeedforward
* A closed-loop controller controlling a one-dimensional output,
* usually a motor.
*/
@Deprecated("Controller is deprecated, as it is it is just a wrapper for PID controller that provides no functionality")
interface Controller {
var setpoint: Double

Expand Down
1 change: 1 addition & 0 deletions controls/TurningPID.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlin.math.sign
* @author Anthony, Mike
*/
@Suppress("MemberVisibilityCanBePrivate")
@Deprecated("TurningPID is deprecated, use the default WPI PID instead")
class TurningPID(var kP: Double, var kD: Double) {
var setPoint = 0.0
var timePrevious = Timer.getFPGATimestamp()
Expand Down
34 changes: 34 additions & 0 deletions misc/Signals.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package frc.robot.beaverlib.misc

/**
* A MutableMap used specifically for managing Lambdas
* Specified Type is used as the input for argument for listener Lambdas
*/
data class BiSignal<Type, Type2>(
val listeners : MutableMap<String, (Type, Type2) -> Unit> = mutableMapOf()
) {
/**
* Adds a listener with the given name. The function will be run whenever the parent object calls the update function
* @param name String to denote the name of the listener, used to remove specific listeners later on
* @param function The function to run when the listener updates */
fun add(name: String, function: (Type, Type2) -> Unit){
listeners.put(name, function)
}

/**
* Removes a listener with the given name
* @param name The name of the listener to remove */
fun remove(name: String){
listeners.remove(name)
}

/**
* Runs all active listeners with the given input
* @param input The input for each of the listening functions
* */
fun update(input: Type, input2: Type2) {
listeners.forEach { (_, listenerFunction) ->
listenerFunction(input, input2) // Pass source to the listener
}
}
}
Loading