Go to Post I gave up football and a chance to be ignorant the remainder of my hs career....so ive gained more than loss - TheNotoriousKid [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 31 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 12-19-2009, 12:21 AM
spartango spartango is offline
Registered User
FRC #0192 (GRT)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Palo Alto, CA
Posts: 43
spartango is an unknown quantity at this point
Event Driven Development for FRC-Java

The GRTFramework (http://code.google.com/p/grtframework , seee http://forums.usfirst.org/showthread.php?t=13459 for more) has been updated to Version 2.0, bringing a brand-new Event model to FRC Java!

That means you can develop code for your robot that doesn't need to poll for sensor data, instead being notified when a sensor has new data or when a sensor state changes. That means you can be notified when a component has executed a specific instruction, or a part has failed to do what it needs to do. All told, this allows for asynchronous robot control and really flexible, responsive code.

Give it a try and let us know what you think!

A little more info:

I'm attaching here a the file that defines a teleoperated tankdrive mode using events from the joystick.

http://forums.usfirst.org/attachment...1&d=1260931244

Very simply, lets walk through this code...
First, we are in a "DriveEventController"... which is an EventController and a JoystickListener.
In the constructor we register the RobotBase(Drivetrains and sensors involved in moving) with this controller by "addMechanism"-ing it.
We also subscribe this controller to events pushed by each joystick, as follows:
((GRTJoystick) ds.getSensor("leftJoystick")).addJoystickListener( this);

When the x-axis Joystick, changes position, that joystick sends an event and calls "xAxisMoved"...When this happens we do nothing--this is tank drive--as is the case with the z axis and throttle.

When the joystick yAxis is moved, yAxisMoved is called, and we do two things:
1st we figure out if it was the left or right joystick by asking for its ID.
2nd we tell the mechanism that it should be tankdriving at the new desired speed.

Thats it! no threads or loops. no polling. no weird or random calls, all abstracted to the physical object of a robot base. Oh, and it works.
See http://code.google.com/p/grtframework for more!
Reply With Quote
  #2   Spotlight this post!  
Unread 12-20-2009, 06:04 PM
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,033
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: Event Driven Development for FRC-Java

This sounds like a neat idea. I'll have to look at it later tonight.
__________________
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 12-29-2009, 09:03 PM
spartango spartango is offline
Registered User
FRC #0192 (GRT)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Palo Alto, CA
Posts: 43
spartango is an unknown quantity at this point
Re: Event Driven Development for FRC-Java

Quote:
Originally Posted by virtuald View Post
This sounds like a neat idea. I'll have to look at it later tonight.
Did you get a chance to play with this? We'd love to hear any feedback you have.
Reply With Quote
  #4   Spotlight this post!  
Unread 01-01-2010, 01:05 PM
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,033
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: Event Driven Development for FRC-Java

I haven't got a chance to actually play with it yet (and I may not, depending on whether I try the Java stuff this year). However, I've briefly looked through the docs/examples that you had posted on the project's wiki, and it looks like using it might get really verbose.

But in any case, I think the idea of using an event driven model for robot development is an excellent idea, as I've noticed when working on stuff for last year that I *essentially* did that same thing when abstracting stuff out, except not necessarily being as formal about it. It'll be something I'll be thinking about when we start working on code for this year.
__________________
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 01-01-2010, 03:40 PM
spartango spartango is offline
Registered User
FRC #0192 (GRT)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Palo Alto, CA
Posts: 43
spartango is an unknown quantity at this point
Re: Event Driven Development for FRC-Java

Quote:
Originally Posted by virtuald View Post
I haven't got a chance to actually play with it yet (and I may not, depending on whether I try the Java stuff this year). However, I've briefly looked through the docs/examples that you had posted on the project's wiki, and it looks like using it might get really verbose.
Hmm. ok. thats a fair point... Do you have any suggestions on how this might be made more concise?

One of the things I was thinking about was emphasizing private mechanism variables as opposed to going through the hashtables(which has its own role in the system).

I've also hidden more of the Command system behind the scenes to make things a little more clear. You no longer should have to instantiate commands unless you need them to be time bound...

http://code.google.com/p/grtframework/wiki/BriefUsage

Last edited by spartango : 01-01-2010 at 03:45 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 01-05-2010, 11:52 AM
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,033
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: Event Driven Development for FRC-Java

Sorry for the delay. I was mostly referring to things like "e.getSource().getId().equals("left")" ... I'm sure theres a good reason why I have to call getSource(), but it seems a bit redundant. Same thing with the subscription mechanism shown in the example: ((GRTJoystick) ds.getSensor("leftJoystick")).addJoystickListener( this); It just seems like a lot of text to do something simple. Should write some wrappers to do common operations like that (even though I *know* the latter example will only be done once or twice in a program, but I'm the type of person that likes creating lots of tiny programs for testing things, and don't want to remember all of that. )
__________________
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[BB]: Still not Bill #2 (FRC Java Software Available) Jason Law General Forum 1 12-07-2009 12:27 PM
**FIRST EMAIL**/FRC Java Software Available/Important Site Updates/Deadline Reminders Mark McLeod FIRST E-Mail Blast Archive 0 12-03-2009 10:31 PM
FRC Java 2010 Documentation alivemyst Java 11 09-07-2009 07:03 PM
[VIDEO] Wiimote Driven FRC Bot Greg Marra General Forum 7 01-22-2008 07:56 AM
**FIRST EMAIL**/Get Ready for 2008 FRC Event Registration! Mark McLeod FIRST E-Mail Blast Archive 0 09-12-2007 02:35 PM


All times are GMT -5. The time now is 07:32 AM.

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