Beispiel #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();
        }
Beispiel #2
0
        public CncMachine(IHost host)
        {
            Contract.Assert(host != null);
            _host = host;

            _client = new NetworkSerialClient(
                _host.GetParam<string>("MachineHostName"),
                _host.GetParam<int>("MachinePort"),
                OnMsg
             );

            _coordSystem = new IdentityTranslator(
                new MachineCoordSystem(
                    new Coord(0, 0, -_host.GetParam<double>("MaxZ"), 0),
                    new Coord(
                        _host.GetParam<double>("MaxX"),
                        _host.GetParam<double>("MaxY"),
                        0,
                        _host.GetParam<double>("MaxA")
                    )
                )
            );

            // We need to request status a few times when the TinyG controller first boots
            // up for *some* reason.
            RequestStatus();
            RequestStatus();
            RequestStatus();
        }