|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
Why not use a SendableChooser with SmartDashboard?
|
|
#2
|
|||
|
|||
|
Re: methods for Switchable Autonomous Modes
How would I do that? (I have only ever worked with the default dashboard, and I only used the camera feed from that)
-Davis |
|
#3
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
Quote:
Code:
public void robotInit() {
// Create a switching autonomous mode
autoSwitcher = new SendableChooser();
autoSwitcher.addDefault("Auto 0", new Auton0());
autoSwitcher.addObject("Auto 1", new Auton1());
autoSwitcher.addObject("Auto 2", new Auton2());
SmartDashboard.putData("Auto Switcher", autoSwitcher);
}
public void autonomousInit() {
autonomousCommand = autoSwitcher.getSelected();
autonomousCommand.start();
}
|
|
#4
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
Yes! I can share my experience! In my opinion, you should go with putting a toggle switch or rotary switch on the robot itself. It's extremely easy to do (just analog). We tried using
Code:
switch(variable) //switch variable
{
case ??: //if variable == something
case ???: //if variable == something else
}
|
|
#5
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
If you are looking for an on-robot switch like ekapalka is saying, you could use this:
https://www.estoprobotics.com/estore...d&productId=63 Which would give you the ability to choose between 8 different autonomous modes using the same logic he used. I still prefer SendableChooser, but if you aren't looking to mess around with new dashboards and such it's definitely an option. (note: it does take up 3 DIO ports on the sidecar, and I know my team is sitting around 12-13 out of 14 atm...) |
|
#6
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
I like using the DIO's on the I/O tab of the drivers station. You had mentioned that and yes it's easily doable. Something like this:
Code:
//declare the driver station - perhaps globally in the robot
DriverStation* driverStation;
//... then in your init code grab the instance
driverStation = DriverStation::GetInstance();
// then in autonomous mode read the inputs to decide
// Start with just 1 through 8 because you can actually label them on
//the driver station what they are
if (driverStation->GetDigitalIn(1)) {
AutoRoutine1();
} else if (driverStation->GetDigitalIn(2)) {
AutoRoutine2();
} else if (driverStation->GetDigitalIn(3)) {
AutoRoutine3();
}
Code:
if (driverStation->GetDigitalIn(1) && driverStation->GetDigitalIn(2)) {
AutoRoutine9();
} else if (driverStation->GetDigitalIn(1) && driverStation->GetDigitalIn(3)) {
AutoRoutine10();
} else if (driverStation->GetDigitalIn(1)) {
AutoRoutine1();
} else if (driverStation->GetDigitalIn(2)) {
AutoRoutine2();
} else if (driverStation->GetDigitalIn(3)) {
AutoRoutine3();
}
|
|
#7
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
Our team came up with a pretty easy method using GPIO and a switch that toggles on and off. Off would be the left side, and on would be the right side. Coding it is incredibly easy because all you need to do is set the two autonomous modes for true and false on the readout of the GPIO. This was a method we came up with right before packaging our bot, and if you are looking for a quick and easy solution I would definitely recommend keeping it simple.
|
|
#8
|
|||
|
|||
|
Re: methods for Switchable Autonomous Modes
To add one more alternative method to the mix, I typically monitor the joystick buttons during disabled mode, if a pair of buttons gets held for 2 seconds, I change the autonomous mode variable.
When the robot goes into autonomous, I have a switch case that calls the different routines based on the autonomous mode variable. It has the disadvantage that it doesn't persist through reset, so if you restart the match or reboot the robot it needs to be set back to the mode you want. It works well if you use the same mode 90% of the time, and have other modes for flexibility. The advantage is that you don't need any hardware, the implementation is entirely in the robot code. |
|
#9
|
||||
|
||||
|
Re: methods for Switchable Autonomous Modes
Really folks - providing you use Smartdashboard, the simplest and most intuitive way to do autonomous is SendableChooser. You don't even have to have real 'Commands' as shown above. The pointer given to AddObject is just a pointer -- point it back to the string itself and compare at autonomous time to decide what the user has chosen. It's super elegant and flexible over time. No need for switches, documenting said switches, holding down buttons, etc.
bob |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|