Beispiel #1
0
        /// <summary>
        /// this method initializes all needed motors and sensors
        /// to control the robot accordingly
        /// </summary>
        public static void InitRobot()
        {
            AddEmergencyStopOption();

            LeftTrack          = new Motor(Constants.LEFT_TRACK_PORT);
            RightTrack         = new Motor(Constants.RIGHT_TRACK_PORT);
            GrapplerRiserMotor = new Motor(Constants.GRAPPLER_RISER_PORT);
            GrapplerWheelMotor = new Motor(Constants.GRAPPLER_WHEEL_PORT);

            ColorSensor      = new EV3ColorSensor(Constants.EV3_COLOR_SENSOR_PORT);
            IRSensor         = new EV3IRSensor(Constants.IR_SENSOR_PORT);
            UltraSonicSensor = new EV3UltrasonicSensor(Constants.ULTRASONIC_SENSOR_PORT);

            ColorSensor.Mode      = ColorMode.RGB;
            UltraSonicSensor.Mode = UltraSonicMode.Centimeter;

            GrapplerPosition = GrapplerPosition.Down;
            FoodState        = FoodState.Searching;

            IsInitialized = true;

            WaitToFullyBootProgram();

            CalibrizeGrappler();

            PrintEmptyLine();

            WaitForStartButtonPress();

            TeamMode = TeamMode.WinnieTeam;
            //InitColour();
        }
Beispiel #2
0
        //EV3IRSensor
        private async Task TestIRSensor()
        {
            EV3IRSensor ultra = new EV3IRSensor(brick, BrickPortSensor.PORT_S4, IRMode.Remote);

            int count = 0;

            while (count < 100)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
            ultra.Mode = IRMode.Proximity;
            count      = 0;
            while (count < 10)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
            ultra.Mode = IRMode.Seek;
            count      = 0;
            while (count < 10)
            {
                Debug.WriteLine(string.Format("NXT ultra, Remote: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                              ultra.Value, ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                await Task.Delay(300);

                count++;
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            ButtonEvents buts = new ButtonEvents();
            bool         run  = true;

            buts.EscapePressed += () =>
            {
                run = false;
            };

            MotorSync   motori = new MotorSync(MotorPort.OutB, MotorPort.OutD);
            EV3IRSensor ir     = new EV3IRSensor(SensorPort.In3, IRMode.Proximity);

            Thread bg = new Thread(Scan);

            bg.Start();
            while (run && ir.Read() > 80)
            {
                LcdConsole.WriteLine(ir.Read().ToString());
                Thread.Sleep(200);
            }
            bg.Abort();
            motori.Brake();
            motori.Off();
        }
Beispiel #4
0
        //EV3IRSensor
        private async Task TestIRSensor()
        {
            EV3IRSensor ultra = new EV3IRSensor(BrickPortSensor.PORT_S4, IRMode.Remote);

            for (int i = 0; i < ultra.NumberOfModes(); i++)
            {
                int count = 0;
                while (count < 100)
                {
                    Debug.WriteLine(string.Format("NXT ultra, Distance: {0}, ReadAsString: {1}, NumberNodes: {2}, SensorName: {3}",
                                                  ultra.ReadBeaconLocation(), ultra.ReadAsString(), ultra.Mode, ultra.GetSensorName()));
                    await Task.Delay(300);
                }
                ultra.SelectNextMode();
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            IRChannel[] channels = { IRChannel.One, IRChannel.Two, IRChannel.Three, IRChannel.Four };

            int channelIdx = 0;
            ManualResetEvent terminateProgram = new ManualResetEvent(false);
            var          sensor = new EV3IRSensor(SensorPort.In1);
            ButtonEvents buts   = new ButtonEvents();

            LcdConsole.WriteLine("Use IR on port1");
            LcdConsole.WriteLine("Up distance");
            LcdConsole.WriteLine("Down beacon location");
            LcdConsole.WriteLine("Enter read command");
            LcdConsole.WriteLine("Left change channel");
            LcdConsole.WriteLine("Right read as string");
            LcdConsole.WriteLine("Esc. terminate");
            buts.EscapePressed += () => {
                terminateProgram.Set();
            };
            buts.UpPressed += () => {
                LcdConsole.WriteLine("Distance " + sensor.ReadDistance() + " cm");
            };
            buts.EnterPressed += () => {
                LcdConsole.WriteLine("Remote command " + sensor.ReadRemoteCommand() + " on channel " + sensor.Channel);
            };
            buts.DownPressed += () => {
                BeaconLocation location = sensor.ReadBeaconLocation();
                LcdConsole.WriteLine("Beacon location: " + location.Location + " Beacon distance: " + location.Distance + " cm");
            };
            buts.LeftPressed += () => {
                channelIdx     = (channelIdx + 1) % channels.Length;
                sensor.Channel = channels[channelIdx];
                LcdConsole.WriteLine("Channel is set to: " + channels[channelIdx]);
            };
            buts.RightPressed += () => {
                LcdConsole.WriteLine(sensor.ReadAsString());
            };
            terminateProgram.WaitOne();
        }
 public IRSensorLockWrapper(EV3IRSensor sensor)
 {
     this.sensor = sensor;
 }