public RobotEngine() { _brick = new NxtBrick(NxtCommLinkType.Bluetooth, Config.SerialPortNo) { MotorA = new NxtMotor(), MotorB = new NxtMotor(), MotorC = new NxtMotor() }; _motorSync = new NxtMotorSync(_brick.MotorA, _brick.MotorB); }
public Robot() { m_brick = new NxtBrick(NxtCommLinkType.Bluetooth, 3); m_leftMotor = new NxtMotor(); m_rightMotor = new NxtMotor(); m_brick.MotorB = m_leftMotor; m_brick.MotorC = m_rightMotor; m_motors = new NxtMotorSync(m_leftMotor, m_rightMotor); }
static void Reverse() { motorPair.Brake(); // set to reverse brick.MotorA = new NxtMotor(true); brick.MotorC = new NxtMotor(true); motorPair = new NxtMotorSync(brick.MotorA, brick.MotorC); motorPair.Run(75, 0, 0); Thread.Sleep(1000); motorPair.Brake(); }
private void Form1_Load(object sender, EventArgs e) { try { myKinect = KinectSensor.KinectSensors[0]; myKinect.SkeletonStream.Enable(); myKinect.Start(); } catch { MessageBox.Show("Kinect initialise failed", "camera view"); Application.Exit(); } leftInitialPosition = new List <SkeletonPoint>(); rightInitialPosition = new List <SkeletonPoint>(); initialPositions = new Dictionary <string, SkeletonPoint>(); //cmds = new List<Motion>(); cmds = new Dictionary <Motion, bool>(); cmds[Motion.Back] = false; cmds[Motion.Brake] = false; cmds[Motion.Forward] = false; cmds[Motion.TurnRight] = false; cmds[Motion.TurnLeft] = false; nxtStatus = new Dictionary <Motion, bool>(); nxtStatus[Motion.Brake] = false; nxtStatus[Motion.Back] = false; nxtStatus[Motion.Forward] = false; nxtStatus[Motion.TurnLeft] = false; nxtStatus[Motion.TurnRight] = false; nxt = new NxtBrick(NxtCommLinkType.Bluetooth, 3); nxt.MotorB = new NxtMotor(); nxt.MotorC = new NxtMotor(); motorPair = new NxtMotorSync(nxt.MotorB, nxt.MotorC); nxt.Connect(); NXTLabel.Text = "NXT is connected."; myKinect.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(myKinect_SkeletonFrameReady); }
private void Backward() { textBox1.Text += "Backward" + Environment.NewLine; if (motorPair != null) { motorPair.Brake(); } nxt.MotorB = new NxtMotor(true); nxt.MotorC = new NxtMotor(true); nxt.MotorB.ResetMotorPosition(true); nxt.MotorC.ResetMotorPosition(true); motorPair = new NxtMotorSync(nxt.MotorB, nxt.MotorC); motorPair.Run(100, 0, 0); nxtStatus[Motion.Forward] = false; nxtStatus[Motion.Back] = true; nxtStatus[Motion.TurnLeft] = false; nxtStatus[Motion.TurnRight] = false; nxtStatus[Motion.Brake] = false; }
static void Main() { Init(); brick = new NxtBrick(NxtCommLinkType.USB, 0); //brick = new NxtBrick(NxtCommLinkType.Bluetooth, 40); var sound = new NxtSoundSensor(); var touch = new NxtTouchSensor(); var sonar = new NxtUltrasonicSensor(); brick.MotorA = new NxtMotor(); brick.MotorC = new NxtMotor(); motorPair = new NxtMotorSync(brick.MotorA, brick.MotorC); brick.Sensor1 = sonar; brick.Sensor3 = touch; brick.Sensor4 = sound; sound.PollInterval = 50; sound.OnPolled += sound_OnPolled; sonar.PollInterval = 50; sonar.ThresholdDistanceCm = 25; sonar.OnPolled += sonar_OnPolled; sonar.OnWithinThresholdDistanceCm += OnWithinThreshold; sonar.ContinuousMeasurementCommand(); touch.PollInterval = 50; touch.OnPressed += OnCollision; brick.Connect(); motorPair.Run(75, 0, 0); Console.WriteLine("Press any key to stop."); Console.ReadKey(); brick.Disconnect(); }