blob: a37ec6f9c1e3e6bb1d879e29e702174c97bb5b18 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#include <stdio.h>
2#include <stdlib.h>
3
4#include "WPILib/Compressor.h"
5
6#include "aos/aos_core.h"
7#include "aos/crio/controls/ControlsManager.h"
8#include "aos/common/Configuration.h"
9#include "aos/crio/aos_ctdt.h"
10#include "aos/crio/motor_server/CRIOControlLoopRunner.h"
11#include "aos/crio/motor_server/MotorServer.h"
12
13namespace aos {
14namespace crio {
15
16// Everything gets an explicit Start call here before calling all of the init
17// functions because it means that all static variables will be initialized
18// before anything actually starts running. It also means that everything will
19// be initialized before any of the init functions start trying to register
20// themselves etc.
21void ControlsManager::StartCompetition() {
22 printf("aos::ControlsManager::RobotMain\n");
23 (new Compressor(14, 1))->Start();
24
25 logging::Start();
26 LOG(INFO, "logging started\n");
27
28 GetWatchdog().SetEnabled(false);
29 LOG(INFO, "disabled watchdog\n");
30
31 RegisterControlLoops();
32 LOG(INFO, "registered control loops\n");
33
34 // CRIOControlLoopRunner calls part of MotorServer, so MotorServer has to get
35 // initialized first.
36 MotorServer::Start();
37 LOG(INFO, "MotorServer started\n");
38 CRIOControlLoopRunner::Start();
39 LOG(INFO, "cRIO control loops started\n");
40
41 LOG(INFO, "calling init functions\n");
42 aos_call_init_functions();
43 LOG(INFO, "initialized\n");
44
45 // Wait forever so that this task doesn't end to avoid confusing any brittle
46 // FIRST code that might be hiding somewhere.
47 while (true) {
48 select(0, NULL, NULL, NULL, NULL);
49 }
50}
51
52} // namespace crio
53} // namespace aos