Question on Autonomous Mode

So, rookie team, question:

Can we have any way to switch commands during Autonomous from the driver station?

I.E. Have a big setup of buttons we could push for the obstacle we’re coming up against?

We’ve got it driving forward and such, but we’re struggling to figure out how the bot should know how to deal with the obstacle in front of it, due to the high amount of variation.

Unfortunately during autonomous you can not directly interact or control the robot. Just try to position yourself in such a way that you can run the autonomous code you are writing now. Or write multiple codes so that right before the match you can be prepared for the difference in obstacles :smiley:

Use SmartDashboard to choose which autonomous you need before the match. It lets you add things like radio buttons to the screen, and you can use those to choose which defense is in front of you. Quick snippet of code:

//Initialize the SendableChooser
public void robotInit() {
	SendableChooser chooser = new SendableChooser();
	chooser.initTable(NetworkTable.getTable("Defense Chooser"));
	chooser.addDefault("Low Bar", "lowbar");
	chooser.addObject("Ramparts", "ramparts");
	chooser.addObject("Moat", "moat");
	chooser.addObject("Cheval de Frise", "cheval");
	chooser.addObject("Rock Wall", "rockwall");
	//ect...add the rest of the defenses

	SmartDashboard.putData("Autonomous Defense Chooser", chooser);
}


...


//Use the below code to check which defense is selected
        
String defense = chooser.getSelected().toString();
        
if (defense.equals("lowbar")) {
	//Lowbar auto
} else if (defense.equals("ramparts")) {
	//ramparts auto
} else if (defense.equals("moat")) {
	//moat auto
}
//ect...add the rest of the if/elses

The SendableChooser class lets you create a set of radio buttons. You use SendableChooser.addDefault() and SendableChooser.addObject() to add different options to it. The two Strings arguments, in order, are display name and an internal value. The first String (the display name) is what people see in SmartDashboard. The second String (the internal value) is what is returned when you call SendableChooser.getSelected(). Hope this helps!

Can we have any way to switch commands during Autonomous from the driver station?

No, not DURING autonomous per G14

G14 During AUTO, DRIVE TEAMS may not directly or indirectly interact with ROBOTS or OPERATOR
CONSOLES unless for personal safety, OPERATOR CONSOLE safety, or pressing an E-Stop for ROBOT safety.

However,

Have a big setup of buttons we could push for the obstacle we’re coming up against?

Yes, this is allowed as long as you push the button before autonomous starts. It is ok to have multiple auto modes programmed for each defense and have a big setup of buttons to choose the auto mode you wish to run, you just have to select it before the match starts.

Recommendation: Add an input on your dashboard which lets you choose one of multiple autonomous programs to run. Ensure your drive team is trained in its usage and that they select the correct obstacle prior to match start. This will accomplish what you require.

Perfect, that’s exactly what I was hoping you’d say. We’ve got auto code done for every obstacle so far that’s testing solid, so I’m wanting to make sure we could pick it to, you know, do the right obstacle.

Thanks!

This has pretty much been covered, but I’ll go into a bit more detail regarding the default dashboard options.

The second tab of the dashboard, labeled Basic, has buttons, LEDs, sliders, and strings that are already tied to Network table variables named “DB/Button 0”, etc. You can also rename the controls from your robot code by setting the network table string array “DB/Button Names”, etc. The default LV code shows how to do this in Begin.vi. These controls can be used however you like, to set default speeds, directions, or names of options.

This year a new selector was added to the Drive tab that displays a list of autonomous beneath the gyro indicator. The names shown can be set on the robot into an array of strings variable called “Auto List” and the value selected by the drive team will be available in “Auto Selector”.

SmartDashboard has a similar capability using the SendableChooser.

Greg McKaskle

IMHO, you might want to consider these options:

  1. Which defense you are going over (or just drive up to get the reach points, or none if you are the spy bot)
  2. Which goal you are attempting (or not, since there are only 2 low goals, and you might be the bot that sits it out)
  3. If you are going for a goal, which position you are starting in
  4. Do you delay to give the other bots more time to clear the path (you don’t want to cross, and collide with another bot driving in front of you to get to a goal.
  5. Do you back out of the low goal to give another bot the opportunity to go after you.

Sounds like a great reason to get your team members out there scouting. Once you get your match list get out there and talk to your alliance partners. Make sure your scouts know the capabilities of your robot, and work with your Alliance mates to determine which defense it makes the most sense for you to start in. There is no rule that states that you must start directly in front of your driver station.

As it stands 2 groups of defenses (B&D) are pretty straight forward to pass, especially if you are using 8" wheels, and add the Low Bar (E) to this list if you are under 14". This alone would allow you to fit into any strategy your alliance might come up with because you will always have a Defense you can pass. Though It will be awesome to see robots taking on the A&C Defenses in AUTO.

We’ve put physical switches on our chassis that we have set before auto mode began to let the robot select the proper autonomous mode

If you don’t mind, was there any particular reason you chose to use physical switches over using SmartDashboard or the FRC dashboard? Just a matter of comfort, or something else? Seems like a lot less flexible option to me, but I’m wondering if there’s something else.

OP, I think you’re using RobotPy [you had posted on the python forum earlier]?

RobotPy’s wpilib utilities has some really useful autonomous tooling to allow you to select multiple modes via SmartDashboard (each .py file in the autonomous directory is automatically detected and added to the options), and also a really easy to use state machine helper for quick and easy autonomous mode creation.


from robotpy_ext.autonomous import StatefulAutonomous
        
class DriveForward(StatefulAutonomous):

    MODE_NAME = 'Drive Forward'

    def initialize(self):
        pass

    @timed_state(duration=0.5, next_state='drive_forward', first=True)
    def drive_wait(self):
        pass

    @timed_state(duration=5)
    def drive_forward(self):
        self.drive.move(0, 1, 0)

Check it out at http://robotpy-wpilib-utilities.readthedocs.org/en/latest/robotpy_ext.autonomous.html

We also have a sample program that uses both the stateful autonomous helper and the automatic autonomous chooser.

We’ve gone both ways, they each have pros and cons.

Doing switches on the robot is reliable, but you can occasionally forget to set the switches before leaving the field (when you would still have a chance to fix it on the DS).

Doing it on the DS is fine, but you either have to make the settings stick across power downs, or else have enough time to set the autonomous in the interval between when your DS makes contact with the robot and when the match starts. If you are having trouble getting the DS talking to the bot (happens…), you might not have enough time.

DS with persistence seems to be best middle ground; you can set it while in queue, and fix it at the last second if needed.