/// <summary> /// This function is called at the end of IterativeSearch after exploring all the executions. /// </summary> public static void RunMotionPlanner(ZingDronacharya zDrona) { List<MotionPlan> allMotionPlans = new List<MotionPlan>(); foreach(var motionPlan in zDrona.GenerateMotionPlans) { int[] outputPath = new int[100]; int outputSize = 0; Console.WriteLine("Invoking Complan for : {0} {1}", motionPlan.startPosition, motionPlan.endPosition); bool result = GenerateMotionPlanFor(motionPlan.startPosition, motionPlan.endPosition, motionPlan.obstacles.ToArray(), motionPlan.obstacles.Count(), outputPath, ref outputSize); if (!result) { outputPath = new int[1] { -1 }; outputSize = 1; } allMotionPlans.Add(new MotionPlan(motionPlan.startPosition, motionPlan.endPosition, outputPath.Take(outputSize).ToList())); } //generate the new function GenerateMotionPlanningModelFunction(zDrona, allMotionPlans); }
public static ZingerResult LaunchNewZingerInstance(ZingDronacharya zDrona, string[] commandLineArgs) { //generate zing commandline string commandline = ""; foreach(var s in ZingerCommandline) { commandline += " " + s; } ZingerResult returnValue = ZingerResult.ProgramRuntimeError; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.CreateNoWindow = false; process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = zDrona.DronaConfiguration.ZingerPath; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.Arguments = (commandline + " -dronaworker "); ZingerUtilities.PrintMessage(process.StartInfo.FileName + " " + process.StartInfo.Arguments); try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. process.Start(); process.WaitForExit(); returnValue = (ZingerResult) process.ExitCode; } catch (Exception ex) { ZingerUtilities.PrintErrorMessage("Failed to run zinger"); ZingerUtilities.PrintErrorMessage(ex.ToString()); Environment.Exit((int)ZingerResult.ProgramRuntimeError); } return returnValue; }
public static void RecompileProgram(ZingDronacharya zDrona) { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.CreateNoWindow = false; process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = zDrona.DronaConfiguration.PcompilerPath; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.Arguments = (zDrona.DronaConfiguration.P_ProgramDriverPath); try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. process.Start(); process.WaitForExit(); } catch(Exception ex) { ZingerUtilities.PrintErrorMessage("Failed to compile P program"); ZingerUtilities.PrintErrorMessage(ex.ToString()); Environment.Exit((int)ZingerResult.ProgramRuntimeError); } }
public static void GenerateMotionPlanningModelFunction(ZingDronacharya zDrona, List<MotionPlan> allMotionPlans) { string motionPlanningFile = zDrona.DronaConfiguration.P_ProgramPath + "\\ModelOfMotionPlanning.p"; if(!File.Exists(motionPlanningFile)) { ZingerUtilities.PrintErrorMessage("Failed to find file: " + motionPlanningFile); } var motionPlanningFunction = File.ReadAllLines(motionPlanningFile); //concatenate the strings string newFunction = ""; foreach(var lines in motionPlanningFunction) { newFunction += (lines + "\n"); } string genSeq = "\n tempSeq = default(seq[int]);\n"; foreach(var MP in allMotionPlans) { foreach(var point in MP.Plan) { string temp1 = String.Format("tempSeq += (sizeof(tempSeq), {0});\n", point); genSeq = genSeq + temp1; } genSeq = genSeq + String.Format("AllMotionPlans[({0}, {1})] = tempSeq;\n\n", MP.start, MP.end); } genSeq += "return AllMotionPlans;\n"; newFunction = newFunction.Replace("return AllMotionPlans;", genSeq); //update the motion planning file. File.Delete(motionPlanningFile); StreamWriter sw = new StreamWriter(File.Create(motionPlanningFile)); sw.WriteLine(newFunction); sw.Close(); }