Go to Post I think this thread needs a reminder that there's no h in mecanum. ;) - Lil' Lavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Events   CD-Media   CD-Spy   FRC-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 02-13-2012, 02:41 PM
tux tux is offline
Registered User
AKA: Lee Harr
FRC #3842 (Shock-a-Bots)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Rochester, NY
Posts: 91
tux is an unknown quantity at this point
Not restarting

I got the netconsole working, so I can now see the output while the code is running.

I am using the "simple" example as a starting point, but the restart functionality is not working properly. When I hit the button for restart, I see the exception output on the netconsole, but the code is not restarted, it acts like it is just hung up.

Is there something special I need to do to make the code restart once an exception is raised?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-13-2012, 10:51 PM
virtuald virtuald is offline
Registered User
AKA: Dustin Spicuzza
FRC #1418
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Northern Virginia
Posts: 495
virtuald is a splendid one to beholdvirtuald is a splendid one to beholdvirtuald is a splendid one to beholdvirtuald is a splendid one to beholdvirtuald is a splendid one to beholdvirtuald is a splendid one to behold
Re: Not restarting

The example is outdated, the boot.py no longer reloads the code when an uncaught exception occurs. You can type 'reboot' at the NetConsole to reset the robot.
__________________
Co-maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables (NetworkTables for Python)

Team #1418: 2014 VA Regional: Finalists, #2 seed overall, Industrial Design Award; DC Regional: Finalists, #6 alliance captain
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


FRC Software Resources (including 2013 python code): http://www.virtualroadside.com/FRC/
WPILib Doxygen Repo: http://www.virtualroadside.com/WPILib/index.html
Reply With Quote
  #3   Spotlight this post!  
Unread 02-14-2012, 10:40 AM
tux tux is offline
Registered User
AKA: Lee Harr
FRC #3842 (Shock-a-Bots)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Rochester, NY
Posts: 91
tux is an unknown quantity at this point
Re: Not restarting

Ah. Ok. Now that I re-read the 2012.1 announcement I see the note about restarting.

So, if I change the RuntimeError exception to SystemRestart, then the interpreter should be restarted -- or at least it should try to. There may be other issues around that, but for testing it may be usable.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-14-2012, 11:36 AM
tux tux is offline
Registered User
AKA: Lee Harr
FRC #3842 (Shock-a-Bots)
Team Role: Mentor
 
Join Date: Apr 2005
Rookie Year: 2005
Location: Rochester, NY
Posts: 91
tux is an unknown quantity at this point
Re: Not restarting

Quote:
Originally Posted by virtuald View Post
You can type 'reboot' at the NetConsole to reset the robot.
Is that the same as pressing the reset button on the cRio or is it faster?
Reply With Quote
  #5   Spotlight this post!  
Unread 01-16-2013, 10:45 PM
tkbletsc tkbletsc is offline
Registered User
FRC #4561
 
Join Date: Jan 2013
Location: Raleigh, NC
Posts: 10
tkbletsc is just really nicetkbletsc is just really nicetkbletsc is just really nicetkbletsc is just really nice
Re: Not restarting

I haven't had a chance to test this on the robot, but given the warnings around the SystemRestart exception ("This is still not all that reliable..."), I wonder if using Python's own reload() would be better?

This works on my local machine...any reason not to do something like this? Also, anyone have an idea how to improve it?

robot.py:
Code:
from my_exceptions import RestartException
import real_code

while True:
	try:
		reload(real_code)
		real_code.go()
	except RestartException:
		print "Reloading and restarting..."
		pass
my_exceptions.py:
Code:
class RestartException(Exception): pass
real_code.py:
Code:
from my_exceptions import RestartException

import sys,os,re,time

# decide if we need to reload based on some signal, in this case a file existing 
which we delete
# on the robot, this would be a joystick check
def check_restart():
	if os.path.exists("do_reload"):
		os.unlink("do_reload")
		raise RestartException

def go():
	while True:
		check_restart()
		print "Test."
		time.sleep(1)
With the above, if I have it running in one window, edit real_code.py, then create "do_reload", the real_code.py is reloaded and restarted at the next tick.
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 09:46 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi