Beispiel #1
0
 public WaypointEventArgs(ReasonType t, PathGroup g, RobotPath s, WayPoint pt)
 {
     Reason = t;
     Group  = g;
     Path   = s;
     Point  = pt;
 }
Beispiel #2
0
 public WaypointEventArgs(ReasonType t)
 {
     Reason = t;
     Group  = null;
     Path   = null;
     Point  = null;
 }
Beispiel #3
0
        public MapForm(RobotPath robotPath)
        {
            InitializeComponent();

            m_OriginX = m_PictureBox.Width / 2.0f;
            m_OriginY = -m_PictureBox.Height / 2.0f;

            m_RobotPath = robotPath;
            InitializeMapImage();
        }
Beispiel #4
0
        public override void GenerateSplines(RobotPath path, List <Spline> xsplines, List <Spline> ysplines)
        {
            for (int i = 0; i < path.Points.Length - 1; i++)
            {
                Spline x, y;
                GenerateSpline(path.Points[i], path.Points[i + 1], out x, out y);

                xsplines.Add(x);
                ysplines.Add(y);
            }
        }
Beispiel #5
0
        private static void LaunchRobot(string robotsDirectoryName, Process processInfo)
        {
            var latestVersion =
                RobotDirectory
                .GetVersions(RobotPath.Combine(robotsDirectoryName, processInfo.FileName))
                .GetLatestVersion();

            var robotFileName =
                new RobotFileNameBuilder()
                .RobotDirectoryName(robotsDirectoryName)
                .Version(latestVersion)
                .FileName(processInfo.FileName)
                .Build();

            if (string.IsNullOrEmpty(robotFileName))
            {
                throw new FileNotFoundException($"Robot not found '{robotFileName}'.");
            }

            if (IsRunning(processInfo.FileName, processInfo.Arguments))
            {
                throw new InvalidOperationException($"Robot already running '{robotFileName}'.");
            }

            using (var process = System.Diagnostics.Process.Start(new ProcessStartInfo
            {
                FileName = robotFileName,
                Arguments = processInfo.Arguments,
                WindowStyle = processInfo.WindowStyle,
                //UseShellExecute = false,
            }))
            {
                if (process == null)
                {
                    throw new ProcessNotStartedException(robotFileName);
                }

                LogEntry.New().Info().Message($"Started '{robotFileName}'").Log(Logger);

                using (var logEntry = LogEntry.New().Info().Stopwatch(sw => sw.Start()).AsAutoLog(Logger))
                {
                    process.WaitForExit();
                    if (process.ExitCode != 0)
                    {
                        logEntry.Error().Message($"'{robotFileName}' exited with error code {process.ExitCode}.");
                        throw new ProcessTerminatedException($"'{robotFileName}' exited with error code {process.ExitCode}.");
                    }
                    logEntry.Info().Message($"'{robotFileName}' exited with error code {process.ExitCode}.");
                }
            }
        }
Beispiel #6
0
    void Start()
    {
        // Copies paths from GameManager
        paths = GameManager.paths;
        foreach (string path in paths)
        {
            StreamReader reader = new StreamReader(path);
            string       input  = reader.ReadToEnd();
            string[]     values = input.Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);

            RobotPath robotPath = new RobotPath();
            robotPath.PathType = values[0];

            List <float[]> coordinates = new List <float[]>();
            int            i           = 1;
            int            row         = 0;
            int            col         = 0;
            for (; i < values.Length; i++, col++)
            {
                col %= RobotPath.itemsPerEntry;
                if (col == 0)
                {
                    coordinates.Add(new float[RobotPath.itemsPerEntry]);
                }
                coordinates[row][col] = float.Parse(values[i]);
                if (col >= RobotPath.itemsPerEntry - 1)
                {
                    row++;
                }
            }
            robotPath.Coordinates = coordinates;

            // Debugging
            //foreach(float[] entry in robotPath.Coordinates)
            //{
            //    foreach(float item in entry)
            //    {
            //        Debug.Log(item);
            //    }
            //    Debug.Log("-");
            //}

            GameObject newRobot = Instantiate(robot);
            newRobot.GetComponent <RobotMovement>().Path = robotPath;
        }
    }
Beispiel #7
0
 public void CreateMainDirectoryName_DirectoryAndFileName_Name()
 {
     Assert.AreEqual(
         @"c:\foo\bar\baz",
         RobotPath.Combine(@"c:\foo\bar", @"baz.exe"));
 }
Beispiel #8
0
        public override PathSegment[] GenerateDetailedPath(RobotParams robot, RobotPath path)
        {
            StringBuilder stdout;
            StringBuilder stderr;
            string        outfile  = Path.GetTempFileName();
            string        pathfile = Path.GetTempFileName();

            stdout = new StringBuilder();
            stderr = new StringBuilder();

            string dir      = AppDomain.CurrentDomain.BaseDirectory;
            string execpath = Path.Combine(dir, "PathFinderV1Gen.exe");

            GeneratePathFile(robot, path, pathfile);

            string args = string.Empty;

            if (pathfile == string.Empty)
            {
                return(null);
            }

            args += "--outfile " + outfile;
            args += " --pathfile " + pathfile;
            args += " --timestep " + robot.TimeStep.ToString();

            ProcessStartInfo info = new ProcessStartInfo();

            info.CreateNoWindow         = true;
            info.RedirectStandardError  = true;
            info.RedirectStandardOutput = true;
            info.UseShellExecute        = false;
            info.Arguments = args;
            info.FileName  = execpath;

            Process proc = new Process();

            proc.StartInfo           = info;
            proc.EnableRaisingEvents = true;
            proc.OutputDataReceived += new DataReceivedEventHandler(delegate(object sender, DataReceivedEventArgs e)
            {
                stdout.Append(e.Data);
            }
                                                                    );
            proc.ErrorDataReceived += new DataReceivedEventHandler(delegate(object sender, DataReceivedEventArgs e)
            {
                stderr.Append(e.Data);
            }
                                                                   );
            proc.Start();
            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();
            proc.WaitForExit();
            proc.CancelErrorRead();
            proc.CancelOutputRead();

            string[]      headers = { "time", "x", "y", "position", "velocity", "acceleration", "jerk", "heading" };
            PathSegment[] seg     = ParseOutputFile(outfile, headers);
            File.Delete(outfile);
            File.Delete(pathfile);

            return(seg);
        }