Пример #1
0
        public ObjectTrackingController()
        {
            ZumoMotorShieldConfig config;

            config = new ZumoMotorShieldConfig();
            config.LeftMotorDirPin       = 5;
            config.RightMotorDirPin      = 4;
            config.LeftPwmChannel        = 1;
            config.RightPwmChannel       = 0;
            config.BuzzerPwmChannel      = 2;
            config.PwmDriverSlaveAddress = 0x40;

            watch = new Stopwatch();

            motorDriver = new ZumoMotorShield(config);
            pixyCam     = new PixyCam();
            panLoop     = new ServoLoop(200, 200);
            tiltLoop    = new ServoLoop(150, 200);
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (pixyCam == null)
            {
                pixyCam = new PixyCam();

                // Initialize camera
                await pixyCam.Init();
            }

            if (!isCameraThreadRunning)
            {
                stopCameraThread = false;

                // Set LED to blue
                pixyCam.SetLED(0, 0, 255);

                // Start reading frames from camera
                await ThreadPool.RunAsync((s) =>
                {
                    isCameraThreadRunning = true;

                    while (!stopCameraThread)
                    {
                        var blocks = pixyCam.GetBlocks(10);

                        if (blocks != null && blocks.Count > 0)
                        {
                            var trackedBlock = trackBlock(blocks.ToArray());
                            if (trackedBlock != null)
                            {
                                followBlock(trackedBlock);
                                updateUI(trackedBlock);
                            }
                        }
                    }

                    isCameraThreadRunning = false;
                });
            }
        }
Пример #3
0
        public DiagnosticsPage()
        {
            this.InitializeComponent();

            CoordinateHelper.Initialize(mainCanvas.Width, mainCanvas.Height);

            pixyCam = new PixyCam();
            robot   = new Robot();

            // Initialize robot's max speed and acceleration
            robot.StepperX.MaxSpeed = Config.MOTOR_X_MAX_SPEED;
            robot.StepperY.MaxSpeed = Config.MOTOR_Y_MAX_SPEED;

            robot.StepperX.Acceleration = Config.MOTOR_X_ACCELERATION;
            robot.StepperY.Acceleration = Config.MOTOR_Y_ACCELERATION;

            // Adds event listeners for when a goal is scored
            robot.HumanGoalSensorTriggered += Robot_HumanGoalSensorTriggered;
            robot.RobotGoalSensorTriggered += Robot_RobotGoalSensorTriggered;

            initializeUI();
        }