void Main1(string[] args) { xCon.WriteLine("*w^z Spiked3.com MiniMagellan Kernel - (c) 2015-2016 Mike Partain "); xCon.WriteLine("*w^z \\^c || break to stop "); #if __MonoCS__ xCon.Write("Mono / "); #else xCon.Write(".Net / "); #endif if (Unix) xCon.WriteLine("Unix"); else xCon.WriteLine("Windows"); Console.CancelKeyPress += Console_CancelKeyPress; Console.TreatControlCAsInput = false; // startup parms var parms = new OptionSet { { "pilot=", (v) => { PilotString = v; } } }; parms.Parse(Environment.GetCommandLineArgs()); // pilot, listen for events Pilot = Pilot.Factory(PilotString); Pilot.OnPilotReceive += PilotReceive; Vis = new Vision(); // start vision first because Navigation listens to vision events taskVis = new Task(Vis.TaskRun, TaskCreationOptions.LongRunning); taskVis.Start(); Nav = new Navigation(); taskNav = new Task(Nav.TaskRun, TaskCreationOptions.LongRunning); taskNav.Start(); Appr = new Approach(); taskAppr = new Task(Appr.TaskRun, TaskCreationOptions.LongRunning); taskAppr.Start(); int telementryIdx = 0; new Task(ListenWayPointsTask).Start(); // menu Dictionary<char, string> menu = new Dictionary<char, string>() { { 'F', "Fake waypoints" }, { 'E', "rEset" }, { 'A', "Autonomous Start" }, { 'P', "Autonomous Start" }, { 'S', "State" }, { 'R', ".Rotate" }, { 'M', ".Move" }, { 'B', ".Bumper" }, { 'T', "Telementry" }, { ' ', "eStop (space bar)" } }; for (;;) { // use ^C to break char n = Char.ToUpper(GetCharChoice(menu)); if (State == RobotState.Shutdown) return; switch (n) { case 'W': break; case 'F': FakeWayPoints(); break; case 'E': resetPilot(); break; case 'A': Trace.t(cc.Warn, string.Format("^yStarting autonomous @ {0}", DateTime.Now.ToLongTimeString())); configPilot(); State = RobotState.Idle; break; case 'P': configPilot(); Pilot.Send(new { Cmd = "MOV", Pwr = 20 }); break; case 'S': ViewStatus(); break; case 'R': xCon.Write("^c#"); X = Nav.CurrentWayPoint.X; Y = Nav.CurrentWayPoint.Y; H = (float)Nav.lastHdg; Pilot.FakeOnReceive(new { T = "Rotate", V = "1" }); break; case 'M': xCon.Write("^c#"); Pilot.FakeOnReceive(new { T = "Move", V = "1" }); break; case 'B': xCon.Write("^c#"); Pilot.FakeOnReceive(new { T = "Bumper", V = "1" }); break; case 'T': Pilot.Send(new { Cmd = "TELEM", Flag = (++telementryIdx % 5) }); break; case ' ': // EStop Trace.t(cc.Bad, "eStop"); State = RobotState.eStop; Pilot.Send(new { Cmd = "MOV", M1 = 0, M2 = 0 }); Pilot.Send(new { Cmd = "ESC", Value = 0 }); break; } } }