Go to Post Like a wizard, Car Nack is never late. He always arrives precisely when he meets you. - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-03-2016, 20:06
RSNovi RSNovi is offline
Registered User
FRC #6081
 
Join Date: Jan 2016
Location: Grass Lake
Posts: 12
RSNovi is an unknown quantity at this point
Access the Auto List on Driver Station in Java

Hello All,

Last weekend we had our first competition. We were using the Smart Dashboard with radio buttons to select our various autonomous modes. It didn't work very well and many others told us they had difficulty using the Smart Dashboard for this purpose. Even though the Smart Dashboard selected the desired autonomous mode I think it had to be selected after the laptop was connected to the robot through the competition system. It was quite error prone for the kids. I would like to use LV Driver Station to choose the autonomous mode.

Under the Drive tab in the driver station there is a blank drop down. Does anyone know how to access this drop dow?. Essentially setup strings and then read from it. I read a little bit, but it all seems to be describing LV to access it via "Auto List" and "Auto Selector"

Thanks.

Chris
Reply With Quote
  #2   Spotlight this post!  
Unread 10-03-2016, 20:19
RufflesRidge RufflesRidge is online now
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Access the Auto List on Driver Station in Java

Here's some sample code that should get you started.

Class members:
final String defaultAuto = "Default";
final String customAuto = "My Auto";
String[] autoList = {defaultAuto, customAuto};
String autoSelected;

in robotInit():
NetworkTable table = NetworkTable.getTable("SmartDashboard");
table.putStringArray("Auto List", autoList);

in autonomousInit():
autoSelected = (String) chooser.getSelected();
System.out.println("Auto selected: " + autoSelected);

in autonomousPeriodic():
switch(autoSelected) {
case customAuto:
//Put custom auto code here
break;
case defaultAuto:
default:
//Put default auto code here
break;
}
Reply With Quote
  #3   Spotlight this post!  
Unread 10-03-2016, 22:25
BenBernard BenBernard is offline
Registered User
FRC #5687 (The Outliers)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Portland, ME
Posts: 37
BenBernard is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

Regarding the SmartDashboard, we've had the same issues. We've told our drive team to make each selection twice, and that seems to do the trick. We will be moving (running?) away from the SmartDashboard in future events.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-03-2016, 16:03
RSNovi RSNovi is offline
Registered User
FRC #6081
 
Join Date: Jan 2016
Location: Grass Lake
Posts: 12
RSNovi is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

Thank you Ruffles for the advice and I appreciate the validation of our troubles Ben. I will try this code the next time the team meets.

Chris

Last edited by RSNovi : 11-03-2016 at 20:03.
Reply With Quote
  #5   Spotlight this post!  
Unread 11-03-2016, 19:41
RufflesRidge RufflesRidge is online now
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by RufflesRidge View Post

