public void showRandHand() { AngleBasedHandModel result = createRandom(); output.visualizeHand(result); Debug.Log("Comfort+Discomfort: " + (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result))); }
public void CalcComfort() { comfortArray = GameObject.FindObjectsOfType <Comfort>(); comfortCount = comfortArray.Length; float minimalDistance = 1000; foreach (var item in comfortArray) { if (!item.occupied) { float distance = Vector3.Distance(item.transform.position, transform.position); if (distance < minimalDistance && item.userQueue == null) { cantFindComfort = false; minimalDistanceComfort = item; minimalDistance = distance; item.userQueue = gameObject; } } else if (item.userQueue == gameObject) { return; } else { //все занято, или нет ни одной minimalDistanceComfort = null; lookingFor = null; ai.target = null; ai.agent.ResetPath(); } } }
public Fridge() { this.make = ""; this.price = 0; this.volume = 0; this.reliability = 0; this.comfort = Comfort.Unset; creationDate = DateTime.Today; }
public MsqcTags() { Durability = new Durability(); Sizing = new Sizing(); Comfort = new Comfort(); Durability.TotalEntries = 0; Comfort.TotalEntries = 0; Sizing.TotalEntries = 0; }
public Fridge(string make, decimal price, decimal volume, decimal reliability, Comfort comfort) { this.make = make; this.price = price; this.volume = volume; this.reliability = reliability; this.comfort = comfort; creationDate = DateTime.Today; }
public AngleBasedHandModel createRandom(float disc_min, float disc_max) { AngleBasedHandModel result; do { result = createRandom(); }while (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) < disc_min || Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) > disc_max); Debug.Log("Discomfort: " + Discomfort.getDiscomfortAngled(result) + ", Comfort: " + Comfort.getRRPComponent(result)); return(result); }
void saveData() { UserStudyData.instance.targetHand = targethand; UserStudyData.instance.angleDis = Comfort.getRRPComponent(targethand); UserStudyData.instance.hyperDis = Discomfort.getHyperExtensionComponent(targethand); UserStudyData.instance.yaxisDis = Discomfort.getAbductionComponent(targethand); UserStudyData.instance.interDis = Discomfort.getInterFingerComponent(targethand); UserStudyData.instance.discomfort = Discomfort.getDiscomfortAngled(targethand); UserStudyData.instance.palmangle = targethand.getAvgMCPAngle() * 0; Debug.Log(targethand.getAvgMCPAngle() * 0); }
public Comfort() { if (_instance != null) { return; } idleStates = PostureDataHandler.instance.getSublist(TrainingUnit.Posture.idle); _instance = this; }
public void convertAll() { inputFileName = PostureDataHandler.instance.filePath + "ComfortEvaluationData" + UserStudyData.instance.fileEnding; outputFileName = PostureDataHandler.instance.filePath + "ComfortEvaluationCompressed" + UserStudyData.instance.fileEnding; read = new StreamReader(inputFileName); string oldHeader = read.ReadLine(); string[] endlArr = { ", " }; first = System.Array.IndexOf(oldHeader.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries), "RandomHandThumbIP"); rating = System.Array.IndexOf(oldHeader.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries), "Rating"); int currentRating; if (File.Exists(outputFileName)) { File.Delete(outputFileName); } string endl = ", "; string fileHeader = "Rating" + endl + Discomfort.getInterFingerCSVHeader(endl) + Discomfort.getAbductionCSVHeader(endl) + Discomfort.getHyperExtensionCSVHeader(endl) + Comfort.getRRPCSVHeader(endl); File.AppendAllText(outputFileName, fileHeader + System.Environment.NewLine); while (!read.EndOfStream) { string dataLine = read.ReadLine(); string[] input = dataLine.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries); currentRating = int.Parse(input[rating]); handNew.parseCSV(input, first); File.AppendAllText( outputFileName, currentRating + endl + Discomfort.getInterFingerCSV(handNew, endl) + Discomfort.getAbductionCSV(handNew, endl) + Discomfort.getHyperExtensionCSV(handNew, endl) + Comfort.getRRPCSV(handNew, endl) + System.Environment.NewLine ); } Debug.Log("Done!"); read.Close(); }
void saveResults() { File.AppendAllText( fileName, UserStudyData.instance.Name + endl + slider.value + endl + Discomfort.getDiscomfortAngled(targethand) + endl + Comfort.getRRPComponent(targethand) + endl + Discomfort.getInterFingerComponent(targethand) + endl + Discomfort.getAbductionComponent(targethand) + endl + Discomfort.getHyperExtensionComponent(targethand) + endl + Discomfort.getInterFingerCSV(targethand, endl) + Discomfort.getAbductionCSV(targethand, endl) + Discomfort.getHyperExtensionCSV(targethand, endl) + Comfort.getRRPCSV(targethand, endl) + targethand.ToCSVString(endl) + Environment.NewLine ); }
// Use this for initialization void Start() { remaining = UserStudyData.instance.evaluations; fileName = PostureDataHandler.instance.filePath + "ComfortEvaluationData" + UserStudyData.instance.fileEnding; string fileHeader = "Name" + endl + "Rating" + endl + "Discomfort" + endl + "Comfort" + endl + "InterDis" + endl + "AbductionDis" + endl + "HyperDis" + endl + Discomfort.getInterFingerCSVHeader(endl) + Discomfort.getAbductionCSVHeader(endl) + Discomfort.getHyperExtensionCSVHeader(endl) + Comfort.getRRPCSVHeader(endl) + AngleBasedHandModel.getCSVHeader(endl, "RandomHand"); if (!File.Exists(fileName)) { File.AppendAllText(fileName, fileHeader + Environment.NewLine); } else { StreamReader read = new StreamReader(fileName); string oldHeader = read.ReadLine(); read.Close(); if (!oldHeader.Equals(fileHeader)) { Debug.Log("Fileheader not matching. Creating new file."); File.Delete(fileName); File.AppendAllText(fileName, fileHeader + Environment.NewLine); } } reset(); if (UserStudyData.instance.right) { outputHand.transform.localScale = new Vector3(-outputHand.transform.localScale.x, outputHand.transform.localScale.y, outputHand.transform.localScale.z); } }
void saveResults() { File.AppendAllText( fileNameEnd, UserStudyData.instance.Name + endl + UserStudyData.instance.ComfortEvaluation + endl + timer + endl + timerTracking + endl + Discomfort.getDiscomfortAngled(UserStudyData.instance.targetHand) + endl + Comfort.getRRPComponent(UserStudyData.instance.targetHand) + endl + Discomfort.getInterFingerComponent(UserStudyData.instance.targetHand) + endl + Discomfort.getAbductionComponent(UserStudyData.instance.targetHand) + endl + Discomfort.getHyperExtensionComponent(UserStudyData.instance.targetHand) + endl + Discomfort.getInterFingerCSV(UserStudyData.instance.targetHand, endl) + Discomfort.getAbductionCSV(UserStudyData.instance.targetHand, endl) + Discomfort.getHyperExtensionCSV(UserStudyData.instance.targetHand, endl) + Comfort.getRRPCSV(UserStudyData.instance.targetHand, endl) + UserStudyData.instance.targetHand.ToCSVString(endl) + Environment.NewLine ); }
IEnumerator getNewRandomHand() { generating = true; int counter = 0; Debug.Log(targetdiscomfort); do { uncomfortable = randHand.createRandom(); yield return(new WaitForEndOfFrame()); counter++; if (counter > 200) { counter = 0; targetdiscomfort -= 25; Debug.Log(targetdiscomfort); } }while (Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) < targetdiscomfort || Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) > targetdiscomfort + 100); generating = false; }
IEnumerator getNewRandomHand() { generating = true; targetdiscomfort = UnityEngine.Random.Range(50, 1000); int counter = 0; Debug.Log(targetdiscomfort); do { targethand = randHand.createRandom(); outputHand.visualizeHand(targethand); yield return(new WaitForEndOfFrame()); counter++; if (counter > 200) { counter = 0; targetdiscomfort = UnityEngine.Random.Range(50, 1000); Debug.Log(targetdiscomfort); } }while (Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) < targetdiscomfort || Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) > targetdiscomfort + 100); generating = false; }
public ActionResult Delete(Comfort comfort) { _context.ComfortsSet.Remove(_context.ComfortsSet.Find(comfort.Id)); _context.SaveChanges(); return(RedirectToAction("Index")); }
// Update is called once per frame void Update() { //TODO: this seems to not be correct; position values are funny hand.rotation = root.rotation; hand.position = root.position; sQuaternion temp = Quaternion.Inverse(root.rotation) * thumb1.rotation; if (rightHanded) { temp.mirrorX(); } hand.thumb.tmc = temp; hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_X] = ((Quaternion)temp).eulerAngles.x; hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_Y] = ((Quaternion)temp).eulerAngles.y; hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.TMC_Z] = ((Quaternion)temp).eulerAngles.z; hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.MP] = Vector3.Angle(thumb1.forward, thumb2.forward); hand.thumb.jointAngles [(int)AngleBasedThumbModel.Fingerjoints.IP] = Vector3.Angle(thumb3.forward, thumb2.forward); temp = Quaternion.Inverse(root.rotation) * index1.rotation; if (rightHanded) { temp.mirrorX(); } hand.fingers [(int)AngleBasedHandModel.FingerName.index].mcp = temp; hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y; hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP] = ((Quaternion)temp).eulerAngles.x; hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP] = Vector3.Angle(index1.forward, index2.forward); hand.fingers[(int)AngleBasedHandModel.FingerName.index].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP] = Vector3.Angle(index2.forward, index3.forward); temp = Quaternion.Inverse(root.rotation) * middle1.rotation; if (rightHanded) { temp.mirrorX(); } hand.fingers [(int)AngleBasedHandModel.FingerName.middle].mcp = temp; hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y; hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP] = ((Quaternion)temp).eulerAngles.x; hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP] = Vector3.Angle(middle1.forward, middle2.forward); hand.fingers[(int)AngleBasedHandModel.FingerName.middle].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP] = Vector3.Angle(middle2.forward, middle3.forward); temp = Quaternion.Inverse(root.rotation) * ring1.rotation; if (rightHanded) { temp.mirrorX(); } hand.fingers [(int)AngleBasedHandModel.FingerName.ring].mcp = temp; hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y; hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP] = ((Quaternion)temp).eulerAngles.x; hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP] = Vector3.Angle(ring1.forward, ring2.forward); hand.fingers[(int)AngleBasedHandModel.FingerName.ring].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP] = Vector3.Angle(ring2.forward, ring3.forward); temp = Quaternion.Inverse(root.rotation) * pinky1.rotation; if (rightHanded) { temp.mirrorX(); } hand.fingers [(int)AngleBasedHandModel.FingerName.pinky].mcp = temp; hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_SIDE] = ((Quaternion)temp).eulerAngles.y; hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.MCP_UP] = ((Quaternion)temp).eulerAngles.x; hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.PIP] = Vector3.Angle(pinky1.forward, pinky2.forward); hand.fingers[(int)AngleBasedHandModel.FingerName.pinky].jointAngles[(int)AngleBasedFingerModel.Fingerjoints.DIP] = Vector3.Angle(pinky2.forward, pinky3.forward); if (isDetecting) { if (Input.GetKeyDown("k")) { saveCurrentAs(trainingPosture); } else if (Input.GetKeyDown("s")) { PostureDataHandler.instance.saveData(); } else { currentPosture = knn.detectPosture(hand); if (poseText) { poseText.text = "Posture: " + currentPosture + "; Discomfort: " + getDiscomfort() + "; Comfort: " + Comfort.getRRPComponent(hand); } } } }
// Update is called once per frame void Update() { text.text = "RRP-Component: " + Mathf.Max(0.0f, Comfort.getRRPComponent(hand.hand) - 20); }
// Use this for initialization void Start() { HandPostureUtils.reload(); if (UserStudyData.instance.right) { hand = rightHand; palm = palmRight; } else { hand = leftHand; palm = palmLeft; } string fileHeader = "Name" + endl + "UserEvaluation" + endl + "Discomfort" + endl + "Time" + endl + "Precision" + endl + "Postureholdtime" + endl + "TargetIndex" + endl + "Posture" + endl + "AngleDis" + endl + "InterDis" + endl + "YAxisDis" + endl + "HyperDis" + endl + AngleBasedHandModel.getCSVHeader(endl, "ActualHand") + endl + AngleBasedHandModel.getCSVHeader(endl, "GivenHand"); string fileHeaderEnd = "Name" + endl + "Rating" + endl + "Time" + endl + "TrackingTime" + endl + "Discomfort" + endl + "Comfort" + endl + "InterDis" + endl + "AbductionDis" + endl + "HyperDis" + endl + Discomfort.getInterFingerCSVHeader(endl) + Discomfort.getAbductionCSVHeader(endl) + Discomfort.getHyperExtensionCSVHeader(endl) + Comfort.getRRPCSVHeader(endl) + AngleBasedHandModel.getCSVHeader(endl, "RandomHand"); fileName = PostureDataHandler.instance.filePath + "TargetShootingData" + UserStudyData.instance.fileEnding; fileNameEnd = PostureDataHandler.instance.filePath + "TargetShootingDataEnd" + UserStudyData.instance.fileEnding; if (!File.Exists(fileName)) { File.AppendAllText(fileName, fileHeader + Environment.NewLine); } else { StreamReader read = new StreamReader(fileName); string oldHeader = read.ReadLine(); read.Close(); if (!oldHeader.Equals(fileHeader)) { Debug.Log("Fileheader not matching. Creating new file."); File.Delete(fileName); File.AppendAllText(fileName, fileHeader + Environment.NewLine); } } if (!File.Exists(fileNameEnd)) { File.AppendAllText(fileNameEnd, fileHeaderEnd + Environment.NewLine); } else { StreamReader read = new StreamReader(fileNameEnd); string oldHeader = read.ReadLine(); read.Close(); if (!oldHeader.Equals(fileHeaderEnd)) { Debug.Log("Fileheader not matching. Creating new file."); File.Delete(fileNameEnd); File.AppendAllText(fileNameEnd, fileHeaderEnd + Environment.NewLine); } } remainingTargets = numTargets; if (UserStudyData.instance.right) { outputHand.transform.localScale = new Vector3(-outputHand.transform.localScale.x, outputHand.transform.localScale.y, outputHand.transform.localScale.z); } if (UserStudyData.instance.targetHand != null) { outputHand.visualizeHand(UserStudyData.instance.targetHand); } else { outputHand.gameObject.SetActive(false); } }
public static void Launch(LaunchMode launchMode = LaunchMode.MicroFramework) { try { Comfort.Init(); IntegratedHeatingAndAirConditioning.Init(); _resetCause = GHI.Processor.Watchdog.LastResetCause; blueLed = new OutputPort(FEZPandaIII.Gpio.Led1, false); greenLed = new OutputPort(FEZPandaIII.Gpio.Led2, false); orangeLed = new OutputPort(FEZPandaIII.Gpio.Led3, _resetCause == GHI.Processor.Watchdog.ResetCause.Watchdog); redLed = new OutputPort(FEZPandaIII.Gpio.Led4, false); #if (NETMF && RELEASE) || (OnBoardMonitorEmulator && !DebugOnRealDeviceOverFTDI) _useWatchdog = true; #endif if (_useWatchdog) { GHI.Processor.Watchdog.Enable(watchDogTimeoutInMilliseconds); } settings = Settings.Instance; FileLogger.Create(); InitManagers(); InstrumentClusterElectronics.DateTimeChanged += DateTimeChanged; Logger.Debug("Watchdog.ResetCause: " + (_resetCause == GHI.Processor.Watchdog.ResetCause.Normal ? "Normal" : "Watchdog")); if (_useWatchdog) { Logger.Debug("Watchdog enabled with timeout: " + watchDogTimeoutInMilliseconds); } //SettingsScreen.Instance.Status = version.Length > 11 ? version.Replace(" ", "") : version; //Localization.SetCurrent(RussianLocalization.SystemName); //Localization.SetCurrent(settings.Language); //Comfort.AutoLockDoors = settings.AutoLockDoors; //Comfort.AutoUnlockDoors = settings.AutoUnlockDoors; //Comfort.AutoCloseWindows = settings.AutoCloseWindows; //Comfort.AutoCloseSunroof = settings.AutoCloseSunroof; #region MassStorage //Controller.DeviceConnectFailed += (sss, eee) => //{ // Logger.Error("DeviceConnectFailed!"); // LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(redLed, 1, 100)); // ControllerState = UsbMountState.DeviceConnectFailed; // _removableMediaInsertedSync.Set(); //}; //Controller.UnknownDeviceConnected += (ss, ee) => //{ // Logger.Error("UnknownDeviceConnected!"); // LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(redLed, 2, 100)); // ControllerState = UsbMountState.UnknownDeviceConnected; // _removableMediaInsertedSync.Set(); //}; //Controller.MassStorageConnected += (sender, massStorage) => //{ // Logger.Debug("Controller MassStorageConnected!"); // LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(orangeLed, 2, 100)); // ControllerState = UsbMountState.MassStorageConnected; RemovableMedia.Insert += (s, e) => { LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(orangeLed, 3, 100)); string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory; settings = Settings.Init(rootDirectory + "\\imBMW.ini"); FileLogger.Init(rootDirectory + "\\logs", () => VolumeInfo.GetVolumes()[0].FlushAll()); Logger.Debug("Logger initialized."); MassStorageMountState = MassStorageMountState.Mounted; _removableMediaInsertedSync.Set(); }; RemovableMedia.Eject += (s, e) => { FileLogger.Eject(); Logger.Print("RemovableMedia Ejected!"); LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(greenLed, 3, 100)); MassStorageMountState = MassStorageMountState.Unmounted; }; //_massStorage = massStorage; _massStorage = new SDCard(SDCard.SDInterface.SPI); _massStorage.Mount(); //}; #if RELEASE //Controller.Start(); #else #if NETMF // WARNING! Be aware, without this line you can get 'Controller -> DeviceConnectFailed' each time when you start debugging... if (Debugger.IsAttached) #endif { //Controller.Start(); } #endif #endregion LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(orangeLed, 1, 200)); bool isSignalled = _removableMediaInsertedSync.WaitOne(Debugger.IsAttached ? 10000 : 10000, true); if (!isSignalled) // No Storage inserted { InstrumentClusterElectronics.ShowNormalTextWithGong(MassStorageMountState.ToStringValue()); FrontDisplay.RefreshLEDs(LedType.RedBlinking, append: true); LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(redLed, 3, 100)); } else { if (MassStorageMountState == MassStorageMountState.DeviceConnectFailed || MassStorageMountState == MassStorageMountState.UnknownDeviceConnected) { InstrumentClusterElectronics.ShowNormalTextWithGong(MassStorageMountState.ToStringValue()); FrontDisplay.RefreshLEDs(LedType.Red, append: true); LedBlinkingQueueThreadWorker.Enqueue(new LedBlinkingItem(redLed, 4, 100)); ResetBoard(); } } Logger.Debug("MassStorage state: " + MassStorageMountState.ToStringValue()); InstrumentClusterElectronics.RequestDateTime(); Init(); Logger.Debug("Started!"); BordmonitorMenu.MenuButtonHold += () => { FrontDisplay.RefreshLEDs(LedType.Empty); if (Emulator.IsEnabled) { Emulator.PlayerIsPlayingChanged += (s, isPlayingChangedValue) => { if (!isPlayingChangedValue) { ResetBoard(); } }; Radio.PressOnOffToggle(); //Emulator.IsEnabled = false; } else { ResetBoard(); } }; BordmonitorMenu.PhoneButtonHold += () => { VolumioRestApiPlayer.Reboot(); Logger.Warning("Reboot request sent."); }; BordmonitorMenu.EjectButtonHold += () => { UnmountMassStorage(); _massStorage = null; Logger.Warning("UNMOUNTED!"); }; Manager.Instance.AddMessageReceiverForSourceDevice(DeviceAddress.InstrumentClusterElectronics, m => { if (m.Data[0] == 0x11 && m.Data.Length == 2) // Ignition status { GHI.Processor.Watchdog.ResetCounter(); } }); requestIgnitionStateTimer = new Timer(RequestIgnitionStateTimerHandler, null, 0, requestIgnitionStateTimerPeriod); imBMWTest(); Logger.Debug("Actions inited!"); if (launchMode == LaunchMode.MicroFramework) { Thread.Sleep(Timeout.Infinite); } } catch (Exception ex) { LedBlinking(new LedBlinkingItem(redLed, 5, 200)); Thread.Sleep(200); redLed.Write(true); Logger.Error(ex, "while modules initialization"); ResetBoard(); } }
public ActionResult Update(Comfort comfort) { _context.Entry(comfort).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); }