View Single Post
  #3   Spotlight this post!  
Unread 19-08-2012, 01:12
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: Switching between Kinect drive / Joystick drive / Autonomous drive

Thanks, I'll try it out when I get a chance.

Here's my "switch" code, though I'm not sure whether it's going to work.

Code:
Command autonomousCommand, teleopCommand;
    DriverStation driverstation = DriverStation.getInstance();
    Messager msg = new Messager();
    OI kinectSwitch = new OI();
    
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        // instantiate the command used for the autonomous period
        msg.printLn("Initializing Robot");    
        if(kinectSwitch.getKinectStatus()) {
            autonomousCommand = new KinectCommand(); 
        } else {
            autonomousCommand = new AutonomousCommand();
        }
        teleopCommand = new TeleopCommand();
        AxisCamera camera = AxisCamera.getInstance();
        camera.writeMaxFPS(18);
        SmartDashboard.putData(Scheduler.getInstance());
        msg.printLn("Robot Initialized");
             
        // Initialize all subsystems
        CommandBase.init();       
    }

From OI.java:

Code:
InternalButton kinectButton = new InternalButton();
.............

public boolean getKinectStatus() {
        return kinectButton.get();
    }
                       
.............

    public OI(){
        SmartDashboard.putData("Enable Kinect", kinectButton);
}


(EDIT)

I've been looking at an alternate way of doing it via the "sendableChooser" method of SmartDashboard.

Code:
NetworkTable.initialize();
        SendableChooser autonomousSwitch = new SendableChooser();
        autonomousSwitch.addDefault("Default autonomous", new AutonomousCommand());
        autonomousSwitch.addObject("Kinect hybrid", new KinectCommand());
        SmartDashboard.putData("Kinect Switch", autonomousSwitch);

autonomousCommand = (Command) autonomousSwitch.getSelected();

Last edited by F22Rapture : 19-08-2012 at 12:52.
Reply With Quote