View Single Post
  #4   Spotlight this post!  
Unread 08-04-2010, 22:39
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

So the way it is working currently, each mechanism has its own task manager, and its own queue. There may have to be a dispatcher taking all the events and putting them in the appropriate queues, and getting the "pass/fail/timeout" back from the mechanism event managers, so that it's easily accessible by the planner.
One goal of this is to have rookie teams be able to use this, so I opted to not go with a queue. In my case the maneuver factory handles all of the pass fail timeout options.

As a maneuver changes it registers the maneuver with the robot. Each mechanisms just reference the robot for the current maneuver. This eliminates the need for different types of ManeuverEvents beyond pass fail and change.

The EventManager also sends all maneuver change events to all mechanisms, all mechanism events to all of the mechanisms. This allows us to keep the event manager unchanged, simplifying to code for rookies.

all a rookie team would have to implement:
Robot
Maneuver Factory (could take a template)
Mechanisms

example maneuver factory
for a robot which drives straight, shoots, repeat.

(draw out the state machine, its easier to picture it way)
..Maneuver(passManeuver,failManeuver,toManeuver);

Code:
public class ManeuverFactory implements IManeuverFactory{
    private static ManeuverFactory factory = new ManeuverFactory();

    private static int mode = 0;

    private ManeuverFactory(){}

    public Maneuver get(String type){
       Maneuver man = null;

       if(type.equalsIgnoreCase(Maneuver.INIT)){
            man = new Initialize();
            man.setNext(ManeuverType.STRAIGHT, Maneuver.INIT, Maneuver.HALT);
       }else if (type.equalsIgnoreCase(ManeuverType.STRAIGHT)){
           man = new Maneuver(ManeuverType.STRAIGHT, ManeuverType.STRAIGHT_TO) {};
           man.setNext(ManeuverType.SHOOT, Maneuver.HALT, Maneuver.HALT);
       }else if (type.equalsIgnoreCase(ManeuverType.SHOOT)){
           man = new Maneuver(ManeuverType.SHOOT, ManeuverType.SHOOT_TO) {};
           man.setNext(ManeuverType.STRAIGHT, ManeuverType.SHOOT, Maneuver.HALT);
       }else if (type.equalsIgnoreCase(Maneuver.OPERATOR)){
            man = new Maneuver(Maneuver.OPERATOR, Maneuver.OPERATOR_TO) {};
            man.setNext(Maneuver.OPERATOR, Maneuver.INIT, Maneuver.OPERATOR);
       }
       return man;
    }

    public static IManeuverFactory getInstance() {
        return factory;
    }
}
__________________
"Never let your schooling interfere with your education" -Mark Twain