Skip to content

Commit

Permalink
Fix MAJOR Notifier Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekma committed Jan 11, 2019
1 parent 56ecff0 commit abbab11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ publishing {
create<MavenPublication>("mavenLocal") {
groupId = "org.ghrobotics"
artifactId = "FalconLibrary"
version = "2019.1.5"
version = "2019.1.10"

from(components["java"])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,21 @@ class TrajectoryTrackerCommand(

private var trajectoryFinished = false

private val notifier = Notifier {
// Get the trajectory follower output.
init {
finishCondition += { trajectoryFinished }
executeFrequency = (1 / dt.second).toInt()
}

/**
* Reset the trajectory follower with the new trajectory.
*/
override suspend fun initialize() {
trajectoryTracker.reset(trajectorySource())
trajectoryFinished = false
LiveDashboard.isFollowingPath = true
}

override suspend fun execute() {
driveBase.setOutput(trajectoryTracker.nextState(driveBase.robotPosition))

val referencePoint = trajectoryTracker.referencePoint
Expand All @@ -44,26 +57,10 @@ class TrajectoryTrackerCommand(
trajectoryFinished = trajectoryTracker.isFinished
}

init {
finishCondition += { trajectoryFinished }
}

/**
* Reset the trajectory follower with the new trajectory.
*/
override suspend fun initialize() {
trajectoryTracker.reset(trajectorySource())
trajectoryFinished = false
LiveDashboard.isFollowingPath = true

notifier.startPeriodic(dt.second)
}

/**
* Make sure that the drivetrain is stopped at the end of the command.
*/
override suspend fun dispose() {
notifier.stop()
driveBase.zeroOutputs()
LiveDashboard.isFollowingPath = false
}
Expand Down

0 comments on commit abbab11

Please sign in to comment.