Go to Post In the now immortal words of will.i.am, "This stuff is really good!" - neshera [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 Rating: Thread Rating: 3 votes, 4.67 average. Display Modes
  #31   Spotlight this post!  
Unread 10-01-2011, 02:50
blakeelias's Avatar
blakeelias blakeelias is offline
2011 CT chairman's award
FRC #0694 (Stuypulse)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 26
blakeelias is an unknown quantity at this point
Re: RobotPy 2010.beta2

Quote:
Originally Posted by Peter Johnson View Post
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
Reply With Quote
  #32   Spotlight this post!  
Unread 10-01-2011, 02:51
blakeelias's Avatar
blakeelias blakeelias is offline
2011 CT chairman's award
FRC #0694 (Stuypulse)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 26
blakeelias is an unknown quantity at this point
Re: RobotPy 2010.beta2

Quote:
Originally Posted by Peter Johnson View Post
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
Reply With Quote
  #33   Spotlight this post!  
Unread 10-01-2011, 03:13
Slix Slix is offline
Registered User
AKA: Peter Kowalczyk
FRC #2115 (NightMares)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Mundelein, IL
Posts: 31
Slix is an unknown quantity at this point
Re: RobotPy 2010.beta2

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

Last edited by Slix : 10-01-2011 at 03:27. Reason: Added url
Reply With Quote
  #34   Spotlight this post!  
Unread 10-01-2011, 03:40
blakeelias's Avatar
blakeelias blakeelias is offline
2011 CT chairman's award
FRC #0694 (Stuypulse)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 26
blakeelias is an unknown quantity at this point
Re: RobotPy 2010.beta2

Quote:
Originally Posted by Slix View Post
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!
Reply With Quote
  #35   Spotlight this post!  
Unread 10-01-2011, 04:11
Slix Slix is offline
Registered User
AKA: Peter Kowalczyk
FRC #2115 (NightMares)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Mundelein, IL
Posts: 31
Slix is an unknown quantity at this point
Re: RobotPy 2010.beta2

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

Last edited by Slix : 10-01-2011 at 04:19. Reason: Edit
Reply With Quote
  #36   Spotlight this post!  
Unread 10-01-2011, 09:30
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,065
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: 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.
__________________
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
  #37   Spotlight this post!  
Unread 10-01-2011, 12:22
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 256
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: RobotPy 2010.beta2

Quote:
Originally Posted by virtuald View Post
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.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote
  #38   Spotlight this post!  
Unread 11-01-2011, 02:45
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: RobotPy 2010.beta2

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
RobotPy: Python for FRC Peter Johnson Python 28 17-10-2012 11:46
[FTC]: FTC 2010-2010 "A New Game" JohnFogarty FIRST Tech Challenge 2 21-08-2010 22:34
Connect a Million Minds 2010 Robotics Invitational, June 26, 2010 Columbus, Ohio Dr. Osemwengie Off-Season Events 29 03-07-2010 00:33
2010 accelerometer chsr C/C++ 1 22-01-2010 02:28


All times are GMT -5. The time now is 10:19.

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