in autonomousInit():
autoSelected = (String) chooser.getSelected();
System.out.println("Auto selected: " + autoSelected);
Sorry!!! This part of the code is wrong (that's the code for sendable chooser).

should be something like this instead:
autoSelected = SmartDashboard.getString("Auto Selector", defaultAuto);
Reply With Quote
  #6   Spotlight this post!  
Unread 14-03-2016, 00:58
GreyingJay GreyingJay is offline
Robonut
AKA: Mr. Lam
FRC #2706 (Merge Robotics)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Ottawa, Canada
Posts: 733
GreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond reputeGreyingJay has a reputation beyond repute
Re: Access the Auto List on Driver Station in Java

My team decided to use a hardware solution instead. We put a 12-position rotary switch on the robot. It has a little led to indicate which position is selected and it's easy to read using an analog input on the Roborio.

http://www.robotshop.com/en/rotary-e...module-v1.html
Reply With Quote
  #7   Spotlight this post!  
Unread 15-03-2016, 12:40
rdmarsh rdmarsh is offline
Junior Mentor - Programming
FRC #2186 (Dogs of Steel)
Team Role: Mentor
 
Join Date: Oct 2012
Rookie Year: 2008
Location: Herndon, VA
Posts: 6
rdmarsh is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

We had a similar problem but with only two auto modes (cross low bar or don't move). We wound up using the throttle on a joystick for it - there is no rule against reading joystick inputs from the driver station during autonomous, just against drivers touching any of them during that period. If you have more than two modes, you might try building a multi-position selector you can hook up over USB using a TI Launchpad.
Reply With Quote
  #8   Spotlight this post!  
Unread 15-03-2016, 13:13
lethc's Avatar
lethc lethc is offline
#gkccurse
AKA: Becker Lethcoe
FRC #1806 (S.W.A.T.)
Team Role: Alumni
 
Join Date: Nov 2012
Rookie Year: 2013
Location: Smithville, MO
Posts: 118
lethc will become famous soon enough
We had the same issue last year using LabVIEW but after switching to Java this year we've had no problems with SmartDashboard or Sendable Choosers.
__________________
2016: Greater Kansas City Regional Finalists, Oklahoma Regional Winners, Tesla Semifinalists, IRI Quarterfinalists
2015: Greater Kansas City Regional Finalists, Oklahoma Regional Winners, Tesla Quarterfinalists, IRI Winners
2014: Central Illinois Regional Quarterfinalists, Greater Kansas City Regional Finalists, Newton Semifinalists
2013: Greater Kansas City Regional Winners, Oklahoma Regional Winners, Galileo Quarterfinalists
Reply With Quote
  #9   Spotlight this post!  
Unread 16-03-2016, 05:05
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: 666
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
Hello All,

Last weekend we had our first competition. We were using the Smart Dashboard with radio buttons to select our various autonomous modes. It didn't work very well and many others told us they had difficulty using the Smart Dashboard for this purpose. Even though the Smart Dashboard selected the desired autonomous mode I think it had to be selected after the laptop was connected to the robot through the competition system. It was quite error prone for the kids. I would like to use LV Driver Station to choose the autonomous mode.

Under the Drive tab in the driver station there is a blank drop down. Does anyone know how to access this drop dow?. Essentially setup strings and then read from it. I read a little bit, but it all seems to be describing LV to access it via "Auto List" and "Auto Selector"

Thanks.

Chris
We are using the SendableChooser and it works great with the SmartDashboard. We have 8 choices in our autonomous. The list is displayed on the SmartDashboard and we can click and select any one of them. Here is our code using it.
https://github.com/trc492/Frc2016Fir...utonomous.java
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 17-03-2016, 15:39
RSNovi RSNovi is offline
Registered User
FRC #6081
 
Join Date: Jan 2016
Location: Grass Lake
Posts: 12
RSNovi is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by mikets View Post
We are using the SendableChooser and it works great with the SmartDashboard. We have 8 choices in our autonomous. The list is displayed on the SmartDashboard and we can click and select any one of them. Here is our code using it.
https://github.com/trc492/Frc2016Fir...utonomous.java
Thank you. Does it matter when you make the selection? For instance does it matter for you whether you make the selection prior to the robot being connected at the competition?
Reply With Quote
  #11   Spotlight this post!  
Unread 18-03-2016, 02:24
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: 666
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. Does it matter when you make the selection? For instance does it matter for you whether you make the selection prior to the robot being connected at the competition?
It doesn't matter. The selection actually sticks meaning even for the next match if you don't select anything else, the previous selection is still in effect until you select something different.
__________________
Reply With Quote
  #12   Spotlight this post!  
Unread 18-03-2016, 13:50
RSNovi RSNovi is offline
Registered User
FRC #6081
 
Join Date: Jan 2016
Location: Grass Lake
Posts: 12
RSNovi is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by mikets View Post
It doesn't matter. The selection actually sticks meaning even for the next match if you don't select anything else, the previous selection is still in effect until you select something different.
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();

}
Reply With Quote
  #13   Spotlight this post!  
Unread 18-03-2016, 14:55
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: 666
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 : 18-03-2016 at 15:04.
Reply With Quote
  #14   Spotlight this post!  
Unread 18-03-2016, 19:50
RSNovi RSNovi is offline
Registered User
FRC #6081
 
Join Date: Jan 2016
Location: Grass Lake
Posts: 12
RSNovi is an unknown quantity at this point
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by mikets View Post
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.
I appreciate the help thinking through this.

When the game was activated I think it just ran the default of Do Nothing even one of the Low Bar options was selected. No errors that I know of. The one time we did get it to work I was at the driver station and i toggled the buttons back and forth after the robot was connected to the system. After a few failures we just hard coded the one choice.

During practicing at our school the buttons seemed to work fine.

I will look into newing all of the commands.

Last edited by RSNovi : 18-03-2016 at 19:59.
Reply With Quote
  #15   Spotlight this post!  
Unread 19-03-2016, 08:37
RufflesRidge RufflesRidge is online now
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Access the Auto List on Driver Station in Java

Quote:
Originally Posted by RSNovi View Post
I appreciate the help thinking through this.

When the game was activated I think it just ran the default of Do Nothing even one of the Low Bar options was selected. No errors that I know of. The one time we did get it to work I was at the driver station and i toggled the buttons back and forth after the robot was connected to the system. After a few failures we just hard coded the one choice.

During practicing at our school the buttons seemed to work fine.

I will look into newing all of the commands.
I wonder if the different behavior you are seeing vs. the other poster is related to you using command based vs. them not. Because your data in each option is an object, it may be considered to be different each time where if there's is a string or something, the dashboard side may see it as the same. That may trigger the behavior difference, if the list is "different" it's possible you need to make the selection after the robot links to give you the new value for the object.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi