Inheritance: MonoBehaviour
Esempio n. 1
0
        public IHttpActionResult PutSensors(int id, Sensors sensors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sensors.Sensora_ID)
            {
                return(BadRequest());
            }

            db.Entry(sensors).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SensorsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public IHttpActionResult PostSensors(Sensors sensors)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Sensori.Add(sensors);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (SensorsExists(sensors.Sensora_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("BatmanApi-Sensors", new { id = sensors.Sensora_ID }, sensors));
        }
Esempio n. 3
0
        public void Sensor_can_be_used_to_check_read_model_catchup_status()
        {
            var result = Sensors.CatchupStatus().Result;

            ((long)result.LatestEventId).Should().BeGreaterOrEqualTo(0);
            ((int)result.ReadModels.Count).Should().BeGreaterOrEqualTo(0);
        }
Esempio n. 4
0
        public Task AddSensor(ISensor sensor)
        {
            _logger.LogInformation("Adding new sensor to parking location");
            Sensors.Add(sensor);

            return(Task.CompletedTask);
        }
Esempio n. 5
0
        public int GetTemperature()
        {
            switch (this.ZoneTemperatureType)
            {
            case ZoneTemperatureType.UseSensor:
                var sensor = Sensors.FirstOrDefault();
                if (sensor != null)
                {
                    return(sensor.Temperature);
                }
                else
                {
                    Log.Warning($"Getting Zone Temperature. ZoneTemperatureType {this.ZoneTemperatureType} expecting one sensor, got none");
                    return(0);
                }

            case ZoneTemperatureType.UseTouchPad:
                return(TouchPadTemperature);

            case ZoneTemperatureType.UseAverage:
                var temps       = Sensors.Sum(x => x.Temperature) + TouchPadTemperature;
                var sensorCount = Sensors.Count();

                return((int)(temps) / (sensorCount + 1));
            }

            Log.Warning($"Getting Zone Temperature. ZoneTemperatureType {this.ZoneTemperatureType} not defined");
            return(0);
        }
Esempio n. 6
0
        void led_test(Sensors sensor, double min_val, double max_val, string color)
        {
            _dutport.WaitFor(color + " led on?", 3);
            double val = -1.0;

            for (int i = 0; i < 5; i++)
            {
                val = read_SingelAi(sensor);

                string rmsg = string.Format(color + " led Voltage: {0}", val.ToString("f2"));
                rmsg += string.Format(" ({0}-{1})", min_val.ToString("f1"), max_val.ToString("f1"));
                fire_status(rmsg);

                if (val >= min_val && val < max_val)
                {
                    break;
                }

                Thread.Sleep(250);
            }

            if (val >= min_val && val < max_val)
            {
                _dutport.WriteLine("y");
            }
            else
            {
                _dutport.WriteLine("n");
                string emsg = string.Format("Unable to detect {0} led. Voltage was: {1}", color, val.ToString("f2"));
                throw new Exception(emsg);
            }
        }
Esempio n. 7
0
 public IdleCellSensor(Sensors sensors)
     : base(sensors)
 {
     navigator = GetComponent <Navigator>();
     brain     = GetComponent <MinionBrain>();
     prefabid  = GetComponent <KPrefabID>();
 }
Esempio n. 8
0
        /// <summary>
        /// 数字量数据处理
        /// </summary>
        /// <param name="num">在线数</param>
        /// <param name="index">下标</param>
        /// <param name="data">数据</param>
        /// <param name="type">类型编码</param>
        private void ProcessActuatorData(int num, ref int index, byte[] data, int type)
        {
            string name = Digital[type];

            type += 1;
            if (name == "照明灯")
            {
                for (int i = 0; i < num; i++)
                {
                    index = ProcessLamp(index, data, type, name);
                }
            }
            else  //其他数字量传感器逻辑
            {
                for (int i = 0; i < num; i++)
                {
                    Actuator actuator = new Actuator();
                    actuator.Id   = Convert.ToString(data[index++], 16);
                    actuator.Name = name;
                    actuator.Type = type;
                    int state = data[index++];
                    actuator.State        = GetState(state);
                    actuator.IsOpen       = state == 1 ? false : true;
                    actuator.Online       = state == 0 ? StateType.Offline : StateType.Online;
                    actuator.Controllable = name != "人体" && name != "气体";
                    Sensors.Add(actuator);
                }
            }
        }
Esempio n. 9
0
        public override string ToString()
        {
            var sensors      = Sensors.Select((s, i) => $"S{i + 1}: {s:F1}°C");
            var sensorString = string.Join("   ", sensors);

            return($"{LogTime:yyyy-MM-dd hh:mm:ss} -- {sensorString}");
        }
Esempio n. 10
0
        public SensorsDTO(IList <SensorCardViewModel> sensorCards, Sensors sensorsValues)
        {
            if (sensorsValues.List.Count != sensorCards.Count)
            {
                throw new InvalidOperationException("Sensors count from config does not match actual sensors!");
            }

            this.Time   = sensorsValues.Timestamp;
            this.Models = new SensorViewModel[sensorCards.Count];
            for (int i = 0; i < sensorCards.Count; i++)
            {
                var sensorCard   = sensorCards[i];
                var sensorValues = sensorsValues.List[i];
                switch (sensorsValues.List[i].TypeCase)
                {
                case Sensor.TypeOneofCase.Analog:
                    this.Models[i] = new SensorViewModel(sensorCard, sensorValues.Analog);
                    break;

                case Sensor.TypeOneofCase.Digital:
                    this.Models[i] = new SensorViewModel(sensorCard, sensorValues.Digital);
                    break;
                }
            }
        }
Esempio n. 11
0
        public ProtobufBenchmark()
        {
            var sensors = new Sensors
            {
                List =
                {
                    new Sensor
                    {
                        Analog = new AnalogSensor
                        {
                            UpperRange = 1023,
                            LowerRange = 0,
                            Value      = 10.1f
                        },
                        MeasurementUnit = "B47", //Kilonewton
                        Pin             = 20
                    },
                    new Sensor
                    {
                        Digital = new DigitalSensor
                        {
                            Timestamp = (uint)Environment.TickCount,
                            Value     = false
                        },
                        MeasurementUnit = "1N",
                        Pin             = 10
                    }
                }
            };

            _bytes = sensors.ToByteArray();
        }
