Beispiel #1
0
        private async Task MotorControlSmokeTest()
        {
            ZumoMotorShieldConfig config = new ZumoMotorShieldConfig();

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

            using (ZumoMotorShield motorDriver = new ZumoMotorShield(config))
            {
                await motorDriver.Init();

                bool flipDir            = false;
                ZumoMotorDirection dirA = ZumoMotorDirection.Forward;
                ZumoMotorDirection dirB = ZumoMotorDirection.Backward;

                for (int i = 20; i <= 100; i += 20)
                {
                    Debug.WriteLine("Motor Control Ticking");

                    if (!flipDir)
                    {
                        motorDriver.SetLeftMotorPower(dirA, (float)i / 100.0f);
                        motorDriver.SetRightMotorPower(dirB, (float)i / 100.0f);
                    }
                    else
                    {
                        motorDriver.SetLeftMotorPower(dirB, (float)i / 100.0f);
                        motorDriver.SetRightMotorPower(dirA, (float)i / 100.0f);
                    }

                    flipDir = !flipDir;

                    await Task.Delay(1500);
                }

                motorDriver.LeftMotorStop();
                motorDriver.RightMotorStop();

                await Task.Delay(1000);

                motorDriver.SetLeftMotorPower(ZumoMotorDirection.Forward, 0.5f);
                await Task.Delay(2000);

                motorDriver.LeftMotorStop();

                await Task.Delay(500);

                motorDriver.SetRightMotorPower(ZumoMotorDirection.Forward, 0.5f);
                await Task.Delay(2000);

                motorDriver.RightMotorStop();
            }
        }
Beispiel #2
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);
        }