Closed msoucy closed 7 years ago
(Copied from the depths of the pull review)
I found the SubsystemCommand class to be very helpful when playing with WPILib in F#. It might seem hacky, but I personally feel that it's actually more hacky to have the Requires as a separate step. Example:
type Drive() =
inherit Subsystem()
// remaining setup, as needed
override drive.InitDefaultCommand() =
let cmd = {
new SubsystemCommand(drive, "TurnZero") with
override cmd.Initialize() = cmd.m_subsystem.ResetGyro()
override cmd.Execute() = cmd.m_subsystem.TurnAngle(0.0)
override cmd.IsFinished() = Math.Abs(cmd.m_subsystem.AngleError) < 0.1
override cmd.End() = cmd.m_subsystem.StopMotors()
override cmd.Interrupted() = cmd.End()
}
drive.SetDefaultCommand(cmd)
Admittedly, in my actual practice, instead of cmd.m_subsystem I used drive because the scoping rules are a bit different, but adding the Subsystem reference as m_subsystem was an afterthought from when I was porting it back to C#
Codecov Report
0% <ø> (ø)
0% <ø> (ø)
Continue to review full report at Codecov.