View Full Version : What is wrong with my RobotPy code?
team-4480
19-01-2015, 18:13
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
virtuald
19-01-2015, 18:27
Recommend that you use the pyfrc simulator to test your code. Your problem will be immediately apparent when you actually run it. :)
To use the pyfrc simulator, get pyfrc installed (http://pyfrc.readthedocs.org/en/latest/install.html) and just run 'robot.py sim'. (http://pyfrc.readthedocs.org/en/latest/usage.html)
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 (https://github.com/robotpy/robotpy-eclipse-plugins) that we just released, it makes running tests and such a lot easier.
team-4480
19-01-2015, 18:33
Recommend that you use the pyfrc simulator to test your code. Your problem will be immediately apparent when you actually run it. :)
To use the pyfrc simulator, get pyfrc installed (http://pyfrc.readthedocs.org/en/latest/install.html) and just run 'robot.py sim'. (http://pyfrc.readthedocs.org/en/latest/usage.html)
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 (https://github.com/robotpy/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!
TimTheGreat
19-01-2015, 20:57
Your code seems a bit complex. What are you trying to accomplish. There may be an easier way.
Peter Johnson
20-01-2015, 03:23
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
team-4480
20-01-2015, 17:31
Your code seems a bit complex. What are you trying to accomplish. There may be an easier way.
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!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.