|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools |
Rating:
|
Display Modes |
|
#1
|
|||
|
|||
|
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! |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |