Example #1
0
        public PuzzleBot(IHost host)
        {
            _host = host;
            _host.WriteLogMessage(c_componentName, "Initializing PuzzleBot comm. channels.");
            _machine = new CncMachine(_host);
            _upwardCamera = new OpenCV.CaptureEngine(
                $"http://{_host.GetParam<string>("MachineHostName")}:{_host.GetParam<int>("UpCameraPort")}/?action=stream");
            _downwardCamera = new OpenCV.CaptureEngine(
                $"http://{_host.GetParam<string>("MachineHostName")}:{_host.GetParam<int>("DownCameraPort")}/?action=stream");
            _upwardCameraView = _host.CreateCameraView("Upward Camera");
            _downwardCameraView = _host.CreateCameraView("Downward Camera");
            _downwardCameraIntrinsic = _host.GetParam<JObject>("IntrinsticCalib").ToMat();
            _downwardCameraExtrinstic = _host.GetParam<JObject>("ExtrinsticCalib").ToMat();

            _viewUpdateThread = new Thread(CameraViewUpdater);
            _viewUpdateThread.Start();

            _host.WriteLogMessage(c_componentName, "Press enter to home...");
            _host.ReadLine();
            _machine.PerformMechanicalHome();

            AttachKeyHandlers();
            MainControlLoop();
        }