View Single Post
  #2   Spotlight this post!  
Unread 26-01-2017, 17:22
jreneew2's Avatar
jreneew2 jreneew2 is offline
Alumni of Team 2053 Tigertronics
AKA: Drew Williams
FRC #2053 (TigerTronics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Vestal, NY
Posts: 213
jreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura aboutjreneew2 has a spectacular aura about
Re: SendableChoosers are causing me grief!

This worked for us:

In Robot.h
Code:
private:
    frc::SendableChooser<frc::Command*> autoChooser;
    std::unique_ptr<frc::Command> selectedMode;
In Robot.cpp
Code:
Robot::RobotInit() {
    autoChooser.AddDefault("Do Nothing", new DoNothing(15));
    autoChooser.AddObject("Gear Align Center", new GearAlignCenter());

    SmartDashboard::PutData("Auto Chooser", &autoChooser);
}

Robot::AutonomousInit() {
    selectedMode.reset(autoChooser.GetSelected());
    if(selectedMode != nullptr) {
        selectedMode->Start();
    }
}
Good luck with the season!

Best Wishes,
Drew

Last edited by jreneew2 : 26-01-2017 at 17:34.
Reply With Quote