View Single Post
  #3   Spotlight this post!  
Unread 06-03-2015, 00:14
kylelanman's Avatar
kylelanman kylelanman is online now
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 186
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: Use of SmartDashboard::GetString()

A better solution would be to use a SenableChooser. The following is for command based but sendable chooser uses void* so the sky is the limit as to what you send. You can send a command, number, or some other pointer.

Code:
class Robot : public IterativeRobot
{
private:
    SendableChooser* autoChooser;

void RobotInit {
    autoChooser = new SendableChoose();
    autoChooser->AddDefault("Auto 1", new Auto1Command());
    autoChooser->AddObject("Auto 2", new Auto2Command());
    autoChooser->AddObject("Auto 3", new Auto3Command());
    SmartDashboard::PutData"Auto Chooser", autoChooser;
}

void AutonomousInit() {
    Command* auton = (Command*)autoChooser->GetSelected();
    if (auton) {
        auto->Start();
    }
}

void TeleopInit() {
    if (auton) {
        auto->Cancel();
    }
}
};
There is more documentation here.
http://wpilib.screenstepslive.com/s/...smartdashboard
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

Reply With Quote