Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Programming in Python and Explaination of Programming (http://www.chiefdelphi.com/forums/showthread.php?t=60489)

roboxking 31-12-2007 02:16

Programming in Python and Explaination of Programming
 
Our team has decided to use Python for programming, instead of C. Does anyone know how to do that. I also need a general explanation of how programming works in general. This is our first year in FRC, and in FVC (now FTC) all we did was use EasyC, so how programming worked wasn't an issue. Thanks for the help anyone can give me.

ebarker 31-12-2007 08:29

Re: Programming in Python and Explaination of Programming
 
The FRC controllers are written in straight ANSI C. It is not C++. We don't do objects.

Inside the controller is a ton of code that has the framework where you hang your custom code for autonomous and a routine that you modify to do your normal hands on control. A lot of the work is setup for you already in terms of conditioning I/O points and setting up interrupt handlers, etc.

Considering that IFI has done 90% of the code for you it is impractical and unnecessary to consider another language.

This competition reflects real life. Just like a real life project the language may have been chosen before you arrived for any of a million reasons.

Besides, professional programmers are adept at:

a - picking the right tool for the job
or
b - using the tools that have been chosen when not given the choice.

BTW - If you used a coprocessor like the gumstick you could eventually get to the point of building support for python but that project isn't for a newbie programmer. You only have 6 weeks to finish this whole robot project.

Good Luck !!

Robostang 548 31-12-2007 11:59

Re: Programming in Python and Explaination of Programming
 
My team will be programming our 2008 robot in python. We are trying to get an off board coprocessor working. Team 245 did a workshop on using a coprocessor at last years kickoff in Novi Mi. They did their coprocessor in python and for a time, they had their code on their website. I don't know if team 245 will be using a coprocessor this year or if they will be giving support to their code because their two main programmers who wrote the code graduated last year. In terms of getting python to work on the RC alone, I cant help you much there. But there is rumor that the new controller that will be available in the 09 season will have support for multiple languages.

-Don

tajmorton 31-12-2007 13:02

Re: Programming in Python and Explaination of Programming
 
Quote:

Originally Posted by roboxking (Post 665679)
I also need a general explanation of how programming works in general.

Check out the guide that Team 1540 (The Flaming Chickens) put together: http://www.team1540.org/programming.
It's a great overview of how the default code is setup, and how to modify it.

[Assuming that you are going to use C...otherwise please ignore :)]
As for learning C, if you already know some Python (or another language), I don't think the jump will be too huge. A lot of being a programmer is the way you think, not the syntax you write (for me, anyway). That said, you might want to dip your toes in the C-sea before you have to write embedded code on a deadline.

On Windows, I've used the Dev-C++ IDE (uses a GCC compiler). Despite its name, it can be used for both C and C++ programming. Look up some C tutorials on the web and try writing some simple programs (something that reads a file and prints it on the screen, something that computes the area of a circle from its radius, something that computes the hypotenuse of a right triangle, etc)--just some simple stuff to learn the syntax. I can't really recommend and C tutorials, but a quick google brought up this this one (and many others).

- Taj

slavik262 31-12-2007 20:35

Re: Programming in Python and Explaination of Programming
 
Quote:

Originally Posted by tajmorton (Post 665779)
A lot of being a programmer is the way you think, not the syntax you write (for me, anyway). That said, you might want to dip your toes in the C-sea before you have to write embedded code on a deadline.

I would definately agree. Once you get the hang of programming itself, learning syntax really isn't as hard as you would think. I would give C a try.

EricH 31-12-2007 21:04

Re: Programming in Python and Explaination of Programming
 
Is EasyC going to be available for FRC again? If so, problem (partially) solved.

hdanak 01-01-2008 19:33

Re: Programming in Python and Explaination of Programming
 
not meant as a reply, just some thoughts:

It interesting to see what real speed advantage the coprocessor would give. Python is generally 16x slower than native, so it would seem that (if true) the Python code would run more slowly on a 400 mhz computer than native c on the 40 mhz (i think) PIC mcu. But it might be worthwhile just using C on the coprocessor, which may or may not be against the purpose of a coprocessor. I think python would be worthwhile for extra control speed (using heavily optimized code, or more likely, native imported code), ease of development (the mcc18 C is not exactly ANSI C, so it would be generally easier to use a higher layer of abstraction instead of dodging all the pitfalls and differences; though it may take some work to setup), and portability of code (we could use a straight cvs/svn/bazaar rep to manage the code which is generally more modular and clean-cut than the C code). Other than that, its way easier to get new programmers in the team learn python than C (well, depends on how thoroughly they think of a problem; if they could live in abstraction, python is easy); it would generally take a day or two to pickup the python syntax (after the general compsci aspect is explained) vs a week for C (which would also require a thorough knowledge of the PIC18 mcu before any programming). Of course, this is after its all setup. And lastly, python is new and cool and stuff, along with linux(not so new, but still cool and stuff).

So those were our reason for trying the python/coprocessor technique.

hdanak 01-01-2008 23:03

Re: Programming in Python and Explaination of Programming
 
I made an error on the previous post, calculating that python would be slower than the frc controller, forgetting that a 40mhz clock allows the FRC controller to run at 10mips (million instructions per second). So it will be faster with python, but not as fast as using C on the coprocessor (which would be an order of magnitude faster).

hdanak 02-01-2008 00:08

Re: Programming in Python and Explaination of Programming
 
Another question: where can we find sample code in Python (adambots reps are down). Thanks.

bear24rw 02-01-2008 00:10

Re: Programming in Python and Explaination of Programming
 
Even if it is alot faster to do calculations on a co processor, how fast can you pipe it back and forth between the two.. 115200kbs at most

hdanak 02-01-2008 00:28

Re: Programming in Python and Explaination of Programming
 
" The ACS communicates over serial using the
programming port on the IFI controller. During
normal operation, the IFI and the coprocessor
exchange data once every 26.2 ms, alternating
sending and receiving as the IFI receives new data.
" from Adambots kickoff presentation (http://www.chiefdelphi.com/media/papers/1900?)

well, that seems a bit slow (38 hertz), but i guess the program can be tweaked to go faster?

Guy Davidson 02-01-2008 01:48

Re: Programming in Python and Explaination of Programming
 
38hz comes from the limitation on the IFI RC. The IFI only recieves new data from the OI every 26.6ms as well as updates pwms, unless I'm mistaken, and those are the points where their code has the IFI RC send the data over.

hdanak 02-01-2008 01:58

Re: Programming in Python and Explaination of Programming
 
I know its not the most reliable source, but according to IFI:
"Digital Input Frequency: 50 KHz (typical)"
and
"Serial Ports| TTL Serial (115Kb) and
RS232 Program (115Kb)"
(http://www.ifirobotics.com/rc.shtml)

so it looks like it could go at least some kilohertz there.

roboxking 02-01-2008 02:29

Re: Programming in Python and Explaination of Programming
 
Thanks for all the information (and quick response) But now, I'm asking if anyone who has a [working] python code for an FRC robot? We need to see how one works, and etc. Thanks

jtdowney 02-01-2008 08:28

Re: Programming in Python and Explaination of Programming
 
I have seen the code for AdamBots (245) co-processor solution which uses Python. However as hdanak pointed out their bazaar repositories are not responding. You might try contacting them and seeing if they'd be willing to share the code with you.


All times are GMT -5. The time now is 23:17.

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