-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.cpp
More file actions
93 lines (79 loc) · 2.4 KB
/
Robot.cpp
File metadata and controls
93 lines (79 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "Commands/Command.h"
#include "Commands/ExampleCommand.h"
#include "CommandBase.h"
#include "Resources.h"
#include "Data.h"
class Robot: public IterativeRobot
{
private:
std::unique_ptr<Command> autonomousCommand;
SendableChooser *chooser;
Data *library;
void RobotInit()
{
CommandBase::init();
chooser = new SendableChooser();
chooser->AddDefault("Default Auto", new ExampleCommand());
//chooser->AddObject("My Auto", new MyAutoCommand());
SmartDashboard::PutData("Auto Modes", chooser);
library = Data::getInstance();
}
/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
* the robot is disabled.
*/
void DisabledInit()
{
}
void DisabledPeriodic()
{
Scheduler::GetInstance()->Run();
}
/**
* 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 code to get the auto name from the text box
* below the Gyro
*
* You can add additional auto modes by adding additional commands to the chooser code above (like the commented example)
* or additional comparisons to the if-else structure below with additional strings & commands.
*/
void AutonomousInit()
{
/* std::string autoSelected = SmartDashboard::GetString("Auto Selector", "Default");
if(autoSelected == "My Auto") {
autonomousCommand.reset(new MyAutoCommand());
} else {
autonomousCommand.reset(new ExampleCommand());
} */
autonomousCommand.reset((Command *)chooser->GetSelected());
if (autonomousCommand != NULL)
autonomousCommand->Start();
}
void AutonomousPeriodic()
{
Scheduler::GetInstance()->Run();
}
void TeleopInit()
{
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (autonomousCommand != NULL)
autonomousCommand->Cancel();
library = Data::getInstance();
}
void TeleopPeriodic()
{
Scheduler::GetInstance()->Run();
// Calls Teleop run here
library->getTele()->run();
}
void TestPeriodic()
{
LiveWindow::GetInstance()->Run();
}
};
START_ROBOT_CLASS(Robot)