More sample code (and a few questions)

I have our team’s (python) code here on bitbucket:

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.


  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?

  1. 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”?

  1. 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:

ai = wpilib.AnalogInput(CHANNEL)
bits = ai.Get()

The manual is pretty dense there on diagrams and theory,
but a bit :wink: sparse on the code details.

  1. 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).
  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 :slight_smile:

  2. Yes

  3. There’s a function called ‘GetVoltage()’, that’s probably what you want.