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