Program() { com = new MyCom(); omniDrive = new OmniDrive(); bumper = new MyBumper(); omniDrive.setComId(com.id()); bumper.setComId(com.id()); }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); camera = new MyCamera(this); omniDrive.setComId(com.id()); bumper.setComId(com.id()); camera.setComId(com.id()); }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); kinect = new MyKinect(this); omniDrive.setComId(com.id()); bumper.setComId(com.id()); kinect.setComId(com.id()); }
public Robot() { com = new MyCom(this); omniDrive = new OmniDrive(); bumper = new Bumper(); camera = new MyCamera(this); motor = new Motor(); Distance = new DistanceSensor(); omniDrive.setComId(com.id()); motor.setComId(com.id()); bumper.setComId(com.id()); camera.setComId(com.id()); Distance.setComId(com.id()); }
Robotino() { _com = new MyCom(); _omniDrive = new OmniDrive(); _bumper = new MyBumper(); _distanceSensors = new List <MyDistanceSensor>(); for (uint i = 0; i < 9; i++) { _distanceSensors.Add(new MyDistanceSensor(i)); _distanceSensors[(int)i].setComId(_com.id()); } _omniDrive.setComId(_com.id()); _bumper.setComId(_com.id()); }
static async Task ControlOmni() { Console.WriteLine("Connecting to MCU ({0})...", PORT); mcu = new Microcontroller(new SerialTransport(PORT)); await mcu.Connect(); Console.WriteLine("Attaching omni drive..."); var omni = new OmniDrive(mcu); await omni.Initialize(); Console.WriteLine("Control with left thumbstick. Press 'Back' to disconnect."); var lastY = float.NaN; var lastX = float.NaN; var lastShoulderLeft = ButtonState.Released; var lastShoulderRight = ButtonState.Released; GamePadState pad; do { pad = GamePad.GetState(PlayerIndex.One); var y = pad.ThumbSticks.Left.Y; var x = pad.ThumbSticks.Left.X; var shoulderLeft = pad.Buttons.LeftShoulder; var shoulderRight = pad.Buttons.RightShoulder; if (x.CompareTo(lastX) != 0) { lastX = x; Console.WriteLine("X: {0}", x); if (x < 0) { await omni.DriveLeft((int)Math.Abs(x * 100)); } else if (x > 0) { await omni.DriveRight((int)(Math.Abs(x * 100))); } else { await omni.AllStop(); } } if (y.CompareTo(lastY) != 0) { lastY = y; Console.WriteLine("Y: {0}", y); if (y < 0) { await omni.DriveForward((int)Math.Abs(y * 100)); } else if (y > 0) { await omni.DriveBackward((int)(Math.Abs(y * 100))); } else { await omni.AllStop(); } } if (shoulderLeft.CompareTo(lastShoulderLeft) != 0) { lastShoulderLeft = shoulderLeft; Console.WriteLine("ShoulderLeft : {0}", shoulderLeft); if (shoulderLeft == ButtonState.Pressed) { await omni.RotateLeft(100); } else { await omni.AllStop(); } } if (shoulderRight.CompareTo(lastShoulderRight) != 0) { lastShoulderRight = shoulderRight; Console.WriteLine("ShoulderRight : {0}", shoulderRight); if (shoulderRight == ButtonState.Pressed) { await omni.RotateRight(100); } else { await omni.AllStop(); } } } while (pad.Buttons.Back != ButtonState.Pressed); Console.WriteLine("Disconnecting from MCU..."); await mcu.Disconnect(); }