Segmentation Fault with PuTTy

Hello all,

We are running our robot.py through a SSH on PuTTy (because we have zero idea how to get pyfrc functioning, it doesn’t seem to work) and have successfully gotten our “Robot Code” light to go green on the Driver’s Station. However, when we start implementing a more advanced code into the RoboRIO, puTTy returns “Segmentation Fault.” Our code light goes red then.

I suppose my question is, really, how do we get our code functioning? It’s the same stuff we used last year, and the same electricals minus the RoboRIO (which appears to be accepting Python and communicates with the DS).

Thanks,
robotdna

I ran into some issues with pyfrc today also, and I’m going to see if I can nail it down. What particular issues are you having?

A segmentation fault means we screwed something up. If you could send me the code that caused the segmentation fault, I can help you figure it out.
[email protected]

More specificially, this happens when a python extension (written in C) tries to access a memory beyond reach.

You can trace it in following ways:

1.Add sys.settrace at the very first line of the code.

2.Use gdb at the command prompt

gdb python
(gdb) run /path/to/script.py

wait for segfault

(gdb) backtrace

stack trace of the c code

My python is rather rusty. Let me know if this method doesn’t work

So, I gave this some thought, and I believe you are creating objects outside of your robot class. At the moment, HALInitialize is not called until after wpilib.run() is called, and if you try to create a device before HALInitialize is called, it will segfault.

For the moment, create your devices inside your robot object, and the segfault will go away. In the next release of the RobotPy WPILib libraries, it will raise an error if you do this.

Were you able to resolve your issue?

First off, how does one even use pyfrc? It seems like there is documentation on how to install pyfrc, but nothing on how to actually function with it.

Where do I type any of my commands? I installed pyfrc using pip(pip window comes up, I select “c:\python34\python.exe” as the interpreter, then typed “pip install pyfrc”

What do I do next from this? Your documentation has plenty on what commands to use, but no documentation on where to type them or how to use them.

Thanks again for all your help,
robotdna

Alright, so using putty:

Every time we use “lmotor2 = wpilib.Talon(1)” we get a segmentation fault. When we replace Talon with Joystick or Timer, the code runs correctly.

We also get this error using “TalonSRX” and “Jaguar”.

Thanks,
robotdna

Yes, as I stated previously, if you create these objects before the robot code is properly initialized, you will get a segmentation fault.

Please upgrade to RobotPy 2015.0.3 (just released a few minutes ago), and it will allow you to create the objects whenever you would like without segmentation faults.

I apologize that the documentation isn’t as clear as it should be on this point. I’ll try to fix it so future users aren’t confused.

The way pyfrc works is it attached to some predefined hooks in the installed wpilib on your computer, such that when you execute your robot code directly, you can specify options to run the various pyfrc commands.

When you run your robot code, you can run it using whatever mechanism you would like (a script, via eclipse, via the terminal). Most people will use the terminal (or cmd on Windows) to execute their code.

So, to execute your robot code on Windows, you would open cmd, change directories to where your robot code is, and then run this:

py robot.py

On linux, you would execute the following from a terminal:

python3 robot.py

Of course, if you just execute robot.py, nothing happens – you need to pass it some arguments. To see all the installed arguments execute this:

py robot.py --help

The various commands that the pyfrc documentation lists are commands that you append to the command line that you execute your robot with. For example, to deploy your robot to the roboRIO, you would do this:

py robot.py deploy

Eclipse plugins for robotpy are still in progress, and will make some of this a bit easier and you won’t need to use the terminal anymore. Ideally they will be done by the end of week 3… maybe even by this weekend.

Also, I’ve updated the documentation on the usage section of pyfrc. Please let me know if the documentation makes sense to you.

http://pyfrc.readthedocs.org/en/latest/usage.html

Alright, everything with RobotPy and PyFRC appears to be functioning perfectly and quite smoothly. Thank you so much for your support!

Good to hear!