DeepBlueRobotics / RobotCode2018

All of our code for FRC's 2018 game: FIRST Power Up.
5 stars 11 forks source link

Why IterativeRobot instead of the new TimedRobot base class? #13

Closed brettle closed 6 years ago

brettle commented 6 years ago

https://github.com/DeepBlueRobotics/RobotCode2018/blob/2ac79eb04c867c5054e83b0cd1b503993213dbec/Robot2018/src/org/usfirst/frc/team199/Robot2018/Robot.java#L23

lhmcgann commented 6 years ago

When I first created the robot project, I created a Command-Based project, which creates the Robot class and automatically inherits from a Robot type. At the time, I had not yet updated my FRC plugins so the auto-inherit was IterativeRobot. To test, I just now created a new blank Command-Based robot project (my FRC plugins are updated to 2018) and the auto-inherit was TimedRobot. So basically that's why our project is currently and IterativeRobot.

From reading (https://wpilib.screenstepslive.com/s/currentCS/m/cpp/l/241853-choosing-a-base-class), there is no difference to the structure that we see in Robot, so we could just change the class signature to "extends TimedRobot". From the same website, they recommend making this change due to slight differences in the way each type updates it periodic methods.

From my understanding, IterativeRobot updates its periodic methods "each time new data arrives from the Driver Station", meaning its updated at irregular time intervals (whenever the data changes + variance "depending on CPU load on the roboRIO, the driver station laptop, or network traffic"). On the other hand, TimedRobot updates its periodic methods "at a predictable time interval", the default setting being 20ms. If the data has not changed in this time period, it updates its methods with the most recent previous data.

Now, after that long-winded response, conclusion: I don't see much harm in switching to TimedRobot: no structure change, recommended to be better (and seems so - more reliable/consistent), would take approximately 10s to change.

brettle commented 6 years ago

Why IterativeRobot instead of the new TimedRobot base class?