robotpy / robotpy-wpilib

Moved to https://github.com/robotpy/mostrobotpy
https://robotpy.github.io
Other
169 stars 59 forks source link

Frameworks taking advantage of python's capabilities as an interpreted language #20

Closed computer-whisperer closed 9 years ago

computer-whisperer commented 9 years ago

Several months ago, I started building a framework that attempted to take advantage of the flexible nature of python, and recently got it to a point where it works pretty well in those areas. You can find it here: https://github.com/Team4819/4819-2014-Offseason-RobotPy . I showed it to virtuald, recently, and he pointed out several key issues with the design concept, as well as the fact that it works strikingly similar to the command framework, which I was unaware existed for python.

Faulty implementation aside, I still was able to do a few neat things with it:

Module reloading: In my framework, I grouped all of the code relevant to a subsystem of the robot into a single python file, which I call a module. These modules are dynamically imported into the framework in such a way that they can, later, be unloaded entirely, and then re-loaded, again. This allowed me to live-edit the individual modules and, with a button press, see results immediately on the robot, without even leaving teleoperated mode!

Error recovery: I used a config file to specify, for each module, a "fallback list" of alternative modules with the same basic abilities. Then, mid-run, if the loaded module threw an exception, it would be immediately unloaded and replaced by the next module on the fallback list, which could be a more basic and robust version.

I think that python as a FRC language as so much more potential than it is currently getting used for. If there were an official framework designed with python in mind, and it's abilities as an interpreted language, I think robotpy could become much more than just an alternative programming language for robots.

computer-whisperer commented 9 years ago

I was going to continue development on my own with what I have for my team, and post it online when I am done. But I have come to realize that, without someone more knowledgeable than I reviewing the work, it will rapidly transform into a big bunch of trouble. I want to contribute something to this project, and to the FRC community in general, and I want to learn from my mistakes. I want to know what you would think about a framework like this, and what you would do with it, so that I can finish what I started.

virtuald commented 9 years ago

I agree that there's a lot of really cool things/potential with python, and I hope that more people will use it and do things like create cool frameworks.

My thought is that we shouldn't clutter the wpilib repository itself with things that aren't wpilib (eg, frameworks, utility libraries, and the like) -- but that shouldn't dissuade you from writing one. If you want feedback from people, I find posting stuff publicly is a good way to get interested people to make comments about it -- the trick is getting people interested in it.

There have been a lot of frameworks created for FRC over the years, and I've never really seen one that I particularly liked -- but perhaps I'm just too old school. However, I'm very interested in adding enhancements/extensions to WPILib to a common place that people can use them (see #6), but I think that stuff needs to end up in a separate repository somewhere -- and I'm not so sure I would want it to be a full-fledged framework. Just a collection of little things that make your coding easier.

virtuald commented 9 years ago

Also, I think @PeterJohnson mentioned he was interested in getting module reloading working on the RoboRIO.

computer-whisperer commented 9 years ago

@PeterJohnson Would you mind me taking a crack at implementing that? Or have you already started.