blob: 762e8b65c3814cc5da0c290e8238c5aa0c0f3b68 [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
Brian Silvermanffe3d712013-03-15 21:35:59 -070016ControlsManager::ControlsManager() {
17 printf("aos::ControlsManager constructor done\n");
18}
19
brians343bc112013-02-10 01:53:46 +000020// Everything gets an explicit Start call here before calling all of the init
21// functions because it means that all static variables will be initialized
22// before anything actually starts running. It also means that everything will
23// be initialized before any of the init functions start trying to register
24// themselves etc.
25void ControlsManager::StartCompetition() {
26 printf("aos::ControlsManager::RobotMain\n");
27 (new Compressor(14, 1))->Start();
28
Brian Silvermanf665d692013-02-17 22:11:39 -080029 logging::crio::Register();
brians343bc112013-02-10 01:53:46 +000030 LOG(INFO, "logging started\n");
31
32 GetWatchdog().SetEnabled(false);
33 LOG(INFO, "disabled watchdog\n");
34
brians343bc112013-02-10 01:53:46 +000035 MotorServer::Start();
36 LOG(INFO, "MotorServer started\n");
brians343bc112013-02-10 01:53:46 +000037
38 LOG(INFO, "calling init functions\n");
39 aos_call_init_functions();
40 LOG(INFO, "initialized\n");
41
Brian Silvermanffe3d712013-03-15 21:35:59 -070042 CreateObjects();
43 LOG(INFO, "created objects\n");
44
Brian Silverman3204dd82013-03-12 18:42:01 -070045 RegisterControlLoops();
46 LOG(INFO, "registered control loops\n");
47
48 StartSensorBroadcasters();
49 LOG(INFO, "started sensor broadcasters\n");
50
brians343bc112013-02-10 01:53:46 +000051 // Wait forever so that this task doesn't end to avoid confusing any brittle
52 // FIRST code that might be hiding somewhere.
53 while (true) {
54 select(0, NULL, NULL, NULL, NULL);
55 }
56}
57
58} // namespace crio
Brian Silvermanc0b65432013-02-24 16:54:47 -080059} // namespace aos