/// <summary> /// Primary entry point. /// </summary> /// <param name="args">Command line arguments.</param> //[STAThread] public static void Main(string[] args) { string recfile = "data.zip"; string scenefile = ""; string commandfile = ""; string configfile = ""; int particlecount = 1; double reftime = 0; bool onlymapping = false; bool realtime = false; bool viewer = false; bool filterhistory = false; bool screenshotmode = false; bool headless = false; bool noterminate = false; bool showhelp = false; VehicleType input = VehicleType.Simulation; NavigationAlgorithm algorithm = NavigationAlgorithm.PHD; OptionSet options = new OptionSet { { "f|scene=", "Scene description file. Simulated, recorded or device id.", f => scenefile = f }, { "r|recfile=", "Recording file. Saves State and events for reviewing.", r => recfile = r }, { "c|command=", "Auto-command file (simulates user input).", c => commandfile = c }, { "g|config=", "Configuration file. Contains global constants.", g => configfile = g }, { "a|algorithm=", "SLAM solver algorithm ('odometry', 'phd', 'loopy' or 'isam2').", a => algorithm = (a == "isam2") ? NavigationAlgorithm.ISAM2 : (a == "odometry") ? NavigationAlgorithm.Odometry : (a == "loopy") ? NavigationAlgorithm.LoopyPHD : NavigationAlgorithm.PHD }, { "p|particles=", "Number of particles used for the RB-PHD.", (int p) => particlecount = p }, { "y|onlymap", "Only do mapping, assuming known localization.", y => onlymapping = y != null }, { "i|input=", "Vehicle input stream: 'kinect', 'simulation' or 'record'.", i => input = (i == "kinect") ? VehicleType.Kinect : (i == "record") ? VehicleType.Record : VehicleType.Simulation }, { "R|realtime", "Process the system in realtime, instead of a fixed step.", R => realtime = R != null }, { "v|view", "View a precorded session.", v => viewer = v != null }, { "H|history=", "Trajectory history mode: either 'filter' or 'smooth'.", h => filterhistory = (h == "filter") }, { "t|reftime=", "Reference time.", (double t) => reftime = t }, { "s|screenshot", "Screenshot mode: just take the screenshots in the tags.", s => screenshotmode = s != null }, { "x|headless", "Run headless, i.e. with no GUI.", x => headless = x != null }, { "q|noterminate", "Skip simulation termination due command depletion o similars.", q => noterminate = q != null }, { "h|help", "Show this message and exit.", h => showhelp = h != null } }; try { options.Parse(args); } catch (OptionException e) { Console.Write("monorfs: "); Console.WriteLine(e.Message); Console.WriteLine("Try monorfs --help for more information."); Environment.Exit(1); } if (showhelp) { ShowHelp(options); return; } TimeSpan time = DateTime.Now.ToUniversalTime() - new DateTime(2010, 1, 1, 0, 0, 0, DateTimeKind.Utc); Util.SeedGenerators((int)time.TotalSeconds); if (!KinectVehicle.Initialize()) { KinectVehicle.Shutdown(); Environment.Exit(2); } // Reading configuration from cfg file specified in argument // or (if none was specified) from the internal config file of the recording file if (!string.IsNullOrEmpty(configfile)) { try { Config.FromFile(configfile); } catch (FileNotFoundException e) { Console.WriteLine("Error: Configuration file '" + e.FileName + "' not found."); Environment.Exit(3); } } else if (input == VehicleType.Record) { try { Config.FromRecordFile(recfile); } catch (IOException) { Console.WriteLine("Couldn't read config data from record file. Using default configuration."); } } else { Console.WriteLine("Using default configuration."); } try { switch (Config.Model) { case DynamicsModel.Linear1D: Run <Linear1DMeasurer, LinearPose1D, LinearMeasurement1D>( recfile, scenefile, commandfile, particlecount, onlymapping, realtime, viewer, filterhistory, reftime, screenshotmode, headless, noterminate, input, algorithm); break; case DynamicsModel.Linear2D: Run <Linear2DMeasurer, LinearPose2D, LinearMeasurement2D>( recfile, scenefile, commandfile, particlecount, onlymapping, realtime, viewer, filterhistory, reftime, screenshotmode, headless, noterminate, input, algorithm); break; case DynamicsModel.PRM3D: default: if (input == VehicleType.Kinect) { Run <KinectMeasurer, Pose3D, PixelRangeMeasurement>( recfile, scenefile, commandfile, particlecount, onlymapping, realtime, viewer, filterhistory, reftime, screenshotmode, headless, noterminate, input, algorithm); } else { Run <PRM3DMeasurer, Pose3D, PixelRangeMeasurement>( recfile, scenefile, commandfile, particlecount, onlymapping, realtime, viewer, filterhistory, reftime, screenshotmode, headless, noterminate, input, algorithm); } break; } } catch (FileNotFoundException e) { Console.WriteLine("Error: File '" + e.FileName + "' not found."); Environment.Exit(4); } KinectVehicle.Shutdown(); signalthread.Abort(); }