Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Python (http://www.chiefdelphi.com/forums/forumdisplay.php?f=187)
-   -   RobotPy 2010.beta2 (http://www.chiefdelphi.com/forums/showthread.php?t=87340)

blakeelias 10-01-2011 02:50

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by Peter Johnson (Post 995489)
By scanning the /py/ directory for updated date/time/size files (maybe non-ideal because of multiple files...)? Or wait for a joystick button press?

Wait for a joystick button press. Like this maybe:

http://pastebin.com/9bcUEy96

blakeelias 10-01-2011 02:51

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by Peter Johnson (Post 995489)
By scanning the /py/ directory for updated date/time/size files (maybe non-ideal because of multiple files...)? Or wait for a joystick button press?

With a joystick, same as usual:

http://pastebin.com/9bcUEy96

Slix 10-01-2011 03:13

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by blakeelias (Post 995481)
When there's an error can't it just sit there and wait for you to load new code? Maybe that's something that could be done in robot.py inside of run(), if it catches an exception then checkRestart() continuously.

Waiting for new code would be good. However, if possible, it shouldn't be done in robot.py. I like the fact that run() exists because it lets you see what the code is doing (unlike in C++, where they use a magic macro), but checking for new code seems like it should really be somewhere other than user code (robot.py). It's probably possible to do it outside of user code though.

Quote:

Originally Posted by Peter Johnson (Post 995489)
By scanning the /py/ directory for updated date/time/size files (maybe non-ideal because of multiple files...)? Or wait for a joystick button press?

Joystick button press might work, but how will you know which joystick and button to use? I suppose you could just use joystick 1 button 1. It's unlikely that a team doesn't have a joystick plugged in...

Quote:

Originally Posted by Peter Johnson (Post 995490)
Unfortunately the memory leak appears to be very difficult to fix (it's a leak in Python itself).

Is that this issue (that is fixed in Python 3.1.3)?
Quote:

Issue #4838: When a module is deallocated, free the memory backing the optional module state data.
Is it too difficult to move RobotPy to 3.1.3?

blakeelias 10-01-2011 03:40

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by Slix (Post 995505)
Waiting for new code would be good. However, if possible, it shouldn't be done in robot.py. I like the fact that run() exists because it lets you see what the code is doing (unlike in C++, where they use a magic macro), but checking for new code seems like it should really be somewhere other than user code (robot.py). It's probably possible to do it outside of user code though.

Joystick button press might work, but how will you know which joystick and button to use? I suppose you could just use joystick 1 button 1. It's unlikely that a team doesn't have a joystick plugged in...

Currently, normal code reloads in RobotPy are handled in robot.py user code by calling the checkRestart() function, which checks joystick 1 button 10 but can be changed. It seems like waiting after a crash could be implemented similarly, without a major change to the underlying framework (not sure how hard that would be). This also makes it easy to remove for competition...wouldn't want to restart the program in the middle of a match!

Slix 10-01-2011 04:11

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by blakeelias (Post 995513)
Currently, normal code reloads in RobotPy are handled in robot.py user code by calling the checkRestart() function, which checks joystick 1 button 10 but can be changed. It seems like waiting after a crash could be implemented similarly, without a major change to the underlying framework (not sure how hard that would be). This also makes it easy to remove for competition...wouldn't want to restart the program in the middle of a match!

Does wpilib still work if the code is not in StartCompetition()?

If so, that could work! Something like this (if done away from user code in boot.py) http://pastebin.com/iqZjYni0

Though, that requires that the user have a CheckRestart function.

EDIT: Also need a wait in that snippet in the loop so that it doesn't take up all the cpu.

virtuald 10-01-2011 09:30

Re: RobotPy 2010.beta2
 
What about instead of a joystick press, just listen on a socket for some string? It's easy enough to write a script to connect to that socket and send it.

Peter Johnson 10-01-2011 12:22

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by virtuald (Post 995602)
What about instead of a joystick press, just listen on a socket for some string? It's easy enough to write a script to connect to that socket and send it.

That's exactly what I was just thinking this morning as well. A little program runs on your PC with a button for "Code Reload".

Note that the latest code (I don't recall if 2010.beta2 did this, but it's in the current repo) implements the 5 second restart loop entirely in Python (in boot.py). If boot.py exits the C++ level terminates as well. So it's easy enough to customize the restart behavior however you like.

jhersh 11-01-2011 02:45

Re: RobotPy 2010.beta2
 
Quote:

Originally Posted by Peter Johnson (Post 995739)
That's exactly what I was just thinking this morning as well. A little program runs on your PC with a button for "Code Reload".

Note that the latest code (I don't recall if 2010.beta2 did this, but it's in the current repo) implements the 5 second restart loop entirely in Python (in boot.py). If boot.py exits the C++ level terminates as well. So it's easy enough to customize the restart behavior however you like.

Can I recommend that you do something that Java does... leverage the NetConsole input stream to signal the cRIO. You can just use a scanf from stdio... then a person using NetConsole or the serial console or wherever can easily reload. You can still make a utility that sends that keystroke to UDP port 6668 and give it a button to click if that's the ultimate interface you want.

-Joe


All times are GMT -5. The time now is 00:06.

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