View Single Post
  #4   Spotlight this post!  
Unread 03-18-2016, 02:55 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by RSNovi View Post
Thank you for sharing your code with me. It is pretty similar to what we have, although yours is more elegant and we put all the code in Robot.java. For some reason we are getting sporadic results. I was thinking that we needed to make sure we toggled the buttons after the robot was connected to the competition system. It was working fine during our normal testing, but something is different when we connect to the competition system. We ended just hard coding the auto choice at our last competition which made it always work, but there were times we needed to change it.

If you get a chance please let me know if you see anything
public void robotInit() {
RobotMap.init();
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
driveTrain = new DriveTrain();
ballArm = new BallArm();
pneumaticArm = new PneumaticArm();

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

autoChooser = new SendableChooser();
autoChooser.addDefault("Do Nothing 15 sec", new DoNothing(15));
autoChooser.addObject("Front of low bar", new AutoFrontOfLowBarGroup());
autoChooser.addObject("BW Front of low bar", new AutoFrontOfLowBarBackwardGroup());
autoChooser.addObject("Drive straight forward", new AutoDriveStraightForwardGroup());
autoChooser.addObject("Turn right in front of low bar", new AutoTurnRightLowBar());
autoChooser.addObject("Custom mode", new AutoCustomGroup());
SmartDashboard.putData("Autonomous mode chooser", autoChooser);


SmartDashboard.putData(Scheduler.getInstance());
RobotMap.pneumaticArmCompressor.setClosedLoopContr ol(true);

//autonomousCommand = new DoNothing();

// OI must be constructed after subsystems. If the OI creates Commands
//(which it very likely will), subsystems are not guaranteed to be
// constructed yet. Thus, their requires() statements may grab null
// pointers. Bad news. Don't move it.
oi = new OI();

// instantiate the command used for the autonomous period

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS


// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
// autonomousCommand = new LookBothWays();

new DisplayDashboard();

}

/**
* This function is called when the disabled button is hit.
* You can use it to reset subsystems before shutting down.
*/
public void disabledInit(){

}

public void disabledPeriodic() {
Scheduler.getInstance().run();
}

public void autonomousInit() {
// schedule the autonomous command (example)
autonomousCommand = (Command) autoChooser.getSelected();
if (autonomousCommand !=null) autonomousCommand.start();
SmartDashboard.putData(Scheduler.getInstance());
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic()
{
SmartDashboard.putData(Scheduler.getInstance());
Scheduler.getInstance().run();

}
Nothing jumps out at me but then again I am not familiar with Command based code. When you said it doesn't work very well, what were the issues/symptoms? Did you get a null back when calling getSelected()? Did you get an exception? What is the exact failure? From the SmartDashboard and SendableChooser's point of view, that should work. However, one major difference between your code and ours is that we only "newing" an auto strategy when it is selected whereas you are newing all your strategies (commands) and added them to the chooser. There shouldn't be anything wrong with it but I am just trying to figure out if the problem lies in the command based code. Again, I am not familiar with command-based code, but depends on what failure you were seeing, you may want to look at it from a different angle.
__________________

Last edited by mikets : 03-18-2016 at 03:04 PM.
Reply With Quote