Open virtuald opened 7 years ago
uh oh, have I been scooped? :)
how finished is it?
You just didn't search sufficiently to see if it had already been done before. :)
There's also a python project called pygazebo which allows you to connect to gazebo (which is what robotpy-frcsim uses). However, it uses asyncio/trollius so it can be a bit obscure to work with if you're not familiar with async stuff.
As the commits indicate, it hasn't been touched in 2 years. It worked at the time... but FRCSim wasn't very useful for me at the time, so I stopped working on it. It probably needs a bit of cleanup to conform to HAL updates and such (particularly with 2017 updates once those are made...).
If you're interested in maintaining the frcsim support, I'd be more than happy to give you commit access to the repo, and you can update/replace pieces of it as you see fit.
Maybe once I've gotten things working to my liking I'll take you up on that.
What's the preferred strategy for hal_impl? Right now I'm just porting the java wpilib simulation stuff and as near as I can tell I'm going to need a different one than that of robotpy-hal-sim, which is leading me to do horrible things with sys.modules
Yeah, the java wpilib simulation stuff is terrible, I would highly recommend not copying their approach (and it will be gutted for 2018 in favor of an approach similar to RobotPy).
Instead, you should be using the normal hal-sim implementation, and use the various hooks that it makes available. You can send data to/from WPILib by modifying the hal_data dictionary, instead of implementing your own HAL.
Study robotpy-frcsim to see how it works. The RobotPy HAL is designed so that something like this is possible to do without too much extra/duplicative effort (as opposed to the wpilib approach, which requires tons of duplication of code).
Do keep in mind that some of the hacks required for the current HAL won't be required for 2017 (in particular, things related to gyros/pwm have changed a lot). The 2017 RobotPy porting process is currently underway.
in wpilib/driverstation, what updates newControlData?
There's a background thread in the DS that continuously calls 'getData', which calls into hal and returns whatever variables happen to be in the hal_data dictionary.
Also, in the 2017 DS, it looks like getControlWord is called directly by a number of functions.
getData doesn't appear to be updating newControlData since https://github.com/robotpy/robotpy-wpilib/commit/9b3a16e7d7e75c725e356f61c7c54b757b2002c4
https://github.com/robotpy/robotpy-frcsim