TeamMeanMachine / meanlib

A Kotlin FRC library
The Unlicense
16 stars 3 forks source link

Update for new TimedRobot #7

Closed andrewda closed 5 years ago

andrewda commented 5 years ago

https://github.com/wpilibsuite/allwpilib/blob/master/wpilibj/src/main/java/edu/wpi/first/wpilibj/TimedRobot.java

There are no longer any calls to ds.waitForData(). Instead, ds.waitForData() seems to have been replaced by a Notifier alarm every 20ms. Incorporating this change will likely make simulations work properly.

tylerscheuble commented 5 years ago

The reason ds.waitForData() is used in the main loop is because the main loop's job is to react to new DS data (currently for changing the robot state and processing joystick button mappings). Unlike the main loop, TimedRobot has the additional job of running your robot program at a consistent period. With the meanlib framework that is supposed to be done in separate coroutines with periodic blocks.

Do simulations not work properly as is? If the current main loop is incompatible with simulations then that is a problem.

andrewda commented 5 years ago

Makes sense. WPILib just fixed the notifyNewData simulating here: https://github.com/wpilibsuite/allwpilib/commit/e97e7a76119ce4c824587a01b397bf504977e7f9. In the mean time, before 2019.1.2 is released, we can simulate new driverstation data with: DriverStationDataJNI.notifyNewData().