|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Autonomous Control
Quote:
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);
}
}
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());
}
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++;
}
Last edited by mwtidd : 09-04-2010 at 12:13. |
|
#2
|
||||
|
||||
|
Re: Autonomous Control
ADK architecture:
================= Robot ================== | (Brains)ManeuverFactory - EventManager - Controller(Auton,Operator) ================== | ================ Mechanism Everything above is extendable except the EventManager. All basic teams would need to implement is: ManeuverFactory - Robot - Mechanism everything else should be able to work as a black box if they want it to. I hope this helps... |
|
#3
|
||||
|
||||
|
Re: Autonomous Control
Okay, so I finally understand how the ADK works:
The "robot" consists of three components:
The maneuver factory can only perform one maneuver at a time (to prevent simultaniously sending two different values to a mechanism). When the maneuver is changed, the mechanisms don't necessarily stop whatever they were doing and accept the new command. Some actions require completion before a new one can be issued. (for example, you don't want a kicker to try to extend when it's already extended; it must retract for two seconds to avoid penalty.) How accurate is that? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |