blob: 906394ffd28509d3084274049651d9f92a4ebf70 [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"
brians343bc112013-02-10 01:53:46 +000011#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
Brian Silvermanf665d692013-02-17 22:11:39 -080025 logging::crio::Register();
brians343bc112013-02-10 01:53:46 +000026 LOG(INFO, "logging started\n");
27
28 GetWatchdog().SetEnabled(false);
29 LOG(INFO, "disabled watchdog\n");
30
brians343bc112013-02-10 01:53:46 +000031 MotorServer::Start();
32 LOG(INFO, "MotorServer started\n");
brians343bc112013-02-10 01:53:46 +000033
34 LOG(INFO, "calling init functions\n");
35 aos_call_init_functions();
36 LOG(INFO, "initialized\n");
37
Brian Silverman3204dd82013-03-12 18:42:01 -070038 RegisterControlLoops();
39 LOG(INFO, "registered control loops\n");
40
41 StartSensorBroadcasters();
42 LOG(INFO, "started sensor broadcasters\n");
43
brians343bc112013-02-10 01:53:46 +000044 // Wait forever so that this task doesn't end to avoid confusing any brittle
45 // FIRST code that might be hiding somewhere.
46 while (true) {
47 select(0, NULL, NULL, NULL, NULL);
48 }
49}
50
51} // namespace crio
Brian Silvermanc0b65432013-02-24 16:54:47 -080052} // namespace aos