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(); } }
public MainPage() { this.InitializeComponent(); Loaded += MainPage_Loaded; Config = new ZumoMotorShieldConfig(); Config.LeftMotorDirPin = 5; Config.RightMotorDirPin = 4; Config.LeftPwmChannel = 1; Config.RightPwmChannel = 0; Config.BuzzerPwmChannel = 2; Config.PwmDriverSlaveAddress = 0x40; }
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); }
public ZumoMotorShield(ZumoMotorShieldConfig config) { Config = config; }
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); stateMachine = new Dictionary<ControllerStateID, ControllerState>(); stateMachine.Add(ControllerStateID.Scan, new ScanState(this)); stateMachine.Add(ControllerStateID.Track, new TrackState(this)); stateMachine.Add(ControllerStateID.Follow, new FollowState(this)); currentState = ControllerStateID.Scan; }