private void Initialize(EnvironmentInfo environmentInfo, HandymanScoreManager scoreManager, AudioSource objectCollisionAudioSource) { List <GameObject> objectCollisionDestinations = new List <GameObject>(); objectCollisionDestinations.Add(scoreManager.gameObject); objectCollisionDestinations.Add(this.playbackRecorder.gameObject); foreach (GameObject graspable in this.graspables) { CollisionTransferer collisionTransferer = graspable.AddComponent <CollisionTransferer>(); collisionTransferer.Initialize(objectCollisionDestinations, Score.GetObjectCollisionVeloticyThreshold(), 0.1f, objectCollisionAudioSource); } Dictionary <RelocatableObjectInfo, GameObject> graspablesPositionMap = null; //key:GraspablePositionInfo, value:Graspables Dictionary <RelocatableObjectInfo, GameObject> destinationsPositionsMap = null; //key:DestinationPositionInfo, value:DestinationCandidate if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { this.graspingTarget = this.DecideGraspingTarget(); this.destination = this.DecideDestination(); graspablesPositionMap = this.CreateGraspablesPositionMap(); destinationsPositionsMap = this.CreateDestinationsPositionsMap(); } else { this.DeactivateGraspingCandidatesPositions(); this.graspingTarget = (from graspable in this.graspables where graspable.name == environmentInfo.graspingTargetName select graspable).First(); if (this.graspingTarget == null) { throw new Exception("Grasping target not found. name=" + environmentInfo.graspingTargetName); } graspablesPositionMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo graspablePositionInfo in environmentInfo.graspablesPositions) { GameObject graspableObj = (from graspable in this.graspables where graspable.name == graspablePositionInfo.name select graspable).First(); if (graspableObj == null) { throw new Exception("Graspable object not found. name=" + graspablePositionInfo.name); } graspablesPositionMap.Add(graspablePositionInfo, graspableObj); } // Destination object this.destination = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == environmentInfo.destinationName select destinationCandidate).First(); if (this.destination == null) { throw new Exception("Destination not found. name=" + environmentInfo.destinationName); } // Destination candidates position map destinationsPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo destinationPositionInfo in environmentInfo.destinationsPositions) { GameObject destinationObj = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == destinationPositionInfo.name select destinationCandidate).First(); if (destinationObj == null) { throw new Exception("Destination candidate not found. name=" + destinationPositionInfo.name); } destinationsPositionsMap.Add(destinationPositionInfo, destinationObj); } } if (this.destination.tag != TagModerator) { // Add Placement checker to triggers Transform judgeTriggerOn = this.destination.transform.Find(JudgeTriggerNameOn); Transform judgeTriggerIn = this.destination.transform.Find(JudgeTriggerNameIn); if (judgeTriggerOn == null && judgeTriggerIn == null) { throw new Exception("No JudgeTrigger. name=" + this.destination.name); } if (judgeTriggerOn != null && judgeTriggerIn != null) { throw new Exception("Too many JudgeTrigger. name=" + this.destination.name); } if (judgeTriggerOn != null) { PlacementChecker placementChecker = judgeTriggerOn.gameObject.AddComponent <PlacementChecker>(); placementChecker.Initialize(PlacementChecker.JudgeType.On); } if (judgeTriggerIn != null) { PlacementChecker placementChecker = judgeTriggerIn.gameObject.AddComponent <PlacementChecker>(); placementChecker.Initialize(PlacementChecker.JudgeType.In); } } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in graspablesPositionMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in destinationsPositionsMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } this.targetRoom = this.GetTargetRoom(); if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { this.taskMessage = this.CreateTaskMessage(); this.correctedTaskMessage = string.Empty; this.isEnvironmentNameSent = true; } else { this.taskMessage = environmentInfo.taskMessage; this.correctedTaskMessage = environmentInfo.correctedTaskMessage; this.isEnvironmentNameSent = environmentInfo.isEnvironmentNameSent; } if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { SaveEnvironmentInfo(this.taskMessage, this.correctedTaskMessage, this.environmentName, this.isEnvironmentNameSent, this.graspingTarget.name, this.destination.name, graspablesPositionMap, destinationsPositionsMap); } this.rosConnections = SIGVerseUtils.FindObjectsOfInterface <IRosConnection>(); SIGVerseLogger.Info("ROS connection : count=" + this.rosConnections.Length); // Set up the voice (Using External executable file) this.speechProcess = new System.Diagnostics.Process(); this.speechProcess.StartInfo.FileName = Application.dataPath + "/" + SpeechExePath; this.speechProcess.StartInfo.CreateNoWindow = true; this.speechProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; this.isSpeechUsed = System.IO.File.Exists(this.speechProcess.StartInfo.FileName); this.speechInfoQue = new Queue <SpeechInfo>(); SIGVerseLogger.Info("Text-To-Speech: " + Application.dataPath + "/" + SpeechExePath); this.isPlacementSucceeded = null; }
private void Initialize(EnvironmentInfo environmentInfo, HandymanScoreManager scoreManager) { List <GameObject> objectCollisionDestinations = new List <GameObject>(); objectCollisionDestinations.Add(scoreManager.gameObject); objectCollisionDestinations.Add(this.playbackRecorder.gameObject); foreach (GameObject graspable in this.graspables) { CollisionTransferer collisionTransferer = graspable.AddComponent <CollisionTransferer>(); collisionTransferer.Initialize(objectCollisionDestinations, Score.GetObjectCollisionVeloticyThreshold()); } Dictionary <RelocatableObjectInfo, GameObject> graspablesPositionMap = null; //key:GraspablePositionInfo, value:Graspables Dictionary <RelocatableObjectInfo, GameObject> destinationsPositionsMap = null; //key:DestinationPositionInfo, value:DestinationCandidate if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { this.graspingTarget = this.DecideGraspingTarget(); this.destination = this.DecideDestination(); graspablesPositionMap = this.CreateGraspablesPositionMap(); destinationsPositionsMap = this.CreateDestinationsPositionsMap(); } else { this.DeactivateGraspingCandidatesPositions(); this.graspingTarget = (from graspable in this.graspables where graspable.name == environmentInfo.graspingTargetName select graspable).First(); if (this.graspingTarget == null) { throw new Exception("Grasping target not found. name=" + environmentInfo.graspingTargetName); } graspablesPositionMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo graspablePositionInfo in environmentInfo.graspablesPositions) { GameObject graspableObj = (from graspable in this.graspables where graspable.name == graspablePositionInfo.name select graspable).First(); if (graspableObj == null) { throw new Exception("Graspable object not found. name=" + graspablePositionInfo.name); } graspablesPositionMap.Add(graspablePositionInfo, graspableObj); } // Destination object this.destination = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == environmentInfo.destinationName select destinationCandidate).First(); if (this.destination == null) { throw new Exception("Destination not found. name=" + environmentInfo.destinationName); } // Destination candidates position map destinationsPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo destinationPositionInfo in environmentInfo.destinationsPositions) { GameObject destinationObj = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == destinationPositionInfo.name select destinationCandidate).First(); if (destinationObj == null) { throw new Exception("Destination candidate not found. name=" + destinationPositionInfo.name); } destinationsPositionsMap.Add(destinationPositionInfo, destinationObj); } } if (this.destination.tag != TagModerator) { // Add Placement checker to triggers Transform judgeTriggersTransform = this.destination.transform.Find(JudgeTriggersName); if (judgeTriggersTransform == null) { throw new Exception("No Judge Triggers object"); } judgeTriggersTransform.gameObject.AddComponent <PlacementChecker>(); } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in graspablesPositionMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in destinationsPositionsMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } this.targetRoom = this.GetTargetRoom(); if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { this.taskMessage = this.CreateTaskMessage(); this.correctedTaskMessage = string.Empty; this.isEnvironmentNameSent = true; } else { this.taskMessage = environmentInfo.taskMessage; this.correctedTaskMessage = environmentInfo.correctedTaskMessage; this.isEnvironmentNameSent = environmentInfo.isEnvironmentNameSent; } if (HandymanConfig.Instance.configFileInfo.isGraspableObjectsPositionRandom) { SaveEnvironmentInfo(this.taskMessage, this.correctedTaskMessage, this.environmentName, this.isEnvironmentNameSent, this.graspingTarget.name, this.destination.name, graspablesPositionMap, destinationsPositionsMap); } this.rosConnections = SIGVerseUtils.FindObjectsOfInterface <IRosConnection>(); SIGVerseLogger.Info("ROS connection : count=" + this.rosConnections.Length); this.isPlacementSucceeded = null; }
public void Initialize(EnvironmentInfo environmentInfo, CleanupScoreManager scoreManager, AudioSource objectCollisionAudioSource) { List <GameObject> objectCollisionDestinations = new List <GameObject>(); objectCollisionDestinations.Add(scoreManager.gameObject); objectCollisionDestinations.Add(this.playbackRecorder.gameObject); foreach (GameObject graspable in this.graspables) { CollisionTransferer collisionTransferer = graspable.AddComponent <CollisionTransferer>(); collisionTransferer.Initialize(objectCollisionDestinations, Score.GetObjectCollisionVeloticyThreshold(), 0.1f, objectCollisionAudioSource); } this.graspablesPositionsMap = null; //key:GraspablePositionInfo, value:Graspables this.destinationsPositionsMap = null; //key:DestinationPositionInfo, value:DestinationCandidate switch (this.executionMode) { // For the competition. Read generated data. case ExecutionMode.Competition: { this.DeactivateGraspingCandidatesPositions(); // Grasping target object this.graspingTarget = (from graspable in this.graspables where graspable.name == environmentInfo.graspingTargetName select graspable).First(); if (this.graspingTarget == null) { throw new Exception("Grasping target not found. name=" + environmentInfo.graspingTargetName); } // Graspables positions map this.graspablesPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo graspablePositionInfo in environmentInfo.graspablesPositions) { GameObject graspableObj = (from graspable in this.graspables where graspable.name == graspablePositionInfo.name select graspable).First(); if (graspableObj == null) { throw new Exception("Graspable object not found. name=" + graspablePositionInfo.name); } this.graspablesPositionsMap.Add(graspablePositionInfo, graspableObj); } // Destination object this.destination = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == environmentInfo.destinationName select destinationCandidate).First(); if (this.destination == null) { throw new Exception("Destination not found. name=" + environmentInfo.destinationName); } // Add Placement checker to triggers this.AddPlacementChecker(this.destination); // Destination candidates position map this.destinationsPositionsMap = new Dictionary <RelocatableObjectInfo, GameObject>(); foreach (RelocatableObjectInfo destinationPositionInfo in environmentInfo.destinationsPositions) { GameObject destinationObj = (from destinationCandidate in this.destinationCandidates where destinationCandidate.name == destinationPositionInfo.name select destinationCandidate).First(); if (destinationObj == null) { throw new Exception("Destination candidate not found. name=" + destinationPositionInfo.name); } this.destinationsPositionsMap.Add(destinationPositionInfo, destinationObj); } break; } // For data generation. case ExecutionMode.DataGeneration: { // this.graspingTarget = CleanupModeratorTools.GetGraspingTargetObject(); // this.cleanupDestination = CleanupModeratorTools.GetDestinationObject(); this.graspablesPositionsMap = this.CreateGraspablesPositionsMap(); this.destinationsPositionsMap = this.CreateDestinationsPositionsMap(); break; } default: { throw new Exception("Illegal Execution mode. mode=" + CleanupConfig.Instance.configFileInfo.executionMode); } } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in this.graspablesPositionsMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } foreach (KeyValuePair <RelocatableObjectInfo, GameObject> pair in this.destinationsPositionsMap) { pair.Value.transform.position = pair.Key.position; pair.Value.transform.eulerAngles = pair.Key.eulerAngles; // Debug.Log(pair.Key.name + " : " + pair.Value.name); } this.rosConnections = SIGVerseUtils.FindObjectsOfInterface <IRosConnection>(); SIGVerseLogger.Info("ROS connection : count=" + this.rosConnections.Length); // Set up the voice (Using External executable file) this.speechProcess = new System.Diagnostics.Process(); this.speechProcess.StartInfo.FileName = Application.dataPath + "/" + SpeechExePath; this.speechProcess.StartInfo.CreateNoWindow = true; this.speechProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; this.isSpeechUsed = System.IO.File.Exists(this.speechProcess.StartInfo.FileName); this.speechInfoQue = new Queue <SpeechInfo>(); SIGVerseLogger.Info("Text-To-Speech: " + Application.dataPath + "/" + SpeechExePath); this.hasPressedButtonToStartRecordingAvatarMotion = false; this.hasPressedButtonToStopRecordingAvatarMotion = false; this.isPlacementSucceeded = null; this.ResetPointingStatus(); }