Go to Post I still believe that if we are legitimately trying to make FRC be recognized as a real sport, then the GDC must treat it like one. - Jim Zondag [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-02-2012, 13:46
tux tux is offline
Registered User
AKA: Lee Harr
FRC #3842 (Shock-a-Bots)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Rochester, NY
Posts: 91
tux is an unknown quantity at this point
More sample code (and a few questions)

I have our team's (python) code here on bitbucket:
https://bitbucket.org/leeharr/first3842/src

Python is working quite well for us, though we are not doing anything very complicated. I may split it out in to separate files eventually, but it's not really a problem as it is.

Questions:

1) I based the code from the simple example. It seems like the while clauses in the run() function are extraneous, since the same thing is done inside of the matching functions for disabled() autonomous() and teleop()

Can I safely remove those statements, or do they provide something that I am not seeing?


2) Servo. I could not get this working at all on Tuesday, but I realized later that I did not have the jumper installed next to the PWM output in the digital sidecar. That was probably my main problem, right?

Also: does SetAngle() take 0.0 - 1.0 (as the manual implies) or is there a Set() that takes 0.0 - 1.0 and SetAngle() is the "method to set the servo angle based on the (currently) fixed minimum and maximum angle values"?


3) Analog Input. Does anyone have any code for this? I want to use a potentiometer to sense one of our actuators. I see the section in the User Guide about average bits and oversample, but I don't understand where exactly I am connecting the wires, and how I am reading the raw bits.

Do I just do:

Code:
ai = wpilib.AnalogInput(CHANNEL)
bits = ai.Get()
The manual is pretty dense there on diagrams and theory,
but a bit sparse on the code details.


4) Licensing. I added license statements that I hope are appropriate to attribute where the base code comes from. For modifications that I have made, can I attribute those to "team 3842" or should I (as sole author) assume copyright to my own name? (I would of course release under a BSD-like free license).
Reply With Quote
  #2   Spotlight this post!  
Unread 29-02-2012, 11:26
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,032
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: More sample code (and a few questions)

1) You could remove those statements if you wanted, it does the same thing. Personally, I prefer the SimpleRobot class-based robot, instead of using functions like that (which incidentally, does the same type of thing). But, whatever works for you

2) Yes

3) There's a function called 'GetVoltage()', that's probably what you want.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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