Go to Post I'd like to thank FIRST for giving me this wonderful opportunity. I've learned so much! - Leav [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Spotlight this post!  
Unread 09-04-2010, 01:06
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Autonomous Control

Quote:
Originally Posted by kamocat View Post
The only events I'm familiar with are user events (the user interacting with a GUI). However, you seem to be using "events" as a method of transferring data from one place to another.
How are you "registering" a maneuver? Is it all variable scope?

Does each mechanism only perform one action? For example, is the Drive mechanism always in the form of Drive(Forward, Strafe, Turn); ?

Are all the maneuvers "canned", so to speak? Can a mechanism be controlled without performing a maneuver?
An event is not so much a way transferring data, but more a way of notifying.
If the current maneuver is changed the mechanisms should be notified.

Here's some code from another teams robot which i converted to the ADK

example robot code (registers on initialize):



Code:
public class Wolv extends Robot
 {
    
    public synchronized void initialize() {
        timer.reset();
        timer.start();

        getWatchdog().setExpiration(0.1);

        controller.setFactory(ManeuverFactory.getInstance());

        controller.addEventListener(ManeuverEvent.CHANGE, shooter);
        controller.addEventListener(ManeuverEvent.CHANGE, drive);
        controller.addEventListener(ManeuverEvent.CHANGE, roof);
    }
    
}
example drive code:

Code:
public void actAutonomous() {
        if(timer.get() > GYRO_TO){
            gy.reset();
            timer.stop();
            timer.reset();
            timer.start();
        }
        String type = Wolv.getInstance().getManeuver().getType();
        if (type.equalsIgnoreCase(ManeuverType.NOT_STRAIGHT))
            notStraight();
        else if (type.equalsIgnoreCase(ManeuverType.ROTATE))
           if(rotate())
               this.respond(new MechanismEvent(MechanismEvent.PASS));
        else if (type.equalsIgnoreCase(ManeuverType.STRAIGHT))
            straight();
        else if (type.equalsIgnoreCase(ManeuverType.STRAFE))
            strafe();
        else if (type.equalsIgnoreCase(Maneuver.OPERATOR))
            actOperator();
        else
            halt();

    }

    public void actOperator() {
        if(timer.get() > GYRO_TO){
            gy.reset();
            timer.stop();
            timer.reset();
            timer.start();
        }

        if(Wolv.getJoystick().getRawButton(DRIVE_STRAIGHT_BUTTON))
            driveStraight();
        else
            drive(Wolv.getJoystick());
    }
a maneuver decides for itself what it should do. it could run by itself and ignore everything else.

or it could only listen for events from a MechanismController which would send events through the form of a MechanismEvent

also everything is extendable, beginner users wouldn't make custom maneuvers per se, but advanced users could. Here is a maneuver which needs to receive 3 passes from the mechanisms before it triggers a pass and gets the next maneuver.


Code:
public class DriveForward extends Maneuver{
    private static int BALLS_EXPECTED = 3;

    private int ballCount = 0;

    public DriveForward()
    {
        super(ManeuverType.DRIVE_F, ManeuverType.DF_TO);
    }
    
    public void pass()
    {
        ballCount++;
        if(ballCount >= BALLS_EXPECTED)
        {
            Bob.getInstance().setManeuver(pass);
            Bob.getInstance().getManeuver().start();
        }
        else
            ballCount++;
            
    }
__________________
"Never let your schooling interfere with your education" -Mark Twain

Last edited by mwtidd : 09-04-2010 at 12:13.
 


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
Traction Control in Autonomous? dboisvert C/C++ 4 07-03-2009 11:11
control 4 motors in autonomous? pinballwizard96 NI LabVIEW 4 10-02-2009 12:03
pic: Autonomous Control Sample Squall Extra Discussion 4 07-04-2005 01:53
OI/Control Board LEDs during Autonomous ace123 Programming 1 12-02-2005 19:38
Autonomous to Manual control? Lint_Ninja Programming 5 16-02-2004 21:48


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

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