![]() |
RobotPy: Python for FRC
After being inspired by Ross Light and Team 973's success in porting Lua to the cRIO (see the "Announcing FIRSTLua" thread), I have completed a port of Python to the cRIO, called RobotPy.
RobotPy is a fully functioning port of Python 3.1.2 that can be used for programming your FRC robot. The full set of WPILib functions, including CANJaguar, is available in Python via "import wpilib". As with the Lua port,
I've performed some initial testing on Team 294's 2010 robot, including running CAN bus Jaguars and compressors and pneumatics. Examples and installation documentation are available on the website and are also included in the download. Also, the download .zip file includes a prebuilt FRC_UserProgram.out, so you don't need to have any programming software installed to get up and running (just FTP a bunch of files to your robot)! Please report any bugs you find via the RobotPy website's ticket system (note: registration is required). RobotPy website: http://www.tortall.net/projects/robotpy/ While the download .zip doesn't include the source code, it is available via a git repository. See the Download page on the website for details. With the exception of modules with large dependencies (e.g. databases), almost all of the Python standard library is included. So yes, you can parse XML files with expat on the robot if you so choose :). Much of this is untested however (I have not tried to run the Python test suite on the robot). Major thanks go to Ross Light and Team 973; this project would not have happened without them creating FIRSTLua first to inspire me to port Python. RobotPy uses the WPILib SWIG wrapper created by Ross, with the addition of CANJaguar. The idea of using a boot script to auto-reload the user code is also taken from FIRSTLua. |
Re: RobotPy: Python for FRC
thank you so much :)
I'm already porting my team's high level motor grouper and pneumatics classes, I'm hoping these can be included with your permission, of course |
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
I have most of the common inputs that my team used coded in python for prototyping, so I will be done with the whole thing by tomorrow
|
Re: RobotPy: Python for FRC
Quote:
Do sockets work? That would make it easy to add a telnet server to the robot, and allow remote execution of code to aid testing. Also, does print work correctly? Thanks again for doing this! I'm really excited. |
Re: RobotPy: Python for FRC
Quote:
Yes, print works correctly. Feel free to tackle NumPy and SciPy. FYI, to date, I've been integrating C/C++ modules directly into Python/Lib and Python/Modules/ (and updating Modules/config.c to add them to _PyImport_Inittab), because it's all a static executable anyway. |
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
where does print go?
|
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
I have basic driving functions and inputs programmed:
output.py Code:
#Made by Sam Dodrill for Team 2412, WTFPLCode:
#made by Sam Dodrill for team 2412, but you can use it too |
Re: RobotPy: Python for FRC
1 Attachment(s)
Code Zipped up and is attatched.
First Release, nothing fancy |
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
This is totally awesome. When I saw the Lua thing, I was thinking the same thing, so I'm glad someone took the time to do it. I'll have to try it on the bot later.
|
Re: RobotPy: Python for FRC
I'm super excited to see this! I love Python as a langue, and I can't wait to maybe load this on a practice robot.
|
Re: RobotPy: Python for FRC
I've implemented dynamic loading of C modules. The next release of RobotPy will break out many of the C modules into separate loadable object files, the same way that normal Python does. These separate .out files are located in /lib/python3.1/dyn-load on the robot, so they won't clutter up the /ni-rt/system directory.
This should also make distributing other modules (e.g. NumPy) easier, as they can be distributed as separate .zip packages without having to integrate them into the RobotPy executable. I'm also going to make the wpilib module dynamically loaded. This will make it easier to test with different/beta/custom versions of WPILib. This reduces the size of the basic Python executable down to ~3.5M; the wpilib module is ~5M! |
Re: RobotPy: Python for FRC
After they were blown away with WindRiver/C++ last season, I introduced the controls and software team to Python by taking part in Team 342's summerpygames. They got the hang of it and are asking for more. This is perfect! :cool:
We'll give it a try. Thanks, Eric |
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
A bit off topic, but the book "Learn Python The Hard Way" seems like a great guide to learning how to program, using Python. (Different than learning how to use Python :p)
This might be good supplement to RobotPy. http://learnpythonthehardway.org/index |
Re: RobotPy: Python for FRC
I built the most recent version from source. The make_dist.bat file copies the loadable modules to "dyn-load", but Python looks for the modules in the "lib-dynload" directory. I fixed the bat file to reflect this, and it works fine now. Before, boot.py couldn't find the time library and aborted.
I post this here because the discussion boards on FIRST Forge are limited to project members (total project members: 1). |
Re: RobotPy: Python for FRC
Quote:
You should be able to request project membership on FIRST Forge to post there... let me know if you are unable to for some reason; maybe there's a setting I missed. Thanks! |
Re: RobotPy: Python for FRC
Hmm. I checked out from the git repository just this morning. However, all the other files seem to match the most recent changeset, so maybe it's a client-side issue.
Anyways, I'm happy to report that I've finished porting last year's code to Python, and as a separate project, modified our existing C++ code to load Python to run an autonomous script that our drive team can edit while queuing for a match with alliance members, with surprising ease. I copied the RobotPy/Python directory and the wchar.h and wchar.c files into the old directory, expanded the include paths to include the root directory (containing the wchar files), /Python/, and /Python/Include/, and compiled. In our autonomous method I put the contents of RobotTask(), replacing ROBOTPY_BOOT with the path (on the robot) to our Python autonomous script. Then I uploaded the resulting .out file to the robot, leaving the existing Python libraries intact. NetConsole shows many error messages about duplicate symbols when Autonomous mode starts, probably as a result of linking WPILib to the C++ code and also loading the _wpilib.out from RobotPy. However, WPILib also throws (fatal) "resource resuse [sic]" errors when WPILib instances from the Python code are not properly deleted before the script ends and the same resources are used in teleoperated code. I'm still resolving the kinks in WPILib on Python, but Python itself runs fine. |
Re: RobotPy: Python for FRC
Quote:
Glad you were able to have some early success even not using the library how it's designed (as a full-up Python solution)! |
Re: RobotPy: Python for FRC
Python sounds great! Is it legal for the 2010 season? And are there handlers or image-recognition algorithims for the camera?
|
Re: RobotPy: Python for FRC
Quote:
With regards to the image recognition suite (WPILib Vision library), there's currently no wrappers but it should a straightforward project for an enterprising person who wants to learn a bit about SWIG (see Packages\wpilib\wpilib.i in the source tree). |
Re: RobotPy: Python for FRC
Hi,
We are a rookie team (temp# 2012085) interested in using RobotPy. Any recommendations on how to start preparing (websites, tutorials, etc). Thank you!! |
Re: RobotPy: Python for FRC
I'm very sorry to bring back an old thread, but I'm wondering if this project has gone anywhere since 2010. If not, would everything in it still work? I've heard some very good things about Python, so am curious about maybe using it next year.
|
Re: RobotPy: Python for FRC
Quote:
|
Re: RobotPy: Python for FRC
As Peter said, RobotPy still works and is being maintained. There's a bunch of resources included with the RobotPy distribution, and my team has released our robot code the last two years, both of which are written in python.
|
| All times are GMT -5. The time now is 00:06. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi