Go to Post FIRST is like a big roller coaster, that can only be experianced if one takes a ride which can become a liftime experiance. - activemx [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

 
 
 
Thread Tools Rating: Thread Rating: 31 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 19-12-2009, 00:21
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
 


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 07-12-2009 12:27
**FIRST EMAIL**/FRC Java Software Available/Important Site Updates/Deadline Reminders Mark McLeod FIRST E-Mail Blast Archive 0 03-12-2009 22:31
FRC Java 2010 Documentation alivemyst Java 11 07-09-2009 19:03
[VIDEO] Wiimote Driven FRC Bot Greg Marra General Forum 7 22-01-2008 07:56
**FIRST EMAIL**/Get Ready for 2008 FRC Event Registration! Mark McLeod FIRST E-Mail Blast Archive 0 12-09-2007 14:35


All times are GMT -5. The time now is 08:52.

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