void determineInitialConfigurations(ref List <ExperimentSetup> experimentSetups) { for (int i = 0; i < experimentSetups.Count; i++) { ExperimentSetup setup = experimentSetups[i]; if (setup.initialConfiguration.isRandom) { if (!onlyRandomizeForward) { setup.initialConfiguration.initialPosition = VirtualPathGenerator.getRandomPositionWithinBounds(-0.5f * setup.trackingSizeShape.x, 0.5f * setup.trackingSizeShape.x, -0.5f * setup.trackingSizeShape.z, 0.5f * setup.trackingSizeShape.z); } setup.initialConfiguration.initialForward = VirtualPathGenerator.getRandomForward(); //Debug.LogWarning("Random Initial Configuration for size (" + trackingSizeShape.x + ", " + trackingSizeShape.z + "): Pos" + initialConfiguration.initialPosition.ToString("f2") + " Forward" + initialConfiguration.initialForward.ToString("f2")); experimentSetups[i] = setup; } else if (Mathf.Abs(setup.initialConfiguration.initialPosition.x) > 0.5f * setup.trackingSizeShape.x || Mathf.Abs(setup.initialConfiguration.initialPosition.y) > 0.5f * setup.trackingSizeShape.z) { Debug.LogError("Invalid beginning position selected. Defaulting Initial Configuration to (0, 0) and (0, 1)."); setup.initialConfiguration.initialPosition = Vector2.zero; setup.initialConfiguration.initialForward = Vector2.up; experimentSetups[i] = setup; } if (!setup.initialConfiguration.isRandom) { // Deal with diagonal hack if (setup.initialConfiguration.initialForward == Vector2.one) { setup.initialConfiguration.initialForward = (new Vector2(setup.trackingSizeShape.x, setup.trackingSizeShape.z)).normalized; experimentSetups[i] = setup; } } } }
public void Initialize() { this.initialPosition = Vector2.zero; this.initialForward = Vector2.up; // Initialize according to the motion type if (this.movementController == MotionManager.MovementController.AutoPilot) { this.DISTANCE_TO_WAYPOINT_THRESHOLD = 0.05f;// 0.0001f; // Setup waypoints and pathseed InstantiateSimulationPrefab(); switch (condPath) { case VirtualPathGenerator.PathSeedChoice.Office: currentPathSeed = VirtualPathGenerator.getPathSeedOfficeBuilding(); break; case VirtualPathGenerator.PathSeedChoice.ExplorationSmall: currentPathSeed = VirtualPathGenerator.getPathSeedExplorationSmall(); break; case VirtualPathGenerator.PathSeedChoice.ExplorationLarge: currentPathSeed = VirtualPathGenerator.getPathSeedExplorationLarge(); break; case VirtualPathGenerator.PathSeedChoice.LongWalk: currentPathSeed = VirtualPathGenerator.getPathSeedLongCorridor(); break; case VirtualPathGenerator.PathSeedChoice.ZigZag: currentPathSeed = VirtualPathGenerator.getPathSeedZigzag(); break; case VirtualPathGenerator.PathSeedChoice.Maze: this.waypoints = VirtualPathGenerator.getPathSeedMaze(); break; } if (condPath != VirtualPathGenerator.PathSeedChoice.Maze) { float sumOfDistances, sumOfRotations; this.waypoints = VirtualPathGenerator.generatePath(currentPathSeed, initialPosition, initialForward, out sumOfDistances, out sumOfRotations); Debug.Log("MOTION sumOfDistances: " + sumOfDistances); Debug.Log("MOTION sumOfRotations: " + sumOfRotations); } // Set First Waypoint Position and Enable It this.targetWaypoint.position = new Vector3(this.waypoints[0].x, this.targetWaypoint.position.y, this.waypoints[0].y); this.waypointIterator = 0; this.targetWaypoint.gameObject.SetActive(true); Debug.Log("First waypoint initialized"); } }
void setUpExperimentTrackingAreaShape(VirtualPathGenerator.PathSeedChoice pathSeedChoice, System.Type redirector, System.Type resetter) { // Initialize Values this.redirector = redirector; this.resetter = resetter; pathSeeds = new List <VirtualPathGenerator.PathSeed>(); trackingSizes = new List <TrackingSizeShape>(); initialConfigurations = new List <InitialConfiguration>(); gainScaleFactors = new List <Vector3>(); trialsForCurrentExperiment = pathSeedChoice == VirtualPathGenerator.PathSeedChoice.LongWalk ? 1 : MAX_TRIALS; switch (pathSeedChoice) { case VirtualPathGenerator.PathSeedChoice.Office: pathSeeds.Add(VirtualPathGenerator.getPathSeedOfficeBuilding()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationSmall: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationSmall()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationLarge: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationLarge()); break; case VirtualPathGenerator.PathSeedChoice.LongWalk: pathSeeds.Add(VirtualPathGenerator.getPathSeedLongCorridor()); break; case VirtualPathGenerator.PathSeedChoice.ZigZag: pathSeeds.Add(VirtualPathGenerator.getPathSeedZigzag()); break; } for (int area = 100; area <= 200; area += 50) { for (float ratio = 1; ratio <= 2; ratio += 0.5f) { trackingSizes.Add(new TrackingSizeShape(Mathf.Sqrt(area) / Mathf.Sqrt(ratio), Mathf.Sqrt(area) * Mathf.Sqrt(ratio))); } } initialConfigurations.Add(new InitialConfiguration(new Vector2(0, 0), new Vector2(0, 1))); initialConfigurations.Add(new InitialConfiguration(new Vector2(0, 0), new Vector2(1, 0))); initialConfigurations.Add(new InitialConfiguration(new Vector2(0, 0), Vector2.one)); // HACK: THIS NON-NORMALIZED ORIENTATION WILL INDICATE DIAGONAL AND WILL BE FIXED LATER gainScaleFactors.Add(Vector3.one); }
void setUpExperimentTrackingAreaSizePerformance(VirtualPathGenerator.PathSeedChoice pathSeedChoice, System.Type redirector, System.Type resetter) { // Initialize Values this.redirector = redirector; this.resetter = resetter; pathSeeds = new List <VirtualPathGenerator.PathSeed>(); trackingSizes = new List <TrackingSizeShape>(); initialConfigurations = new List <InitialConfiguration>(); gainScaleFactors = new List <Vector3>(); trialsForCurrentExperiment = pathSeedChoice == VirtualPathGenerator.PathSeedChoice.LongWalk ? 1 : MAX_TRIALS; switch (pathSeedChoice) { case VirtualPathGenerator.PathSeedChoice.Office: pathSeeds.Add(VirtualPathGenerator.getPathSeedOfficeBuilding()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationSmall: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationSmall()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationLarge: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationLarge()); break; case VirtualPathGenerator.PathSeedChoice.LongWalk: pathSeeds.Add(VirtualPathGenerator.getPathSeedLongCorridor()); break; case VirtualPathGenerator.PathSeedChoice.ZigZag: pathSeeds.Add(VirtualPathGenerator.getPathSeedZigzag()); break; } for (int i = 2; i <= 60; i += 1) { trackingSizes.Add(new TrackingSizeShape(i, i)); } initialConfigurations.Add(new InitialConfiguration(new Vector2(0, 0), new Vector2(0, 1))); gainScaleFactors.Add(Vector3.one); }
void setUpExperimentFixedTrackingArea(VirtualPathGenerator.PathSeedChoice pathSeedChoice, System.Type redirector, System.Type resetter) { // Initialize Values this.redirector = redirector; this.resetter = resetter; pathSeeds = new List <VirtualPathGenerator.PathSeed>(); trackingSizes = new List <TrackingSizeShape>(); initialConfigurations = new List <InitialConfiguration>(); gainScaleFactors = new List <Vector3>(); trialsForCurrentExperiment = pathSeedChoice == VirtualPathGenerator.PathSeedChoice.LongWalk ? 1 : MAX_TRIALS; switch (pathSeedChoice) { case VirtualPathGenerator.PathSeedChoice.Office: pathSeeds.Add(VirtualPathGenerator.getPathSeedOfficeBuilding()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationSmall: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationSmall()); break; case VirtualPathGenerator.PathSeedChoice.ExplorationLarge: pathSeeds.Add(VirtualPathGenerator.getPathSeedExplorationLarge()); break; case VirtualPathGenerator.PathSeedChoice.LongWalk: pathSeeds.Add(VirtualPathGenerator.getPathSeedLongCorridor()); break; case VirtualPathGenerator.PathSeedChoice.ZigZag: pathSeeds.Add(VirtualPathGenerator.getPathSeedZigzag()); break; } trackingSizes.Add(new TrackingSizeShape(simulationManager.envManager.trackedSpace.localScale.x, simulationManager.envManager.trackedSpace.localScale.z)); initialConfigurations.Add(new InitialConfiguration(new Vector2(0, 0), new Vector2(0, 1))); gainScaleFactors.Add(Vector3.one); }
void startNextExperiment() { Debug.Log("---------- EXPERIMENT STARTED ----------"); ExperimentSetup setup = experimentSetups[experimentIterator]; printExperimentDescriptor(getExperimentDescriptor(setup)); // Setting Gain Scale Factors //RedirectionManager.SCALE_G_T = setup.gainScaleFactor.x; //RedirectionManager.SCALE_G_R = setup.gainScaleFactor.y; //RedirectionManager.SCALE_G_C = setup.gainScaleFactor.z; // Enabling/Disabling Redirectors simulationManager.redirectionManager.UpdateRedirector(setup.redirector); simulationManager.redirectionManager.UpdateResetter(setup.resetter); // Setup Trail Drawing simulationManager.trailDrawer.enabled = !simulationManager.runAtFullSpeed; // Enable Waypoint simulationManager.motionManager.targetWaypoint.gameObject.SetActive(true); // Resetting User and World Positions and Orientations this.transform.position = Vector3.zero; this.transform.rotation = Quaternion.identity; // ESSENTIAL BUG FOUND: If you set the user first and then the redirection recipient, then the user will be moved, so you have to make sure to do it afterwards! //Debug.Log("Target User Position: " + setup.initialConfiguration.initialPosition.ToString("f4")); simulationManager.redirectionManager.headTransform.position = Utilities.UnFlatten(setup.initialConfiguration.initialPosition, simulationManager.redirectionManager.headTransform.position.y); //Debug.Log("Result User Position: " + redirectionManager.userHeadTransform.transform.position.ToString("f4")); simulationManager.redirectionManager.headTransform.rotation = Quaternion.LookRotation(Utilities.UnFlatten(setup.initialConfiguration.initialForward), Vector3.up); // Set up Tracking Area Dimensions simulationManager.envManager.UpdateTrackedSpaceDimensions(setup.trackingSizeShape.x, setup.trackingSizeShape.z); // Set up Virtual Path float sumOfDistances, sumOfRotations; simulationManager.motionManager.waypoints = VirtualPathGenerator.generatePath(setup.pathSeed, setup.initialConfiguration.initialPosition, setup.initialConfiguration.initialForward, out sumOfDistances, out sumOfRotations); Debug.Log("sumOfDistances: " + sumOfDistances); Debug.Log("sumOfRotations: " + sumOfRotations); if (setup.redirector == typeof(ZigZagRedirector)) { // Create Fake POIs Transform poiRoot = (new GameObject()).transform; poiRoot.name = "ZigZag Redirector Waypoints"; poiRoot.localPosition = Vector3.zero; poiRoot.localRotation = Quaternion.identity; Transform poi0 = (new GameObject()).transform; poi0.localPosition = Vector3.zero; poi0.parent = poiRoot; List <Transform> zigzagRedirectorWaypoints = new List <Transform>(); zigzagRedirectorWaypoints.Add(poi0); foreach (Vector2 waypoint in simulationManager.motionManager.waypoints) { Transform poi = (new GameObject()).transform; poi.localPosition = Utilities.UnFlatten(waypoint); poi.parent = poiRoot; zigzagRedirectorWaypoints.Add(poi); } ((ZigZagRedirector)simulationManager.redirectionManager.redirector).waypoints = zigzagRedirectorWaypoints; } // Set First Waypoint Position and Enable It simulationManager.motionManager.targetWaypoint.position = new Vector3(simulationManager.motionManager.waypoints[0].x, simulationManager.motionManager.targetWaypoint.position.y, simulationManager.motionManager.waypoints[0].y); simulationManager.motionManager.waypointIterator = 0; // POSTPONING THESE FOR SAFETY REASONS! //// Allow Walking //UserController.allowWalking = true; //// Start Logging //redirectionManager.redirectionStatistics.beginLogging(); //redirectionManager.statisticsLogger.beginLogging(); //lastExperimentRealStartTime = Time.realtimeSinceStartup; experimentInProgress = true; }