mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
|
|
/*----------------------------------------------------------------------------*/
|
||
|
|
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||
|
|
/* the project. */
|
||
|
|
/*----------------------------------------------------------------------------*/
|
||
|
|
|
||
|
|
#include <iostream>
|
||
|
|
#include <memory>
|
||
|
|
#include <string>
|
||
|
|
|
||
|
|
#include <IterativeRobot.h>
|
||
|
|
#include <LiveWindow/LiveWindow.h>
|
||
|
|
#include <SmartDashboard/SendableChooser.h>
|
||
|
|
#include <SmartDashboard/SmartDashboard.h>
|
||
|
|
|
||
|
|
class Robot : public frc::IterativeRobot {
|
||
|
|
public:
|
||
|
|
void RobotInit() {
|
||
|
|
chooser.AddDefault(autoNameDefault, autoNameDefault);
|
||
|
|
chooser.AddObject(autoNameCustom, autoNameCustom);
|
||
|
|
frc::SmartDashboard::PutData("Auto Modes", &chooser);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* This autonomous (along with the chooser code above) shows how to
|
||
|
|
* select
|
||
|
|
* between different autonomous modes using the dashboard. The sendable
|
||
|
|
* chooser code works with the Java SmartDashboard. If you prefer the
|
||
|
|
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
|
||
|
|
* GetString line to get the auto name from the text box below the Gyro.
|
||
|
|
*
|
||
|
|
* You can add additional auto modes by adding additional comparisons to
|
||
|
|
* the
|
||
|
|
* if-else structure below with additional strings. If using the
|
||
|
|
* SendableChooser make sure to add them to the chooser code above as
|
||
|
|
* well.
|
||
|
|
*/
|
||
|
|
void AutonomousInit() override {
|
||
|
|
autoSelected = chooser.GetSelected();
|
||
|
|
// std::string autoSelected = SmartDashboard::GetString("Auto
|
||
|
|
// Selector", autoNameDefault);
|
||
|
|
std::cout << "Auto selected: " << autoSelected << std::endl;
|
||
|
|
|
||
|
|
if (autoSelected == autoNameCustom) {
|
||
|
|
// Custom Auto goes here
|
||
|
|
} else {
|
||
|
|
// Default Auto goes here
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void AutonomousPeriodic() {
|
||
|
|
if (autoSelected == autoNameCustom) {
|
||
|
|
// Custom Auto goes here
|
||
|
|
} else {
|
||
|
|
// Default Auto goes here
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void TeleopInit() {}
|
||
|
|
|
||
|
|
void TeleopPeriodic() {}
|
||
|
|
|
||
|
|
void TestPeriodic() { lw->Run(); }
|
||
|
|
|
||
|
|
private:
|
||
|
|
frc::LiveWindow* lw = LiveWindow::GetInstance();
|
||
|
|
frc::SendableChooser<std::string> chooser;
|
||
|
|
const std::string autoNameDefault = "Default";
|
||
|
|
const std::string autoNameCustom = "My Auto";
|
||
|
|
std::string autoSelected;
|
||
|
|
};
|
||
|
|
|
||
|
|
START_ROBOT_CLASS(Robot)
|