What is wrong with my RobotPy code?

Hi and sorry for so many question! I am the sole python programmer so I have no one else to turn to. So the problem is when I upload my code to the RIO and then I click enable in the driver station, the driver station disables the code after about a second. I can’t seem to find anything that would make the Driver Station quit so quickly without showing an error. Any help will be greatly appreciated! Code: http://pastebin.com/L17jQVqB

Recommend that you use the pyfrc simulator to test your code. Your problem will be immediately apparent when you actually run it. :slight_smile:

To use the pyfrc simulator, get pyfrc installed and just run ‘robot.py sim’.

When uploading the code to the robot, to see the output from your code (which would also show your problem), specify the --nc parameter to ‘robot.py deploy’ and it will launch a netconsole listener, which will show the output from your code.

You might benefit from the RobotPy eclipse plugins that we just released, it makes running tests and such a lot easier.

I appreciate it(again)! I will try the pyfrc sim and --nc parameter! Thanks a bunch!

Your code seems a bit complex. What are you trying to accomplish. There may be an easier way.

There are two issues with your code:

1 - you call teleopPeriodic from robotInit. You shouldn’t do this. The IterativeRobot class does this for you.

2 - you have a while loop in teleopPeriodic. You shouldn’t do this either. The IterativeRobot class periodically calls this function in a loop. You only need to have a while loop if you’re using SampleRobot as a base class (not recommended).

See the documentation on IterativeRobot for more details: http://robotpy.readthedocs.org/en/latest/wpilib/IterativeRobot.html

I am trying to make a controller curve so it is not a 1 to 1 ratio on the controller for better handling of robot. Thanks!