Go to Post The battery needs to be velcro-ed, strapped, buckled, tied, bolted, glued, zipped, or stapled in place so that it can't fall out when (not if) the robot turns upside-down. - dlavery [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 10-01-2015, 17:53
robotdna robotdna is offline
Registered User
FRC #4593
 
Join Date: Jan 2015
Location: SD
Posts: 7
robotdna is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 10-01-2015, 19:24
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: Segmentation Fault with PuTTy

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.
dustin@virtualroadside.com
__________________
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
  #3   Spotlight this post!  
Unread 10-01-2015, 19:49
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: Segmentation Fault with PuTTy

Quote:
Originally Posted by virtuald View Post
A segmentation fault means we screwed something up.
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
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
Reply With Quote
  #4   Spotlight this post!  
Unread 10-01-2015, 20:06
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: Segmentation Fault with PuTTy

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.
__________________
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
  #5   Spotlight this post!  
Unread 11-01-2015, 23:10
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: Segmentation Fault with PuTTy

Were you able to resolve your issue?
__________________
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
  #6   Spotlight this post!  
Unread 12-01-2015, 20:47
robotdna robotdna is offline
Registered User
FRC #4593
 
Join Date: Jan 2015
Location: SD
Posts: 7
robotdna is an unknown quantity at this point
Re: Segmentation Fault with PuTTy

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
Reply With Quote
  #7   Spotlight this post!  
Unread 12-01-2015, 21:58
robotdna robotdna is offline
Registered User
FRC #4593
 
Join Date: Jan 2015
Location: SD
Posts: 7
robotdna is an unknown quantity at this point
Re: Segmentation Fault with PuTTy

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
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2015, 01:58
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: Segmentation Fault with PuTTy

Quote:
Originally Posted by robotdna View Post
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".
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.
__________________
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
  #9   Spotlight this post!  
Unread 13-01-2015, 02:09
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: Segmentation Fault with PuTTy

Quote:
Originally Posted by robotdna View Post
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
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:

Code:
py robot.py
On linux, you would execute the following from a terminal:

Code:
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:

Code:
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:

Code:
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.
__________________
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
  #10   Spotlight this post!  
Unread 13-01-2015, 02: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: Segmentation Fault with PuTTy

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
__________________
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
  #11   Spotlight this post!  
Unread 30-01-2015, 21:07
robotdna robotdna is offline
Registered User
FRC #4593
 
Join Date: Jan 2015
Location: SD
Posts: 7
robotdna is an unknown quantity at this point
Re: Segmentation Fault with PuTTy

Quote:
Originally Posted by virtuald View Post
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!
Reply With Quote
  #12   Spotlight this post!  
Unread 30-01-2015, 22:06
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: Segmentation Fault with PuTTy

Quote:
Originally Posted by robotdna View Post
Alright, everything with RobotPy and PyFRC appears to be functioning perfectly and quite smoothly. Thank you so much for your support!
Good to hear!
__________________
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:36.

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