Example #1
0
 public AutonomousBehaviour(IMU440 IMU1, Microcontroller uC1, PositionTracker pos1, ThrustManager lev1, log ERRORLOG)
 {
     // TODO: Complete member initialization
     this.IMU      = IMU1;
     this.uC       = uC1;
     this.pos      = pos1;
     this.lev      = lev1;
     this.ERRORLOG = ERRORLOG;
 }
Example #2
0
        //public static Sonar sonar;
        //public static AutonomousBehaviour auto;

        static void Main(string[] args)
        {
            //we might consider switching the COM port references over to commandline input
            bool is_init  = false;
            bool init_imu = false;
            bool init_due = false;
            int  _try     = 0;

            ERRORLOG = new log();

            Dictionary <string, string> serials = parseSerialLocations();


            ERRORLOG.LOG(" Starting Program", 0);

            while (!is_init && _try < 5)
            {
                try
                {
                    //externals
                    ERRORLOG.LOG("F**k you jeff", 0);
                    ERRORLOG.LOG("Initialization: " + _try.ToString() + " of 6", 0);
                    if (!init_imu)
                    {
                        IMU = new IMU440(serials["IMU"], 57600, ERRORLOG, false);
                    }
                    init_imu = true;
                    ERRORLOG.LOG("Initialized IMU", 0);
                    if (!init_due)
                    {
                        uC = new Microcontroller(serials["DUE"], 115200, ERRORLOG);
                    }
                    init_due = true;
                    ERRORLOG.LOG("Initialized DUE", 0);
                    //sonar will make an appearance soon.
                    //sonar = new Sonar(serials["SONAR"], log);//port

                    //internals
                    pos = new PositionTracker(IMU, uC, ERRORLOG);
                    lev = new ThrustManager(IMU, uC, pos, ERRORLOG);
                    ERRORLOG.LOG("Initialized ThrustManager", 0);
                    //auto = new AutonomousBehaviour(IMU,uC,pos,lev,ERRORLOG);
                    is_init = true;
                }
                catch (Exception e)
                {
                    ERRORLOG.LOG(e.Message, 0);
                    Thread.Sleep(5000);
                    _try++;
                    is_init = false;
                }
            }
            //this is because communications issues:
            for (int l = 0; l < 15; l++)
            {
                uC.sensorRequest();
            }
            while (is_init)
            {
            }
            ERRORLOG.LOG("Exiting", 0);
            //while (true)
            //{//testing driver
            //    Console.WriteLine("pitch: " + Math.Round(IMU.pitchAngle*(180/Math.PI)));
            //    Console.WriteLine("roll: " + Math.Round(IMU.rollAngle * (180 /Math.PI)));
            //    Console.WriteLine("tp: " + Math.Round(lev.Tp,4));
            //    Console.WriteLine("tr: " + Math.Round(lev.Tr,4));
            //    Console.WriteLine(IMU.boardTemp);
            //    Thread.Sleep(200);
            //    Console.Clear();
            //}
        }