Esempio n. 12
0
        static void GetCpuSensors(IHardware hardwareItem, ref Sensors sensors)
        {
            foreach (var sensor in hardwareItem.Sensors)
            {
                if (sensor.Value.HasValue)
                {
                    switch (sensor.SensorType)
                    {
                    case SensorType.Temperature:
                        sensors.cpuTemp.Add(sensor);
                        break;

                    case SensorType.Load:
                        if (sensor.Name.Contains("Total") || sensors.cpuLoad == null)
                        {
                            sensors.cpuLoad = sensor;
                        }
                        break;

                    case SensorType.Clock:
                        if (sensor.Index != 0)
                        {
                            sensors.cpuFreq = sensor;
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            var myComputer = new Computer();

            myComputer.CPUEnabled = true;
            myComputer.GPUEnabled = true;
            myComputer.Open();

            Sensors sensors = new Sensors();

            sensors.cpuTemp = new List <ISensor>();
            sensors.gpuTemp = new List <ISensor>();
            foreach (var hardwareItem in myComputer.Hardware)
            {
                switch (hardwareItem.HardwareType)
                {
                case HardwareType.CPU:
                    GetCpuSensors(hardwareItem, ref sensors);
                    break;

                case HardwareType.GpuAti:
                case HardwareType.GpuNvidia:
                    GetGPUSensors(hardwareItem, ref sensors);
                    break;
                }
            }

            string     comPortName = args.Length > 0 ? args[0] : "COM3";
            SerialPort port        = new SerialPort(comPortName, 9600, Parity.None, 8, StopBits.One);

            port.Open();

            HardwareInfo info = new HardwareInfo();

            while (true)
            {
                foreach (var hardwareItem in myComputer.Hardware)
                {
                    hardwareItem.Update();
                }

                info.cpuLoad    = Convert.ToByte(GetSensorData(sensors.cpuLoad));
                info.cpuTemp    = Convert.ToByte(GetMaxSensorValue(sensors.cpuTemp));
                info.cpuFreq    = Convert.ToUInt16(GetSensorData(sensors.cpuFreq));
                info.gpuLoad    = Convert.ToByte(GetSensorData(sensors.gpuLoad));
                info.gpuTemp    = Convert.ToByte(GetMaxSensorValue(sensors.gpuTemp));
                info.gpuFreq    = Convert.ToUInt16(GetSensorData(sensors.gpuFreq));
                info.gpuMemFreq = Convert.ToUInt16(GetSensorData(sensors.gpuMemFreq));
                GetRAMValues(ref info);


                byte[] bytes = new byte[1];
                bytes[0] = 0x3C;
                port.Write(bytes, 0, 1);
                port.Write(info.ToBytes(), 0, 8);
                Console.WriteLine("CPU: {0}% {1}°С {2}MHz, Memory: {3}/{4}MB, GPU: {5}% {6}°С {7}/{8}MHz",
                                  info.cpuLoad, info.cpuTemp, info.cpuFreq, info.memUsed, info.memTotal, info.gpuLoad, info.gpuTemp, info.gpuFreq, info.gpuMemFreq);
                System.Threading.Thread.Sleep(250);
            }
        }
        public void InsertLightData(string HardwareMAC, long UTCTime, int SensorValue)
        {
            string  SensorType  = "light";
            Sensors LightSensor = new Sensors();

            LightSensor.Insert(HardwareMAC, UTCTime, SensorType, SensorValue);
        }
        public void StatusChanger(string slaveMac, SlaveStatus slaveStatus)
        {
            var device = Devices.FirstOrDefault(x => x.Key == slaveMac);

            if (device.Key != null)
            {
                device.Value.Slave.Status = slaveStatus;
                Devices.AddOrUpdate(slaveMac, device.Value, (key, oldVal) => device.Value);
                _logger.Info($"Status of device with MAC {slaveMac} has been updated to {slaveStatus}");
            }
            else
            {
                var sensor = Sensors.FirstOrDefault(x => x.Key == slaveMac);

                if (sensor.Key != null)
                {
                    sensor.Value.Slave.Status = slaveStatus;
                    Sensors.AddOrUpdate(slaveMac, sensor.Value, (key, oldVal) => sensor.Value);
                    _logger.Info($"Status of sensor with MAC {slaveMac} has been updated to {slaveStatus}");
                }
                else
                {
                    _logger.Info($"Can't find device or sensor with MAC: {slaveMac}.");
                }
            }
        }
Esempio n. 16
0
    public void processAvatarMessage(AvatarMessage av)
    {
        Sensors sensors = GameObject.Find("Main").GetComponent <Sensors>();

        foreach (string s in av.calibrations)
        {
            string[] chunks = s.Split(';');
            string   id     = chunks[0];
            float    px     = float.Parse(chunks[1]);
            float    py     = float.Parse(chunks[2]);
            float    pz     = float.Parse(chunks[3]);
            float    rx     = float.Parse(chunks[4]);
            float    ry     = float.Parse(chunks[5]);
            float    rz     = float.Parse(chunks[6]);
            float    rw     = float.Parse(chunks[7]);

            GameObject cloudobj = new GameObject(id);
            cloudobj.transform.localPosition = new Vector3(px, py, pz);
            cloudobj.transform.localRotation = new Quaternion(rx, ry, rz, rw);
            cloudobj.transform.localScale    = new Vector3(-1, 1, 1);
            cloudobj.AddComponent <PointCloudSimple>();


            PointCloudSimple cloud = cloudobj.GetComponent <PointCloudSimple>();
            _clouds.Add(id, cloud);
            _cloudGameObjects.Add(id, cloudobj);
            sensors.addSensor(id, new Vector3(px, py, pz), new Quaternion(rx, ry, rz, rw));
        }
        Camera.main.GetComponent <MouseOrbitImproved>().target = _cloudGameObjects.First().Value.transform;
    }
Esempio n. 17
0
 /// <summary>
 /// Starts listening to the given headset sensors.
 /// </summary>
 /// <param name="sensorsToListenTo">The sensors to start listening to.</param>
 public async void StartListeningToSensorsAsync(Sensors sensorsToListenTo = Sensors.Accelerometer | Sensors.Gyro | Sensors.Magnetometer | Sensors.Gps)
 {
     if (DeviceInfo.ConnectionStatus == ConnectionStatus.Connected)
     {
         await _engine.StartListeningToSensorReadingsAsync(sensorsToListenTo);
     }
 }
Esempio n. 18
0
        private void GetFollowedList(Sensors sensors)
        {
            FollowedList = new ObservableCollection <Sensor>(sensors.List);
            ICollectionView source = CollectionViewSource.GetDefaultView(FollowedList);

            source.Filter = item => ((Sensor)item).Followed;
        }
    public AssignableReachabilitySensor(Sensors sensors)
        : base(sensors)
    {
        MinionAssignablesProxy minionAssignablesProxy = base.gameObject.GetComponent <MinionIdentity>().assignableProxy.Get();

        minionAssignablesProxy.ConfigureAssignableSlots();
        Assignables[] components = minionAssignablesProxy.GetComponents <Assignables>();
        if (components.Length == 0)
        {
            Debug.LogError(base.gameObject.GetProperName() + ": No 'Assignables' components found for AssignableReachabilitySensor");
        }
        int num = 0;

        foreach (Assignables assignables in components)
        {
            num += assignables.Slots.Count;
        }
        slots = new SlotEntry[num];
        int num2 = 0;

        foreach (Assignables assignables2 in components)
        {
            for (int k = 0; k < assignables2.Slots.Count; k++)
            {
                slots[num2++].slot = assignables2.Slots[k];
            }
        }
        navigator = GetComponent <Navigator>();
    }
Esempio n. 20
0
        /// <summary>
        /// 处理温湿度数据
        /// </summary>
        /// <param name="num">在线数</param>
        /// <param name="index">索引</param>
        /// <param name="data">数据</param>
        /// <param name="type">传感器类型</param>
        /// <returns></returns>
        private int ProcessTemperatureAndHumidity(int num, int index, byte[] data, int type)
        {
            for (int i = 0; i < num; i++)
            {
                Digital digitalWd = new Digital();
                digitalWd.Id = Convert.ToString(data[index++], 16);
                double wd = Convert.ToDouble(data[index++] << 8 | data[index++]) / 10;
                digitalWd.Value        = wd + "℃";
                digitalWd.Name         = "温度";
                digitalWd.Type         = type;
                digitalWd.Online       = wd == 0 ? StateType.Offline : StateType.Online;
                digitalWd.State        = wd == 0 ? StateType.StateClose : StateType.StateOpen;
                digitalWd.Controllable = false;
                Sensors.Add(digitalWd);
                Digital digitalSd = new Digital();
                digitalSd.Id = digitalWd.Id;
                double sd = Convert.ToDouble(data[index++] << 8 | data[index++]) / 10;
                digitalSd.Value        = sd + "%";
                digitalSd.Name         = "湿度";
                digitalSd.Type         = type;
                digitalSd.Online       = sd == 0 ? StateType.Offline : StateType.Online;
                digitalSd.State        = sd == 0 ? StateType.StateClose : StateType.StateOpen;
                digitalSd.Controllable = false;
                Sensors.Add(digitalSd);
            }

            return(index);
        }
Esempio n. 21
0
 void Awake()
 {
     //Cache components
     Movement       = GetComponent <DroneMovement>();
     SpriteRenderer = GetComponent <SpriteRenderer>();
     sensors        = GetComponent <Sensors>();
 }
        public void InsertTemperatureData(string HardwareMAC, long UTCTime, int SensorValue)
        {
            string  SensorType        = "temperature";
            Sensors TemperatureSensor = new Sensors();

            TemperatureSensor.Insert(HardwareMAC, UTCTime, SensorType, SensorValue);
        }
Esempio n. 23
0
        public async Task <IActionResult> Edit(string id, [Bind("Identifier,Sensorname,Sensortype,Sensorcomment")] Sensors sensors)
        {
            if (id != sensors.Identifier)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sensors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SensorsExists(sensors.Identifier))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(sensors));
        }
Esempio n. 24
0
        void ModuleProgramInit()
        {
            //            wicoTravelMovement = new TravelMovement(this);
            //OurName = "";
            //moduleName += "\nOrbital V4";
            //sVersion = "4";

            wicoThrusters  = new WicoThrusters(this);
            wicoGyros      = new WicoGyros(this, wicoBlockMaster);
            wicoGasTanks   = new GasTanks(this, wicoBlockMaster);
            wicoGasGens    = new GasGens(this);
            wicoConnectors = new Connectors(this);
            wicoCameras    = new Cameras(this);
            wicoAntennas   = new Antennas(this);
            wicoSensors    = new Sensors(this, wicoBlockMaster);
            wicoPower      = new PowerProduction(this, wicoBlockMaster);
            wicoTimers     = new Timers(this, wicoBlockMaster);
            //            navRemote = new NavRemote(this);
            navCommon   = new NavCommon(this);
            _cargoCheck = new CargoCheck(this, wicoBlockMaster);
            _sensors    = new Sensors(this, wicoBlockMaster);
            _drills     = new Drills(this, wicoBlockMaster);

//                spaceDock = new SpaceDock(this, _wicoControl, wicoBlockMaster, wicoThrusters, wicoConnectors,
//                    wicoAntennas, wicoGasTanks, wicoGyros, wicoPower, wicoTimers, wicoIGC, wicoBases, navCommon, _cargoCheck);
            //wicoOrbitalLaunch = new OrbitalModes(this);
            //            wicoNavigation = new Navigation(this, wicoBlockMaster.GetMainController());

            /// DEBUG
            wicoIGC.SetDebug(true);
            _wicoControl.SetDebug(true);
        }
        public async Task <bool> InitSensor(Sensor newSlave)
        {
            if (newSlave != null)
            {
                var success = Sensors.TryAdd(newSlave.MAC, new HouseSlaveSensorClient {
                    Slave = newSlave, ConnectionId = Context.ConnectionId
                });
                if (success)
                {
                    _logger.Info($"Sensor with MAC: {newSlave.MAC}  has been added to current list");

                    var containsEntity =
                        await SensorRepository.ContainsEntityWithMAC(newSlave.MAC, CancellationToken.None);

                    if (!containsEntity)
                    {
                        await SensorRepository.Add(newSlave, Token);

                        _logger.Info($"Sensor with MAC: {newSlave.MAC} has been added to repository.");
                    }
                    else
                    {
                        await SensorRepository.Update(newSlave, Token);

                        _logger.Info($"Sensor with MAC: {newSlave.MAC} has been updated.");
                    }
                }
            }

            return(false);
        }
Esempio n. 26
0
        /// <summary>
        /// Given a weapon (countermeasures type), determines if this weapon can work on this missile. Returns bool.
        /// Takes into account remaining ammunition on soft kill weapon, but does not deduct from it. If MaxAmmunition==0,
        /// this is interpreted as unlimited ammo.
        /// </summary>
        /// <param name="wpn"></param>
        /// <returns></returns>
        public bool CanBeSoftKilled(BaseWeapon wpn)
        {
            if (wpn.MaxAmmunition > 0 && wpn.AmmunitionRemaining < 1)
            {
                return false; //soft kill is out of ammo
            }
            try
            {
                switch (wpn.WeaponClass.EwCounterMeasures)
                {
                    case GameConstants.EwCounterMeasuresType.None:
                        return false;
                    case GameConstants.EwCounterMeasuresType.Flare:
                        return Sensors.Any(s => s.SensorClass.SensorType == GameConstants.SensorType.Infrared);
                    case GameConstants.EwCounterMeasuresType.Chaff:
                        //Missiles without any sensors is considered semiactive radar seeking (uses radar transmitter from launch platform)
                        if (UnitClass.UnitType == GameConstants.UnitType.Missile)
                        {
                            return Sensors.Any(s => s.SensorClass.SensorType == GameConstants.SensorType.Radar)
                                || !Sensors.Any(s => s.SensorClass.SensorType != GameConstants.SensorType.Radar);
                        }
                        return false;
                    case GameConstants.EwCounterMeasuresType.TorpedoDecoy:
                        return UnitClass.UnitType == GameConstants.UnitType.Torpedo;
                    default:
                        return false;
                }
            }
            catch (Exception ex)
            {
                GameManager.Instance.Log.LogError("MissileUnit->CanBeSoftKilled error " + ex.Message);
                return false;

            }
        }
Esempio n. 27
0
        static void GetGPUSensors(IHardware hardwareItem, ref Sensors sensors)
        {
            foreach (var sensor in hardwareItem.Sensors)
            {
                if (sensor.Value.HasValue)
                {
                    switch (sensor.SensorType)
                    {
                    case SensorType.Temperature:
                        sensors.gpuTemp.Add(sensor);
                        break;

                    case SensorType.Load:
                        sensors.gpuLoad = sensor;
                        break;

                    case SensorType.Clock:
                        if (sensor.Name.Contains("Memory"))
                        {
                            sensors.gpuMemFreq = sensor;
                        }
                        else
                        {
                            sensors.gpuFreq = sensor;
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 28
0
 public BoontonPiStatusViewModel(IBackgroundHandler backgroundHandler, IBoontonPi device) : base(backgroundHandler, device)
 {
     foreach (var sensor in Device.Sensors)
     {
         Sensors.Add(new SensorInfoViewModel(sensor));
     }
 }
Esempio n. 29
0
        private void SetupDrillSensor(VRageMath.Matrix fromReference, int id, VRageMath.BoundingBox bb)
        {
            // grid size in meters per block
            float gridSize = sensors[id].CubeGrid.GridSize;

            // matrix from grid coordinate system to sensor coordinate system
            VRageMath.Matrix toSensor = new VRageMath.Matrix();
            sensors[id].Orientation.GetMatrix(out toSensor);
            // matrix is orthogonal => transposed matrix = inversed matrix
            VRageMath.Matrix.Transpose(ref toSensor, out toSensor);

            VRageMath.Vector3[] corners = bb.GetCorners();
            VRageMath.Vector3   diffMax = corners[1] - sensors[id].Position;
            VRageMath.Vector3   diffMin = corners[7] - sensors[id].Position;

            List <VRageMath.Vector3> .Enumerator enumerator = XUtils.Directions.GetEnumerator();
            while (enumerator.MoveNext())
            {
                VRageMath.Vector3 dir         = enumerator.Current;
                VRageMath.Vector3 gridDir     = VRageMath.Vector3.Transform(dir, fromReference);
                float             lengthToMax = (diffMax * gridDir).Max();
                float             lengthToMin = (diffMin * gridDir).Max();
                float             offset      = Sensors.getOffset(VRageMath.Vector3.Transform(gridDir, toSensor));
                float             value       = _astroidDetectSize + (Math.Max(lengthToMax, lengthToMin) + offset) * gridSize;
                value = Math.Max(Math.Min(value, sensors.Max), sensors.Min);
                sensors.Extend(dir, id, value);
            }
        }
Esempio n. 30
0
        /// <summary>
        /// This method reads as 'move sensor A to the spot occupied by sensor B'. It moves sensor A to the spot where sensor B was, and moves sensor B one spot below it.
        /// </summary>
        /// <param name="a">The sensor to be moved.</param>
        /// <param name="b">The sensor whose spot will become sensor A's new location.</param>
        public void MoveSensorTo(Sensor a, Sensor b)
        {
            if (a.Equals(b))
            {
                return;
            }

            var newIndex = 0;

            var goingDown = Sensors.IndexOf(a) < Sensors.IndexOf(b);

            if (goingDown)
            {
                newIndex = Sensors.IndexOf(b); // Going down - use current index in the list
            }
            Sensors.Remove(a);

            if (!goingDown)
            {
                newIndex = Sensors.IndexOf(b);
            }

            if (newIndex < Sensors.Count)
            {
                Sensors.Insert(newIndex, a);
            }
            else
            {
                Sensors.Add(a);
            }
        }
Esempio n. 31
0
 public VolkeTestOrchestrator(Form parentForm, BoardControl boardControl, VolkeTest test, int idParticipant, Sensors.SensorContainer sensors)
     : base(parentForm, boardControl)
 {
     this.test = test;
     this.testItems = test.Items.GetEnumerator();
     this.idParticipant = idParticipant;
     this.sensors = sensors;
 }
Esempio n. 32
0
        public SpectatorServer(Board board, Sensors.SensorContainer sensors = null)
        {
            ServerDiscovery.StartListening();
            this.board = board;
            this.sensors = sensors;

            listenerThread = new Thread(StartListening) { IsBackground = true };
            listenerThread.Start();
        }
Esempio n. 33
0
        public ChessStream(Board board, Sensors.SensorContainer sensors)
        {
            this.Board = board;
            this.Board.Checkmate += (player) => this.Enqueue(new EndGameAction(player));
            this.Board.Stalemate += (reason) => this.Enqueue(new EndGameAction(reason));
            this.Sensors = sensors;

            this.Board.PieceMoved += board_PieceMoved;
            if (sensors != null)
                this.Sensors.SensorDataReceived += sensors_SensorDataReceived;

            this.actions.Enqueue(new StartAction(board, sensors));
        }
Esempio n. 34
0
    //This is only a one time thing
    public void SendDataToServer()
    {
        //If human is controlling, we want to send human's data for training
            //Print accumulated data
        if (sensor == null) {
            sensor = this.GetComponent<Sensors> ();
        }
        Debug.Log(sensor.SerializeList());

        string url = "http://localhost:8000/sendDrivingData";
        Dictionary<string, string> postHeaders = new Dictionary<string, string>();
        postHeaders.Add ("Content-Type", "application/json");
        byte[] bytes = Encoding.UTF8.GetBytes (sensor.SerializeList());
        WWW www = new WWW (url, bytes, postHeaders);
            // Debug.Log("We sent data correctly...");

        //StartCoroutine (WaitForRequest (www));
    }
Esempio n. 35
0
        internal void StartPlayer(BoardControl sourceBoardControl, Sensors.SensorContainer sensorContainer)
        {
            sw = System.Diagnostics.Stopwatch.StartNew();
            sensorContainer.SensorDataReceived += sensorContainer_SensorDataReceived;

            sourceBoardControl.GameStarted += sourceBoardControl_GameStarted;
            sourceBoardControl.MessageShowed += sourceBoardControl_MessageShowed;
            try
            {
                this.Invoke(this.boardControl.Show);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            this.KeyDown -= SidePlayer_KeyDown;
            this.KeyDown += SidePlayer_KeyDown;
        }
        public async void getSensorData()
        {
            try
            {
                HttpClient httpClient = new HttpClient();
                httpClient.DefaultRequestHeaders.Accept.TryParseAdd("application/json");
                String uriString = "http://" + ip_address + ":8484/pi/sensors";
                String responseJsonString = await httpClient.GetStringAsync(new Uri(uriString));

                Sensors sensors = new Sensors();
                sensors = JsonConvert.DeserializeObject<Sensors>(responseJsonString);
                textBlockTempValue.Text = sensors.temperature.value.ToString();
                textBlockBaroValue.Text = sensors.barometer.value.ToString();
                textBlockAltValue.Text = sensors.altitude.value.ToString();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 37
0
        /// <summary>
        /// Returns temp in Fahrenheit
        /// Using Steinhart-Hart Equation http://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation
        /// </summary>
        /// <returns></returns>
        public float GetReading(Sensors.Types.TemperatureTypes tempType, int sampleCount = SAMPLECOUNT)
        {
            if (_Port != null)
            {
                float average = 0.0f;

                // Capture sampleCount samples for average
                for (int i = 0; i < sampleCount; i++)
                {
                    average += _Port.Read();

                    Thread.Sleep(20); // Sleep before next iteration
                }

                // Get averaged value
                average /= sampleCount;

                Debug.Print("Average reading from analog pin: " + average);

                if (average > 0)
                {
                    float Resistance = ((1024 * _BaseResistance / average) - _BaseResistance);
                    float temp = Trigo.Log(Resistance); // Saving the Log(resistance) so not to calculate  it 4 times later
                    temp = 1 / (0.001129148f + (0.000234125f * temp) + (0.0000000876741f * temp * temp * temp));

                    switch (tempType)
                    {
                        case Types.TemperatureTypes.Kelvin:
                            return temp;

                        case Types.TemperatureTypes.Celsius:
                            return temp - 273.15f;

                        default:
                            return ((temp - 273.15f) * 9.0f) / 5.0f + 32.0f;
                    }
                }
            }

            return 0.0f;
        }
Esempio n. 38
0
 // Use this for initialization
 void Start()
 {
     fitness = 0.0f;
     player = GameObject.Find ("Warrior");
     moveSpeed = 10.0f;
     rotateSpeed = 100.0f;
     animSelector = GetComponentsInChildren<OrcAnimationSelector>();
     hp = player.GetComponent<Experience>().enemyHealth;
     damage = player.GetComponent<Experience>().enemyDamage;
     alive = true;
     net = GetComponent<NeuralNet>();
     rays = GetComponent<Sensors>();
     radar = GetComponent<RangedRadar>();
     inputs = new List<double>();
     outputs = new List<double>();
     catWrath = GameObject.FindGameObjectWithTag ("catslider");
     transform.Translate (Vector3.up);
 }
Esempio n. 39
0
 private void sensors_SensorDataReceived(Sensors.Sensor sensor, Sensors.SensorData data)
 {
     this.Enqueue(new SensorAction(data));
 }
Esempio n. 40
0
 public IgnitionRelay(Cpu.Pin pin, bool initialState, Sensors.Tachometer tach)
     : base(pin, initialState, -1)
 {
     Tachometer = tach;
 }
Esempio n. 41
0
 public StartAction(Board board, Sensors.SensorContainer sensors)
 {
     this.FEN = board.GetFEN();
     this.Sensors = sensors.GetSensorsType();
 }
Esempio n. 42
0
 public TestContainer(Tests.TestOrchestrator orchestrator, Sensors.SensorContainer sensorContainer)
 {
     this.Orchestrator = orchestrator;
     this.SensorContainer = sensorContainer;
 }
Esempio n. 43
0
 public StarterRelay(Cpu.Pin pin, bool initialState, bool glitchFilter, Port.ResistorMode resistor, int timeout, Sensors.Tachometer tach)
     : base(pin, initialState, glitchFilter, resistor, timeout)
 {
     Tachometer = tach;
 }
Esempio n. 44
0
 public override TestOrchestrator GetOrchestrator(Form parentForm, BoardControl boardControl, Sensors.SensorContainer sensorContainer)
 {
     return new VolkeTestOrchestrator(parentForm, boardControl, this, 0, sensorContainer);
 }
Esempio n. 45
0
    public void Awake()
    {
        //TODO: Make a loading scene to wait for data after we send data...

        finishText = GameObject.Find ("Finished").GetComponent<Text> ();
        //crashText.text = "";

        sendData = this.GetComponent<SendData>();
        sensors = this.GetComponent<Sensors>();

        initialPosition = transform.position;
        initialRotation = transform.rotation;

        rb = GetComponent<Rigidbody> ();
        rb.centerOfMass = centerOfMass;
        audioSource = GetComponent<AudioSource> ();
        if (MoveCar.isControlledByAI) {
            //Change to IEnumerator
            StartCoroutine(sendData.GetDataFromServer());
        }
        StartAgain ();
        //Start sending data only when acceleration is pressed for the first time
    }
Esempio n. 46
0
 public ISensorItem GetSensorItem(Sensors sensorName)
 {
     return new SensorItems.DoorSwitchItem();
 }
        private void Initialize()
        {
            //blobHelper = new BlobHelper(blobAccountName, blobAccountKey);

            service = new Bluetooth();
            service.OnConnect +=
                async connection =>
                {
                    await SendResult(new SystemResultMessage("CONNECT"), "!!");
                };

            service.OnDisconnected += connection =>
            {
                this.Disconnect();
                // say disconnected... ? reconnecting ? onscreen or allow bt symbol to be all?
            };

            service.Initialize( !appSettings.MissingBackButton );
            ////service = new ServerClient(remoteHost, remoteService);
            ////service.Initialize(); 

            RefreshConnections();

            destinations = new List<IDestination>();

            //ConnectionList = new Connections();
            //connectList.ItemsSource = ConnectionList;

            DataContext = model;
            model.Sensors = new Sensors(dispatcher);
            //SensorStack.ItemsSource = model.Sensors.ItemsList;

            MessageFactory.LoadClasses();

            Sensors = model.Sensors;

            // the Azure BLOB storage helper is handed to both Camera and audio for stream options
            // if it is not used, no upload will to Azure BLOB will be done
            camera = new Camera();
            audio = new Audio();

            CheckSensors();
            Sensors.OnSensorUpdated += Sensors_OnSensorUpdated;
            Sensors.Start();

            NavigationCacheMode = NavigationCacheMode.Required;

            canvas.PointerPressed += async (s, a) => await SendEvent(s, a, "pressed");
            canvas.PointerReleased += async (s, a) => await SendEvent(s, a, "released");

            Display.PointerPressed += async (s, a) => await SendEvent(s, a, "pressed");
            Display.PointerReleased += async (s, a) => await SendEvent(s, a, "released");

            screen = new Screen(this);
            web = new Web(this);
            CheckAlwaysRunning();

            isRunning = true;
#pragma warning disable 4014
            Task.Run(() => { AutoReconnect(); });
            Task.Run(() => { ProcessMessages(); });
#pragma warning restore 4014
        }
Esempio n. 48
0
    public static Tuple<Vector, Sensors, State> AHRS_LKF_EULER(Sensors Sense, State State, Parameters Param)
    {
        Vector Attitude = new DenseVector(6, 0);
        bool restart = false;
        // get sensor data
        Matrix m = Sense.m;
        Matrix a = Sense.a;
        Matrix w = Sense.w;

        // Correct magntometers using callibration coefficients
        Matrix B = new DenseMatrix(3,3);
        B.At(0, 0, Param.magn_coefs.At(0));
        B.At(0, 1, Param.magn_coefs.At(3));
        B.At(0, 2, Param.magn_coefs.At(4));
        B.At(1, 0, Param.magn_coefs.At(5));
        B.At(1, 1, Param.magn_coefs.At(1));
        B.At(1, 2, Param.magn_coefs.At(6));
        B.At(2, 0, Param.magn_coefs.At(7));
        B.At(2, 1, Param.magn_coefs.At(8));
        B.At(2, 2, Param.magn_coefs.At(2));
        Matrix B0 = new DenseMatrix(3, 1);
        B0.At(0, 0, Param.magn_coefs.At(9));
        B0.At(1, 0, Param.magn_coefs.At(10));
        B0.At(2, 0, Param.magn_coefs.At(11));

        m = Matrix_Transpose(Matrix_Mult(Matrix_Minus(new DiagonalMatrix(3,3,1),B),Matrix_Minus(Matrix_Transpose(m),B0)));

        // Correct accelerometers using callibration coefficients
        B.At(0, 0, Param.accl_coefs.At(0));
        B.At(0, 1, Param.accl_coefs.At(3));
        B.At(0, 2, Param.accl_coefs.At(4));
        B.At(1, 0, Param.accl_coefs.At(5));
        B.At(1, 1, Param.accl_coefs.At(1));
        B.At(1, 2, Param.accl_coefs.At(6));
        B.At(2, 0, Param.accl_coefs.At(7));
        B.At(2, 1, Param.accl_coefs.At(8));
        B.At(2, 2, Param.accl_coefs.At(2));

        B0.At(0, 0, Param.accl_coefs.At(9));
        B0.At(1, 0, Param.accl_coefs.At(10));
        B0.At(2, 0, Param.accl_coefs.At(11));

        a = Matrix_Transpose(Matrix_Mult(Matrix_Minus(new DiagonalMatrix(3, 3, 1), B), Matrix_Minus(Matrix_Transpose(a), B0)));

        // Correct gyroscopes using callibration coefficients
        B.At(0, 0, Param.gyro_coefs.At(0));
        B.At(0, 1, Param.gyro_coefs.At(3));
        B.At(0, 2, Param.gyro_coefs.At(4));
        B.At(1, 0, Param.gyro_coefs.At(5));
        B.At(1, 1, Param.gyro_coefs.At(1));
        B.At(1, 2, Param.gyro_coefs.At(6));
        B.At(2, 0, Param.gyro_coefs.At(7));
        B.At(2, 1, Param.gyro_coefs.At(8));
        B.At(2, 2, Param.gyro_coefs.At(2));

        B0.At(0, 0, Param.gyro_coefs.At(9));
        B0.At(1, 0, Param.gyro_coefs.At(10));
        B0.At(2, 0, Param.gyro_coefs.At(11));

        w = Matrix_Transpose(Matrix_Mult(Matrix_Minus(new DiagonalMatrix(3, 3, 1), B), Matrix_Minus(Matrix_Transpose(w), B0)));

        // Get State
        Matrix q = State.q;
        Matrix dB = State.dB;
        Matrix dG = State.dG;
        Matrix dw = State.dw;
        Matrix P = State.P;

        Matrix Wb = Matrix_Transpose(w);
        Matrix Ab = Matrix_Transpose(a);
        Matrix Mb = Matrix_Transpose(m);

        double dT = Param.dT;

        //Correct Gyroscopes for estimate biases and scale factor
        B.At(0, 0, dB.At(0, 0));
        B.At(0, 1, dG.At(0, 0));
        B.At(0, 2, dG.At(1, 0));
        B.At(1, 0, dG.At(2, 0));
        B.At(1, 1, dB.At(1, 0));
        B.At(1, 2, dG.At(3, 0));
        B.At(2, 0, dG.At(4, 0));
        B.At(2, 1, dG.At(5, 0));
        B.At(2, 2, dB.At(2, 0));

        Matrix Omegab_ib;
        Omegab_ib = Matrix_Minus(Matrix_Mult(Matrix_Minus(new DiagonalMatrix(3, 3, 1), B), Wb),dw);

        if (q.At(0, 0).ToString() == "NaN")
        {
            restart = true;
        }

        //Quternion calculation
        q = mrotate(q, Omegab_ib, dT);

        if (q.At(0,0).ToString() == "NaN")
        {
            restart = true;
        }

        //DCM calculation
        Matrix Cbn = quat_to_DCM(q);

        //Gyro Angles
        Matrix angles = dcm2angle(Cbn);
        double Psi = (double) angles.At(0, 0);
        double Theta = (double) angles.At(0, 1);
        double Gamma = (double) angles.At(0, 2);

        //Acceleration Angles
        double ThetaAcc = (double)Math.Atan2(Ab.At(0, 0), Math.Sqrt(Ab.At(1, 0) * Ab.At(1, 0) + Ab.At(2, 0) * Ab.At(2, 0)));
        double GammaAcc = (double)-Math.Atan2(Ab.At(1, 0), Math.Sqrt(Ab.At(0, 0) * Ab.At(0, 0) + Ab.At(2, 0) * Ab.At(2, 0)));

        //Horizontal projection of magnetic field
        angles.At(0, 0, 0);
        angles.At(0, 1, ThetaAcc);
        angles.At(0, 2, GammaAcc);
        Matrix Cbh = angle2dcm(angles);
        Matrix Mh = Matrix_Mult(Matrix_Transpose(Cbh), Mb);

        //Magnetic Heading
        double PsiMgn = (double)(-Math.Atan2(Mh.At(1,0),Mh.At(0,0)) + Param.declination);

        //System matrix
        Matrix A = new DenseMatrix (15, 15, 0);
        Matrix I = new DiagonalMatrix (15, 15, 1);

        A.At(0, 3, 1);
        A.At(1, 4, 1);
        A.At(2, 5, 1);

        A.At(0, 6, 1);
        A.At(1, 7, 1);
        A.At(2, 8, 1);

        A.At(0, 9, Omegab_ib.At(1, 0));
        A.At(0, 10, Omegab_ib.At(2, 0));
        A.At(1, 11, Omegab_ib.At(0, 0));
        A.At(1, 12, Omegab_ib.At(2, 0));
        A.At(2, 13, Omegab_ib.At(0, 0));
        A.At(2, 14, Omegab_ib.At(1, 0));

        Matrix F = Matrix_Plus(I, Matrix_Const_Mult(A,dT));

        //Measurment Matrix
        double dPsi = Psi - PsiMgn;
        if (dPsi > Math.PI) dPsi = (double)(dPsi - 2 * Math.PI);
        if (dPsi < -Math.PI) dPsi = (double)(dPsi + 2 * Math.PI);

        double dTheta = Theta - ThetaAcc;
        if (dTheta > Math.PI) dTheta = (double)(dTheta - 2 * Math.PI);
        if (dTheta < -Math.PI) dTheta = (double)(dTheta + 2 * Math.PI);

        double dGamma = Gamma - GammaAcc;
        if (dGamma > Math.PI) dGamma = (double)(dGamma - 2 * Math.PI);
        if (dGamma < -Math.PI) dGamma = (double)(dGamma + 2 * Math.PI);

        Matrix z = new DenseMatrix(3, 1, 1);

        z.At(0, 0, dGamma);
        z.At(1, 0, dTheta);
        z.At(2, 0, dPsi);

        Matrix H = new DenseMatrix(3, 15, 0);
        H.At(0, 0, 1);
        H.At(1, 1, 1);
        H.At(2, 2, 1);

        if (Math.Abs(Math.Sqrt(Ab.At(0, 0) + Ab.At(1, 0) + Ab.At(2, 0))) > Param.accl_threshold)
        {
            H.At(0, 0, 0);
            H.At(1, 1, 0);
        }

        //Kalman Filter
        Matrix Q = State.Q;
        Matrix R = State.R;

        P = Matrix_Plus(Matrix_Mult(Matrix_Mult(F, P), Matrix_Transpose(F)),Q);

        if (P.At(0, 0).ToString() == "NaN")
        {
            P = new DiagonalMatrix(15, 15, (double)Math.Pow(10, -8));

            P.At(0, 0, (double)Math.Pow(10, -1));
            P.At(1, 1, (double)Math.Pow(10, -1));
            P.At(2, 2, (double)Math.Pow(10, -1));

            P.At(3, 3, (double)Math.Pow(10, -3));
            P.At(4, 4, (double)Math.Pow(10, -3));
            P.At(5, 5, (double)Math.Pow(10, -3));
            restart = true;
        }

        Tuple<Matrix, Matrix> KF_result;
        KF_result = KF_Cholesky_update(P,z,R,H);
        Matrix xf = KF_result.Item1;
        P = KF_result.Item2;

        Matrix df_hat = new DenseMatrix(3, 1, 0);
        df_hat.At(0, 0, xf.At(0, 0));
        df_hat.At(1, 0, xf.At(1, 0));
        df_hat.At(2, 0, xf.At(2, 0));

        Matrix dw_hat = new DenseMatrix(3, 1, 0);
        dw_hat.At(0, 0, xf.At(3, 0));
        dw_hat.At(1, 0, xf.At(4, 0));
        dw_hat.At(2, 0, xf.At(5, 0));
        Matrix dB_hat = new DenseMatrix(3, 1, 0);
        dB_hat.At(0, 0, xf.At(6, 0));
        dB_hat.At(1, 0, xf.At(7, 0));
        dB_hat.At(2, 0, xf.At(8, 0));
        Matrix dG_hat = new DenseMatrix(6, 1, 0);
        dG_hat.At(0, 0, xf.At(9, 0));
        dG_hat.At(1, 0, xf.At(10, 0));
        dG_hat.At(2, 0, xf.At(11, 0));
        dG_hat.At(3, 0, xf.At(12, 0));
        dG_hat.At(4, 0, xf.At(13, 0));
        dG_hat.At(5, 0, xf.At(14, 0));

        dw = Matrix_Plus(dw, dw_hat);
        dB = Matrix_Plus(dB, dB_hat);
        dG = Matrix_Plus(dG, dG_hat);

        Matrix dCbn = new DenseMatrix(3, 3, 0);

        dCbn.At(0, 1, -df_hat.At(2, 0));
        dCbn.At(0, 2, df_hat.At(1, 0));
        dCbn.At(1, 0, df_hat.At(2, 0));
        dCbn.At(1, 2, -df_hat.At(0, 0));
        dCbn.At(2, 0, -df_hat.At(1, 0));
        dCbn.At(2, 1, df_hat.At(0, 0));

        Cbn = Matrix_Mult(Matrix_Plus(new DiagonalMatrix(3, 3, 1), dCbn), Cbn);
        if (Cbn.At(0, 0).ToString() == "NaN")
        {
            restart = true;
        }
        if (dcm2quat(Cbn).At(0, 0).ToString() == "NaN")
        {
            restart = true;
        }
        q = dcm2quat(Cbn);
        if (q.At(0, 0).ToString() == "NaN")
        {
            restart = true;
        }
        q = quat_norm(q);

        if (q.At(0, 0).ToString() == "NaN")
        {
            restart = true;
        }

        Attitude.At(0, Psi);
        Attitude.At(1, Theta);
        Attitude.At(2, Gamma);
        Attitude.At(3, PsiMgn);
        Attitude.At(4, ThetaAcc);
        Attitude.At(5, GammaAcc);

        State.q = q;
        State.dG = dG;
        State.dB = dB;
        State.dw = dw;
        State.P = P;

        Sense.w = Matrix_Transpose(Omegab_ib);
        Sense.a = a;
        Sense.m = m;

        if (restart)
        {
            Matrix Initia_quat = new DenseMatrix(1, 4, 0);
            Initia_quat.At(0, 0, 1);
            State = new Kalman_class.State(ACCLERATION_NOISE, MAGNETIC_FIELD_NOISE, ANGULAR_VELOCITY_NOISE,
                Math.Pow(10, -6), Math.Pow(10, -15), Math.Pow(10, -15), Initia_quat);
        }

        return new Tuple <Vector, Sensors, State>(Attitude, Sense, State);
    }
Esempio n. 49
0
 public ChessStreamWriter(Board board, Sensors.SensorContainer sensors, string destinationFile)
     : this(board, sensors, File.OpenWrite(destinationFile))
 {
 }
Esempio n. 50
0
 void Awake()
 {
     //StartCoroutine (SendAndReceiveData())
     sensor = this.GetComponent<Sensors> ();
 }
Esempio n. 51
0
 public ChessStreamWriter(Board board, Sensors.SensorContainer sensors, Stream outputStream)
     : this(new ChessStream(board, sensors), outputStream)
 {
 }
Esempio n. 52
0
 public IgnitionRelay(Cpu.Pin pin, bool initialState, bool glitchFilter, Port.ResistorMode resistor, Sensors.Tachometer tach)
     : base(pin, initialState, glitchFilter, resistor, -1)
 {
     Tachometer = tach;
 }
Esempio n. 53
0
 public StarterRelay(Cpu.Pin pin, bool initialState, int timeout, Sensors.Tachometer tach)
     : base(pin, initialState, timeout)
 {
     Tachometer = tach;
 }
        private void Initialize()
        {
            this.destinations = new List<IDestination>();

            this.DataContext = this.model;
            this.model.Sensors = new Sensors(this.dispatcher);

            MessageFactory.LoadClasses();

            this.Sensors = this.model.Sensors;

            // the Azure BLOB storage helper is handed to both Camera and audio for stream options
            // if it is not used, no upload will to Azure BLOB will be done
            this.camera = new Camera();
            this.audio = new Audio();

            this.Sensors.OnSensorUpdated += this.Sensors_OnSensorUpdated;
            this.Sensors.Start();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.canvas.PointerPressed += async (s, a) => await this.SendEvent(s, a, "pressed");
            this.canvas.PointerReleased += async (s, a) => await this.SendEvent(s, a, "released");

            this.Display.PointerPressed += async (s, a) => await this.SendEvent(s, a, "pressed");
            this.Display.PointerReleased += async (s, a) => await this.SendEvent(s, a, "released");

            this.screen = new Screen(this);
            this.web = new Web(this);
            this.CheckAlwaysRunning();

            this.isRunning = true;
#pragma warning disable 4014
            Task.Run(
                () =>
                    {
                        this.SetService();
                        this.AutoReconnect();
                    });
            Task.Run(() => { this.ProcessMessages(); });
#pragma warning restore 4014
        }
Esempio n. 55
0
 public void ControlUpdate(motor[] motors, Transmitter tx, Sensors sensors)
 {
     if (armed)
     {
         if (Modes.BARO_MODE)
         {//35 degrees max inclination
             roll.Control(sensors.GetRotation().x, sensors.GetAngularVelocity().x, -tx.GetRoll() * 35);
             pitch.Control(sensors.GetRotation().z, sensors.GetAngularVelocity().z, -tx.GetPitch() * 35);
             yaw.Control(sensors.GetRotation().y, sensors.GetAngularVelocity().y, tx.GetYaw() * 50);
         }
         //Calculates and applies the force to the motors
         for (int i = 0; i < 4; i++)
         {
             //General force (throttle)
             motors[i].force = tx.GetThrottle() * 2.0F; //:) This should take into account the air density, air temp, altitude, batteries charge, etc.
                                                        //Pitch force
             motors[i].force -= motors[i].position.x * (pitch.p + pitch.i + pitch.d);
             //Roll force
             motors[i].force += motors[i].position.z * (roll.p + roll.i + roll.d);// + (-0.1F + Random.value*0.2F);
         }
         if (tx.GetYaw() < -0.9 && tx.GetThrottle() < 0.1)
         {
             contCyclesBeforeArmUnarm++;
         }
         else
         {
             contCyclesBeforeArmUnarm = 0;
         }
         if (contCyclesBeforeArmUnarm >= 100)
         {
             armed = false;
             Debug.Log("UNARMED");
         }
     }
     else
     {
         for (int i = 0; i < 4; i++)
         {
             motors[i].force = 0f;
         }
         if (tx.GetYaw() > 0.9 && tx.GetThrottle() < 0.1)
         {
             contCyclesBeforeArmUnarm++;
         }
         else
         {
             contCyclesBeforeArmUnarm = 0;
         }
         if (contCyclesBeforeArmUnarm >= 100)
         {
             armed = true;
             Debug.Log("ARMED");
         }
     }
 }
Esempio n. 56
0
    void Start()
    {
        //Multicopter motor configuration
        //Quadcopter
        motors = new motor[4];
        motors[0] = new motor(new Vector3(1, 0, 1), 0f, true); //Front left CW
        motors[1] = new motor(new Vector3(1, 0, -1), 0f, false); //Front righ CCW
        motors[2] = new motor(new Vector3(-1, 0, -1), 0f, true); //Rear right CW
        motors[3] = new motor(new Vector3(-1, 0, 1), 0, false); //Rear left CCW

        tx = new Transmitter();
        sensors = new Sensors(GetComponent<Rigidbody>());
        controller = new CFController(0);

        armed = true;
    }
Esempio n. 57
0
 public override TestOrchestrator GetOrchestrator(Form parentForm, BoardControl boardControl, int idParticipant, Sensors.SensorContainer sensorContainer)
 {
     return new AdHocOrchestrator(parentForm, boardControl, this);
 }
Esempio n. 58
0
        void sensorContainer_SensorDataReceived(Sensors.Sensor sensor, Sensors.SensorData data)
        {
            if (data is MouseSensorData)
                this.Invoke(() => this.boardControl.SetMousePosition(((MouseSensorData)data).Location));

            if (data is EyeTrackerSensorData)
                ShowEyeSensor(((EyeTrackerSensorData)data).LeftPosition, ((EyeTrackerSensorData)data).RightPosition);
        }
Esempio n. 59
0
File: Test.cs Progetto: hcesar/Chess
 public abstract TestOrchestrator GetOrchestrator(Form parentForm, BoardControl boardControl, int idParticipant, Sensors.SensorContainer sensorContainer);
Esempio n. 60
0
 public SensorAction(Sensors.SensorData data)
 {
     this.Data = data;
 }