Esempio n. 1
0
        public static bool SetCurrentThreadPriority(bool realTime, int priority)
        {
            int status = 0;
            var ret    = HALThreads.HAL_SetCurrentThreadPriority(realTime, priority, ref status);

            CheckStatus(status);
            return(ret);
        }
Esempio n. 2
0
        public static int GetCurrentThreadPriority()
        {
            bool rt     = false;
            int  status = 0;
            var  ret    = HALThreads.HAL_GetCurrentThreadPriority(ref rt, ref status);

            CheckStatus(status);
            return(ret);
        }
Esempio n. 3
0
        public static bool GetCurrentThreadIsRealTime()
        {
            bool rt     = false;
            int  status = 0;

            HALThreads.HAL_GetCurrentThreadPriority(ref rt, ref status);
            CheckStatus(status);
            return(rt);
        }
Esempio n. 4
0
        public override void RobotInit()
        {
            int status = 0;
            var ret    = HALThreads.HAL_SetCurrentThreadPriority(true, 25, ref status);

            Console.WriteLine(status);
            Console.WriteLine(ret);
            Thread cameraThread = new Thread(() =>
            {
                // Get the USB Camera from the camera server
                UsbCamera camera = CameraServer.Instance.StartAutomaticCapture();
                camera.SetResolution(640, 480);

                // Get a CvSink. This will capture Mats from the Camera
                CvSink cvSink = CameraServer.Instance.GetVideo();
                // Setup a CvSource. This will send images back to the dashboard
                CvSource outputStream = CameraServer.Instance.PutVideo("Rectangle", 640, 480);

                // Mats are very expensive. Let's reuse this Mat.

                Mat mat = new Mat();

                while (true)
                {
                    // Tell the CvSink to grab a frame from the camera and put it
                    // in the source mat.  If there is an error notify the output.
                    if (cvSink.GrabFrame(mat) == 0)
                    {
                        Console.WriteLine("Timeout");
                        // Send the output the error.
                        outputStream.NotifyError(cvSink.GetError());
                        // skip the rest of the current iteration
                        continue;
                    }
                    // Put a rectangle on the image
                    Cv2.Rectangle(mat, new Point(100, 100), new Point(400, 400),
                                  new Scalar(255, 255, 255), 5);
                    // Give the output stream a new image to display
                    outputStream.PutFrame(mat);
                }
            });

            cameraThread.IsBackground = true;
            cameraThread.Start();

            servo = new Servo(0);

            joystick = new Joystick(0);
            gyro     = new AnalogGyro(0);
        }