View Single Post
  #6   Spotlight this post!  
Unread 12-12-2012, 22:13
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Implementing a switchable control scheme

I am running Java, just for the record.

So I have this in OI:

Code:
public void switcher() {
        driveSwitch = new SendableChooser();
        driveSwitch.addDefault("Joystick Arcade (1)", new JoystickArcade());
        driveSwitch.addDefault("Joystick Arcade (2)", new DualJoystickArcade());
        driveSwitch.addDefault("Joystick Tank", new DualJoystickTank());
        driveSwitch.addObject("Kinect", new KinectCommand());
        SmartDashboard.putData("Drive Switch", driveSwitch);  
    }
And this in RobotMain:

Code:
public void testInit() {
        autonomousCommand.cancel();
        teleopCommand.cancel();
        msg.printLn("[mode] Dev");
        CommandBase.oi.initLiveWindow();
        msg.printLn("[status] LiveWindow initialized");
        CommandBase.oi.switcher();
        
        driveCommand = (Command) CommandBase.oi.driveSwitch.getSelected();        
        driveCommand.start();                
    }
    
    public void testPeriodic() {
        LiveWindow.run();      
    }

This code would allow it to switch, but it would require switching modes beforehand. My question is, how should I set it up to be able to switch modes on the fly? I feel like calling driveCommand.start() over and over in testPeriodic wouldn't work so well, but I have no idea. How should I check the current state of the SendableChooser against the current command running?
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 12-12-2012 at 22:24.