Quote:
Originally Posted by AlexBrinister
So what is the point of robotInit()?
|
Like I said, it serves a different function than the constructor. It's called when you are basically guaranteed that all WPILIBJ stuff will work. The constructor is a bit iffy on that point. An example would be Preferences. There is a bug that anything called before robotInit() (well actually anything called before Preferences is done initialising, but in practicality it's before robotInit()) where writing to files will cause a File Close IOException. It's usually much safer to assume nothing will function properly until robotInit().
That being said, we don't do that. We construct everything in the constructor and it works completely fine. If anything is wrong with your initialising, try moving it to robotInit(), but otherwise the constructor is a more elegant solution (if you wanted to use the code somewhere that doesn't call robotInit() - or in Java SE).