Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   Python WPILib Reference? (http://www.chiefdelphi.com/forums/showthread.php?t=97137)

WizenedEE 27-08-2011 03:10

Python WPILib Reference?
 
Hello there,

I'm looking to try out programming in python, but I can't figure out what functions/classes/etc exist. Is there some sort of simple reference that lists the functions, parameters, returns, and a sort description of what they do? Or is there a file in the robotpy folder that defines them? Going off examples involves a lot of guesswork, which is tough without a C-RIO.

I did find something that says, "They're basically the same as the c++ ones but some of them are different" which wasn't very helpful, especially since I don't know the c++ functions! If anyone has a page on the c++ functions, that would be nice also.

Thanks for the help!

Peter Johnson 28-08-2011 00:25

Re: Python WPILib Reference?
 
It's available in a couple of places online (just search for "WPILib reference"):

http://devildawgs549.com/2011_WPILib...Reference.html

http://amhsrobotics.com/wpilib/html/annotated.html

WizenedEE 28-08-2011 03:58

Re: Python WPILib Reference?
 
Thank you, those look great.

Is there a place where I can look at the source code of all the wpilib python functions, somewhere in the robotpy file that's on github?

Peter Johnson 29-08-2011 00:09

Re: Python WPILib Reference?
 
The Python WPILib is mostly just a wrapper around the C++ one, generated by a tool called SIP (this is unlike Java, where the Java WPILib is written entirely in Java itself). The code is located in https://github.com/robotpy/robotpy/t...ackages/wpilib

The wpilib.py file is what you get when you "import wpilib", and is the only real Python file. It reimplements the robot base classes (e.g. IterativeRobot) for technical reasons (the C++ robot class runs the Python interpreter so you can't overload it directly from Python).

The rest of the library is implemented through code generated from the sip files in the sip/ directory. These are (for the most part) just stripped down copies of the C++ header files with a few tweaks where necessary to support reasonable parameter passing to and from Python.

Ziv 03-09-2011 00:26

Re: Python WPILib Reference?
 
Peter, thanks for bringing Python to FRC!
I poked around for a while in the links you mention, but I still have one question: does one need to do anything special to specify values of types such as EncodingType? Is the proper syntax just "enc = wpilib.Encoder(1, 2, False, k4x)" or something fancier?

Peter Johnson 04-09-2011 00:06

Re: Python WPILib Reference?
 
Quote:

Originally Posted by Ziv (Post 1075825)
Peter, thanks for bringing Python to FRC!
I poked around for a while in the links you mention, but I still have one question: does one need to do anything special to specify values of types such as EncodingType? Is the proper syntax just "enc = wpilib.Encoder(1, 2, False, k4x)" or something fancier?

Constants are scoped into the class where they are defined. E.g. "wpilib.Encoder.k4x", "wpilib.Relay.kReverse", etc.

DjMaddius 24-09-2011 20:42

Re: Python WPILib Reference?
 
Are we allowed to use Python this year? That would be incredible! Python is easily on the top of my favorite languages. It makes things that would normally take lots of code in one language into just a few short lines.

If we can use Python, we are all set this year. Not a fan of labview D:

Peter Johnson 25-09-2011 00:27

Re: Python WPILib Reference?
 
Quote:

Originally Posted by DjMaddius (Post 1078447)
Are we allowed to use Python this year? That would be incredible! Python is easily on the top of my favorite languages. It makes things that would normally take lots of code in one language into just a few short lines.

If we can use Python, we are all set this year. Not a fan of labview D:

Until the 2012 game manual is released, we won't know for sure, but all indications are that it (and other scripting languages like Lua) will be legal. One positive indication: both teams 294 (ported Python) and 973 (ported Lua) are control system beta testers for 2012.

DjMaddius 25-09-2011 13:38

Re: Python WPILib Reference?
 
Awesome! Really looking forward to it this year. Thanks for the info.

virtuald 26-09-2011 15:05

Re: Python WPILib Reference?
 
We used python last year, it was fantastic. :)

DjMaddius 26-09-2011 15:46

Re: Python WPILib Reference?
 
Been talking with the others involved and it looks like we are going to do Labview and python parallel together this year! Im doing the python and one of the mentors is doing labview. He prefers labview because he did it at Comau.

Really looking forward to my third year programming for the team! Im glad their is a nice community on python now. I had no idea the opportunity was there last year.

LinuxArchitect 05-10-2011 14:52

Re: Python WPILib Reference?
 
Quote:

Originally Posted by DjMaddius (Post 1078703)
it looks like we are going to do Labview and python parallel together this year!

You're not alone. We're doing the same thing, beta testing labview and developing our python skills in parallel. A third team might sneak in with Java as well. We'll have an in-house autonomous challenge in December and then decide on which language to use for competition season.

George/Team 53

DjMaddius 11-10-2011 20:59

Re: Python WPILib Reference?
 
Thats a good idea, put the students to the test to see which language to follow. See which one we are strongest at, and get some experience in as well. Im going to bring this idea up at our meeting on Thursday. Thanks haha.


All times are GMT -5. The time now is 19:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi