private void PostProcess() { SIGVerseLogger.Info("Task end"); if (HandymanConfig.Instance.numberOfTrials == HandymanConfig.Instance.configFileInfo.maxNumberOfTrials) { this.SendRosMessage(MsgMissionComplete, string.Empty); StartCoroutine(this.tool.CloseRosConnections()); StartCoroutine(this.DisplayEndMessage()); this.isAllTaskFinished = true; } else { this.tool.AddSpeechQueModerator("Let's go to the next session"); StartCoroutine(this.tool.ClearRosConnections()); this.step = ModeratorStep.WaitForNextTask; } }
//----------------------------- private void InitializeMainPanel() { this.panelMainController.SetTeamNameText("Team: " + HumanNaviConfig.Instance.configInfo.teamName); if (this.isPracticeMode) { HumanNaviConfig.Instance.numberOfTrials = 1; } else { HumanNaviConfig.Instance.InclementNumberOfTrials(HumanNaviConfig.Instance.configInfo.playbackType); } this.numberOfSession = HumanNaviConfig.Instance.numberOfTrials; //this.panelMainController.SetTrialNumberText(HumanNaviConfig.Instance.numberOfTrials); this.panelMainController.SetTrialNumberText(this.numberOfSession); SIGVerseLogger.Info("##### " + this.panelMainController.GetTrialNumberText() + " #####"); this.panelMainController.SetTaskMessageText(""); this.scoreManager.ResetTimeLeftText(); }
public static System.Net.Sockets.TcpClient GetConnection(string rosBridgeIP, int sigverseBridgePort) { if (!canConnect) { throw new Exception("Cannot connect HSR. IP=" + rosBridgeIP + ", Port=" + sigverseBridgePort); } System.Net.Sockets.TcpClient tcpClient = new System.Net.Sockets.TcpClient(); IAsyncResult connectResult = tcpClient.BeginConnect(rosBridgeIP, sigverseBridgePort, null, null); bool isConnected = connectResult.AsyncWaitHandle.WaitOne(TimeSpan.FromMilliseconds(SigverseRosbridgeConnectionTimeOut)); if (!isConnected) { canConnect = false; SIGVerseLogger.Error("Failed to connect. IP=" + rosBridgeIP + ", Port=" + sigverseBridgePort); throw new Exception("Failed to connect. IP=" + rosBridgeIP + ", Port=" + sigverseBridgePort); } return(tcpClient); }
private void Awake() { try { // For practice mode if (HumanNaviConfig.Instance.configInfo.executionMode == (int)ExecutionMode.Practice) { this.GetComponent <HumanNaviPubTaskInfo>().enabled = false; this.GetComponent <HumanNaviPubMessage>().enabled = false; this.GetComponent <HumanNaviSubMessage>().enabled = false; this.GetComponent <HumanNaviPubAvatarStatus>().enabled = false; this.GetComponent <HumanNaviPubObjectStatus>().enabled = false; robot.transform.Find("RosBridgeScripts").gameObject.SetActive(false); robot.GetComponentInChildren <HumanNaviSubGuidanceMessage>().enabled = false; foreach (Camera camera in robot.transform.GetComponentsInChildren <Camera>()) { camera.gameObject.SetActive(false); } } this.robot.SetActive(false); this.robotBaseFootprint = SIGVerseUtils.FindTransformFromChild(this.robot.transform, "base_footprint"); this.InitializeEnvironments(); this.tts = this.robot.transform.Find("CompetitionScripts").GetComponent <SAPIVoiceSynthesisExternal>(); this.InitializeTaskInfo(); } catch (Exception e) { SIGVerseLogger.Error(e.Message); this.ApplicationQuitAfter1sec(); } }
void FixedUpdate() { try { // Receive the time gap between Unity and ROS if (this.networkStream.DataAvailable) { byte[] byteArray = new byte[256]; int numberOfBytesRead = 0; if (networkStream.CanRead) { numberOfBytesRead = networkStream.Read(byteArray, 0, byteArray.Length); } string message = System.Text.Encoding.UTF8.GetString(byteArray, 0, numberOfBytesRead); string[] messageArray = message.Split(','); if (messageArray.Length == 3) { SIGVerseLogger.Info("Time gap sec=" + messageArray[1] + ", msec=" + messageArray[2]); SIGVerse.RosBridge.std_msgs.Header.SetTimeGap(Int32.Parse(messageArray[1]), Int32.Parse(messageArray[2])); } else { SIGVerseLogger.Error("Illegal message. Time gap message=" + message); } } } catch (ObjectDisposedException exception) { SIGVerseLogger.Warn(exception.Message); } }
// Use this for initialization void Awake() { this.process = new System.Diagnostics.Process(); this.process.StartInfo.FileName = Application.dataPath + this.path; //this.process.EnableRaisingEvents = true; //this.process.Exited += new System.EventHandler(ProcessExit); //this.process.StartInfo.RedirectStandardOutput = true; //this.process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(OutputHandler); //this.process.StartInfo.RedirectStandardError = true; //this.process.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(ErrorOutputHanlder); this.process.StartInfo.CreateNoWindow = true; this.process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; SIGVerseLogger.Info("Text-To-Speech: " + this.process.StartInfo.FileName); this.ResetNotificationDestinations(); this.isSpeaking = false; }
void Awake() { try { if (HandymanConfig.Instance.configFileInfo.playbackType == WorldPlaybackCommon.PlaybackTypePlay) { return; } this.tool = new HandymanModeratorTool(this); this.stepTimer = new StepTimer(); this.mainMenu = GameObject.FindGameObjectWithTag("MainMenu"); this.mainPanelController = mainMenu.GetComponent <PanelMainController>(); } catch (Exception exception) { Debug.LogError(exception); SIGVerseLogger.Error(exception.Message); SIGVerseLogger.Error(exception.StackTrace); this.ApplicationQuitAfter1sec(); } }
public void OnReceiveRosMessage(RosBridge.human_navigation.HumanNaviMsg humanNaviMsg) { if (this.receivedMessageMap.ContainsKey(humanNaviMsg.message)) { this.receivedMessageMap[humanNaviMsg.message] = true; if (humanNaviMsg.message == MsgGiveUp) { this.OnGiveUp(); } else if (humanNaviMsg.message == MsgGetAvatarPose) { RosBridge.human_navigation.HumanNaviAvatarPose avatarPose = new RosBridge.human_navigation.HumanNaviAvatarPose(); avatarPose.head.position = ConvertCoorinateSystemUnityToROS_Position(this.head.transform.position); avatarPose.head.orientation = ConvertCoorinateSystemUnityToROS_Rotation(this.head.transform.rotation); avatarPose.left_hand.position = ConvertCoorinateSystemUnityToROS_Position(this.LeftHand.transform.position); avatarPose.left_hand.orientation = ConvertCoorinateSystemUnityToROS_Rotation(this.LeftHand.transform.rotation); avatarPose.right_hand.position = ConvertCoorinateSystemUnityToROS_Position(this.rightHand.transform.position); avatarPose.right_hand.orientation = ConvertCoorinateSystemUnityToROS_Rotation(this.rightHand.transform.rotation); this.SendRosAvatarPoseMessage(avatarPose); } else if (humanNaviMsg.message == MsgConfirmSpeechState) { if (this.isDuringTrial) { this.SendRosHumanNaviMessage(MsgSpeechState, this.sessionManager.GetSeechRunStateMsgString()); } } } else { SIGVerseLogger.Warn("Received Illegal message : " + humanNaviMsg.message); } }
private void SetDestinationToHumanNaviTaskInfo() { List <GameObject> destinations = GameObject.FindGameObjectsWithTag("Destination").ToList <GameObject>(); if (destinations.Count == 0) { throw new Exception("Destination candidate is not found."); } foreach (GameObject destination in destinations) { if (destination.name == this.currentTaskInfo.destination) { Vector3 conterOfCollider = destination.GetComponent <BoxCollider>().center; taskInfoForRobot.destination = this.ConvertCoorinateSystemUnityToROS_Position(destination.transform.position + conterOfCollider); } } SIGVerseLogger.Info("Destination : " + taskInfoForRobot.destination); //if (taskInfoForRobot.destination == null) //{ // throw new Exception("Destination is not found."); //} }
//----------------------------- /// <summary> /// Human Avatar -> Robot /// </summary> public override void OnReceiveChatMessage(string senderName, string message) { #if SIGVERSE_PUN if (this.photonView.Owner != PhotonNetwork.LocalPlayer) { return; } string senderNickName = senderName.Split('#')[0]; string speaker = (senderNickName == PhotonNetwork.NickName) ? "You" : senderNickName; // Display the message PanelNoticeStatus noticeStatus = new PanelNoticeStatus(speaker, message, PanelNoticeStatus.Green); ExecuteEvents.Execute <IPanelNoticeHandler> ( target: this.mainMenu, eventData: null, functor: (reciever, eventData) => reciever.OnPanelNoticeChange(noticeStatus) ); // Forward the message to ROS if (senderNickName != PhotonNetwork.NickName) { ExecuteEvents.Execute <SIGVerse.RosBridge.IRosSendingStringMsgHandler> ( target: this.rosBridgeScripts, eventData: null, functor: (reciever, eventData) => reciever.OnSendRosStringMsg(message) ); } SIGVerseLogger.Info("Robot: Received a message. sender=" + senderName + ", message=" + message); #endif }
protected void Awake() { this.collisionEffect = (GameObject)Resources.Load(CompetitionUtils.CollisionEffectPath); this.exclusionColliderList = new List <Collider>(); foreach (string exclusionColliderTag in exclusionColliderTags) { List <GameObject> exclusionColliderObjects = GameObject.FindGameObjectsWithTag(exclusionColliderTag).ToList <GameObject>(); foreach (GameObject exclusionColliderObject in exclusionColliderObjects) { List <Collider> colliders = exclusionColliderObject.GetComponentsInChildren <Collider>().ToList <Collider>(); this.exclusionColliderList.AddRange(colliders); } } this.colliders = this.GetComponentsInChildren <Collider>(); this.colliderVelocities = new float[this.colliders.Length]; this.prePoss = new Vector3[this.colliders.Length]; SIGVerseLogger.Info("HSR collider count=" + this.colliders.Length); }
private void StartRecording() { SIGVerseLogger.Info("Recorder : Initialise"); this.DisableSettings(); DateTime dateTime = DateTime.Now; this.targetTransformInstances = new List <Transform>(); List <string> linkPathList = new List <string>(); // It is for only duplication check // Make header line this.savedHeaderStrings = string.Empty; this.savedHeaderStrings += "0.0," + PlaybackerCommon.TypeDef; // Elapsed time is dummy. // Create targets transform list foreach (GameObject targetObj in targetObjects) { Transform[] transforms = targetObj.transform.GetComponentsInChildren <Transform>(); foreach (Transform transform in transforms) { // Save Transform instance list this.targetTransformInstances.Add(transform); string linkPath = SIGVerseUtils.GetHierarchyPath(transform); // Make a header line this.savedHeaderStrings += "\t" + linkPath; // Duplication check if (linkPathList.Contains(linkPath)) { SIGVerseLogger.Error("Objects in the same path exist. path=" + linkPath); throw new Exception("Objects in the same path exist."); } linkPathList.Add(linkPath); } } if (this.modeType == ModeType.TextRecorder) { this.InitializeText(); } else { #if SIGVERSE_MYSQL this.InitializeDatabase(); #endif } this.savedMotionStrings = new List <string>(); // Change Buttons this.recordButtonText.text = PlaybackerCommon.ButtonTextStop; // Reset elapsed time this.elapsedTime = 0.0f; this.previousRecordedTime = 0.0f; SIGVerseLogger.Info("Recorder : Recording start."); this.statusText.text = StatusTextRecording; this.isRecording = true; }
void Awake() { // Read Config file this.configFilePath = Application.dataPath + HandymanConfig.FolderPath + HandymanConfig.ConfigFileName; this.configFileInfo = new HandymanConfigFileInfo(); if (File.Exists(configFilePath)) { // File open StreamReader streamReader = new StreamReader(configFilePath, Encoding.UTF8); this.configFileInfo = JsonUtility.FromJson <HandymanConfigFileInfo>(streamReader.ReadToEnd()); streamReader.Close(); } else { #if UNITY_EDITOR SIGVerseLogger.Warn("Handyman config file does not exists."); this.configFileInfo.teamName = "XXXX"; this.configFileInfo.sessionTimeLimit = 600; this.configFileInfo.maxNumberOfTrials = 15; this.configFileInfo.isScoreFileRead = false; this.configFileInfo.isGraspableObjectsPositionRandom = true; this.configFileInfo.isAlwaysGoNext = false; this.configFileInfo.playbackType = HandymanPlaybackCommon.PlaybackTypeRecord; this.configFileInfo.bgmVolume = 0.01f; this.configFileInfo.reduceLoadInDataGen = false; this.SaveConfig(); #else SIGVerseLogger.Error("Handyman config file does not exists."); Application.Quit(); #endif } // Initialize common parameter this.scoreFilePath = Application.dataPath + HandymanConfig.FolderPath + HandymanConfig.ScoreFileName; this.scores = new List <int>(); if (this.configFileInfo.isScoreFileRead) { if (!System.IO.File.Exists(this.scoreFilePath)) { SIGVerseLogger.Error("Score file does not exists."); Application.Quit(); } // File open StreamReader streamReader = new StreamReader(scoreFilePath, Encoding.UTF8); string line; while ((line = streamReader.ReadLine()) != null) { string scoreStr = line.Trim(); if (scoreStr == string.Empty) { continue; } this.scores.Add(Int32.Parse(scoreStr)); } streamReader.Close(); this.numberOfTrials = this.scores.Count; if (this.numberOfTrials >= this.configFileInfo.maxNumberOfTrials) { SIGVerseLogger.Error("this.numberOfTrials >= this.configFileInfo.maxNumberOfTrials"); Application.Quit(); } } else { this.numberOfTrials = 0; } }
public override bool ReadEvents(string[] headerArray, string dataStr) { // Transform data if (headerArray[1] == WorldPlaybackCommon.DataType1Transform) { string[] dataArray = dataStr.Split('\t'); // Definition if (headerArray[2] == WorldPlaybackCommon.DataType2TransformDef) { this.transformOrder.Clear(); SIGVerseLogger.Info("Playback player : transform data num=" + dataArray.Length); foreach (string transformPath in dataArray) { if (!this.targetTransformPathMap.ContainsKey(transformPath)) { SIGVerseLogger.Error("Couldn't find the object that path is " + transformPath); } this.transformOrder.Add(this.targetTransformPathMap[transformPath]); } } // Value else if (headerArray[2] == WorldPlaybackCommon.DataType2TransformVal) { if (this.transformOrder.Count == 0) { return(false); } PlaybackTransformEventList playbackTransformEventList = new PlaybackTransformEventList(); playbackTransformEventList.ElapsedTime = float.Parse(headerArray[0]); for (int i = 0; i < dataArray.Length; i++) { string[] transformValues = dataArray[i].Split(','); PlaybackTransformEvent transformEvent = new PlaybackTransformEvent(); transformEvent.TargetTransform = this.transformOrder[i]; transformEvent.Position = new Vector3(float.Parse(transformValues[0]), float.Parse(transformValues[1]), float.Parse(transformValues[2])); transformEvent.Rotation = new Vector3(float.Parse(transformValues[3]), float.Parse(transformValues[4]), float.Parse(transformValues[5])); if (transformValues.Length == 6) { transformEvent.Scale = Vector3.one; } else if (transformValues.Length == 9) { transformEvent.Scale = new Vector3(float.Parse(transformValues[6]), float.Parse(transformValues[7]), float.Parse(transformValues[8])); } playbackTransformEventList.EventList.Add(transformEvent); } this.eventLists.Add(playbackTransformEventList); } return(true); } return(false); }
private IEnumerator StartPlaying() { SIGVerseLogger.Info("Player : Initialise"); if (!File.Exists(inputFilePathInputField.text)) { throw new Exception("Input File NOT found. File path=" + inputFilePathInputField.text); } this.DisableSettings(); this.statusText.text = StatusTextReading; this.isReading = true; this.playingTransformList = new List <UpdatingTransformList>(); if (this.modeType == ModeType.TextPlayer) { Thread threadWriteMotions = new Thread(new ThreadStart(this.ReadMotionsFromFile)); threadWriteMotions.Start(); } else { #if SIGVERSE_MYSQL Thread threadWriteMotions = new Thread(new ThreadStart(this.SelectMotionsFromMySQL)); threadWriteMotions.Start(); #endif } while (this.isReading) { yield return(new WaitForSeconds(0.1f)); } // Change Buttons this.playButtonText.text = PlaybackerCommon.ButtonTextStop; this.animatorEnableMap.Clear(); this.rigidbodyIsKinematicMap.Clear(); // Disable Animators and Rigidbodies foreach (GameObject targetObj in targetObjects) { // Disable animators Animator[] animators = targetObj.transform.GetComponentsInChildren <Animator>(true); foreach (Animator animator in animators) { this.animatorEnableMap.Add(animator, animator.enabled); animator.enabled = false; } // Disable rigidbodies Rigidbody[] rigidbodies = targetObj.transform.GetComponentsInChildren <Rigidbody>(true); foreach (Rigidbody rigidbody in rigidbodies) { this.rigidbodyIsKinematicMap.Add(rigidbody, rigidbody.isKinematic); rigidbody.isKinematic = true; rigidbody.velocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; } } SIGVerseLogger.Info("Player : Playing start."); // Reset elapsed time this.elapsedTime = 0.0f; this.playingTransformIndex = 0; this.statusText.text = StatusTextPlaying; this.isPlaying = true; }
private bool SpeakMessage(string message, string displayType, string sourceLanguage, string targetLanguage) { if (this.isSpeaking) { SIGVerseLogger.Info("Text-To-Speech: isSpeaking"); try { if (/*isTaskFinished &&*/ !this.speechProcess.HasExited) { this.speechProcess.Kill(); } } catch (Exception) { SIGVerseLogger.Warn("Couldn't terminate the speech process, but do nothing."); // Do nothing even if an error occurs } } // Translation if ((sourceLanguage == string.Empty && targetLanguage != string.Empty) || (sourceLanguage != string.Empty && targetLanguage == string.Empty)) { SIGVerseLogger.Error("Invalid language type. Source Language=" + sourceLanguage + ", Target Language=" + targetLanguage); return(false); } if (sourceLanguage != string.Empty && targetLanguage != string.Empty) { if (message.Length > maxCharactersForSourceLang) { message.Substring(0, maxCharactersForSourceLang); SIGVerseLogger.Info("Length of guidance message(source lang) is over " + this.maxCharactersForSourceLang.ToString() + " charcters."); } if (this.translationClient != null) { message = this.translationClient.TranslateText(message, targetLanguage, sourceLanguage).TranslatedText; } else { SIGVerseLogger.Warn("There is no environment for translation."); } } string truncatedMessage; if (message.Length > maxCharactersForTargetLang) { truncatedMessage = message.Substring(0, maxCharactersForTargetLang); SIGVerseLogger.Info("Length of guidance message(target lang) is over " + this.maxCharactersForTargetLang.ToString() + " charcters."); } else { truncatedMessage = message; } // speak string settings = "Language=" + HumanNaviConfig.Instance.ttsLanguageId + "; Gender=" + this.gender; this.speechProcess.StartInfo.Arguments = "\"" + truncatedMessage + "\" \"" + settings + "\""; SIGVerseLogger.Info("Speech Message=" + this.speechProcess.StartInfo.Arguments); foreach (GameObject destination in this.notificationDestinations) { // For recording ExecuteEvents.Execute <ISpeakGuidanceMessageHandler> ( target: destination, eventData: null, functor: (reciever, eventData) => reciever.OnSpeakGuidanceMessage(new GuidanceMessageStatus(message, displayType, sourceLanguage, targetLanguage)) ); // For send speech result (ROS message) ExecuteEvents.Execute <ISendSpeechResultHandler> ( target: destination, eventData: null, functor: (reciever, eventData) => reciever.OnSendSpeechResult(SpeechResultStarted) ); } this.speechProcess.Start(); this.isSpeaking = true; return(true); }
//---------------------------- GUI related codes are below --------------------------------------------- void OnGUI() { // Update a text of status if (this.errorMsg != string.Empty) { this.statusText.text = this.errorMsg; this.SetTextColorAlpha(this.statusText, 1.0f); return; } switch (this.step) { case Step.Waiting: { if (this.isStepChanged) { Debug.Log("Waiting"); if (this.isInitialized) { this.trialNoInputField.interactable = true; this.readFileButton.interactable = true; this.timeSlider.interactable = true; this.playButton.interactable = true; this.speedDropdown.interactable = true; this.repeatToggle.interactable = true; this.startTimeInputField.interactable = true; this.endTimeInputField.interactable = true; } if (this.isFileRead) { this.SetTextColorAlpha(this.statusText, 0.0f); this.totalTimeText.text = this.elapsedTime.ToString(ElapsedTimeFormat); this.totalTimeText.text = Math.Ceiling(this.GetTotalTime()).ToString(TotalTimeFormat); this.totalTimeInt = int.Parse(this.totalTimeText.text); this.ResetTimeSlider(); this.SetStartTime(0); this.SetEndTime(this.totalTimeInt); this.UpdateDataByLatest(0); this.isFileRead = false; } this.SetTextColorAlpha(this.statusText, 0.0f); this.playButton.image.sprite = this.playSprite; this.isStepChanged = false; } this.UpdateTimeDisplay(); break; } case Step.Initializing: { if (this.isStepChanged) { SIGVerseLogger.Info("Initializing"); this.statusText.text = "Reading..."; this.isStepChanged = false; } this.SetTextColorAlpha(this.statusText, Mathf.Sin(5.0f * Time.time) * 0.5f + 0.5f); break; } case Step.Playing: { if (this.isStepChanged) { SIGVerseLogger.Info("Playing"); this.statusText.text = "Playing..."; this.playButton.image.sprite = this.pauseSprite; this.trialNoInputField.interactable = false; this.readFileButton.interactable = false; this.timeSlider.interactable = false; this.speedDropdown.interactable = false; this.repeatToggle.interactable = false; this.startTimeInputField.interactable = false; this.endTimeInputField.interactable = false; this.isStepChanged = false; } this.SetTextColorAlpha(this.statusText, Mathf.Sin(5.0f * Time.time) * 0.5f + 0.5f); this.UpdateTimeDisplay(); this.timeSlider.value = Mathf.Clamp((this.elapsedTime - this.startTime) / (this.endTime - this.startTime), 0.0f, 1.0f); break; } } }
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; }
// Update is called once per frame void Update() { try { if (this.isAllTaskFinished) { return; } if (this.interruptedReason != string.Empty && this.step != ModeratorStep.WaitForNextTask) { SIGVerseLogger.Info("Failed '" + this.interruptedReason + "'"); this.SendPanelNotice("Failed\n" + interruptedReason.Replace('_', ' '), 100, PanelNoticeStatus.Red); this.GoToNextTaskTaskFailed(this.interruptedReason); } switch (this.step) { case ModeratorStep.Initialize: { SIGVerseLogger.Info("Initialize"); this.PreProcess(); this.step++; break; } case ModeratorStep.WaitForStart: { if (this.stepTimer.IsTimePassed((int)this.step, 3000)) { if (this.tool.IsPlaybackInitialized() && this.tool.IsConnectedToRos()) { this.step++; } } break; } case ModeratorStep.TaskStart: { SIGVerseLogger.Info("Task start!"); this.scoreManager.TaskStart(); this.tool.StartPlayback(); this.tool.StartAvatarMotionPlayback(); this.step++; break; } case ModeratorStep.WaitForIamReady: { if (this.receivedMessageMap[MsgIamReady]) { this.step++; break; } if (this.stepTimer.IsTimePassed((int)this.step, SendingAreYouReadyInterval)) { this.SendRosMessage(MsgAreYouReady, string.Empty); this.SendRosMessage(MsgEnvironment, this.tool.GetEnvironmentName()); } break; } case ModeratorStep.SendInstruction: { // Wait for sending tf if (this.stepTimer.IsTimePassed((int)this.step, 1000)) { this.SendRosMessage(MsgInstruction, this.taskMessage); this.step++; SIGVerseLogger.Info("Waiting for '" + MsgRoomReached + "'"); } break; } case ModeratorStep.WaitForRoomReached: { if (this.receivedMessageMap[MsgRoomReached]) { // Check for robot position bool isSucceeded = this.tool.IsRoomReachedSucceeded(); if (HandymanConfig.Instance.configFileInfo.isAlwaysGoNext) { SIGVerseLogger.Warn("!!! DEBUG MODE !!! : always go next step : result=" + isSucceeded); isSucceeded = true; } if (isSucceeded) { SIGVerseLogger.Info("Succeeded '" + MsgRoomReached + "'"); this.SendPanelNotice("Good", 150, PanelNoticeStatus.Green); this.scoreManager.AddScore(Score.Type.RoomReachingSuccess); } else { SIGVerseLogger.Info("Failed '" + MsgRoomReached + "'"); this.SendPanelNotice("Failed\n" + MsgRoomReached.Replace('_', ' '), 100, PanelNoticeStatus.Red); this.scoreManager.AddScore(Score.Type.RoomReachingFailure); this.GoToNextTaskTaskFailed(MsgRoomReached); return; } this.step++; if (this.shouldWaitDoesNotExist) { SIGVerseLogger.Info("Waiting for '" + MsgDoesNotExist + "'"); } else { SIGVerseLogger.Info("Waiting for '" + MsgObjectGrasped + "'"); } } break; } case ModeratorStep.WaitForDoesNotExist: { if (!this.shouldWaitDoesNotExist) { this.step++; break; } if (this.receivedMessageMap[MsgDoesNotExist]) { string detail = "Send a new message"; SIGVerseLogger.Info("Succeeded '" + MsgDoesNotExist + "'"); this.SendPanelNotice("Good\n" + detail, 95, PanelNoticeStatus.Green); this.scoreManager.AddScore(Score.Type.TargetConfirmationSuccess); this.SendRosMessage(MsgCorrectedInstruction, this.correctedTaskMessage); this.mainPanelController.SetTaskMessageText(this.correctedTaskMessage); this.step++; SIGVerseLogger.Info("Waiting for '" + MsgObjectGrasped + "'"); break; } if (this.receivedMessageMap[MsgObjectGrasped]) { string detail = "Target doesn't exist"; SIGVerseLogger.Info("Failed '" + MsgDoesNotExist + "'"); this.SendPanelNotice("Failed\n" + detail, 90, PanelNoticeStatus.Red); this.scoreManager.AddScore(Score.Type.TargetConfirmationFailure); this.GoToNextTaskTaskFailed(MsgDoesNotExist); return; } break; } case ModeratorStep.WaitForObjectGrasped: { if (!this.shouldWaitDoesNotExist) { if (this.receivedMessageMap[MsgDoesNotExist]) { string detail = "The target exist"; SIGVerseLogger.Info("Failed '" + MsgObjectGrasped + "'"); this.SendPanelNotice("Failed\n" + detail, 100, PanelNoticeStatus.Red); this.scoreManager.AddScore(Score.Type.GraspingFailure); this.GoToNextTaskTaskFailed(detail); return; } } if (this.receivedMessageMap[MsgObjectGrasped]) { // Check for grasping bool isSucceeded = this.tool.IsObjectGraspedSucceeded(); if (HandymanConfig.Instance.configFileInfo.isAlwaysGoNext) { SIGVerseLogger.Warn("!!! DEBUG MODE !!! : always go next step : result=" + isSucceeded); isSucceeded = true; } if (isSucceeded) { SIGVerseLogger.Info("Succeeded '" + MsgObjectGrasped + "'"); this.SendPanelNotice("Good", 150, PanelNoticeStatus.Green); this.scoreManager.AddScore(Score.Type.GraspingSuccess); } else { SIGVerseLogger.Info("Failed '" + MsgObjectGrasped + "'"); this.SendPanelNotice("Failed\n" + MsgObjectGrasped.Replace('_', ' '), 100, PanelNoticeStatus.Red); this.scoreManager.AddScore(Score.Type.GraspingFailure); this.GoToNextTaskTaskFailed(MsgObjectGrasped); return; } this.step++; SIGVerseLogger.Info("Waiting for '" + MsgTaskFinished + "'"); break; } break; } case ModeratorStep.WaitForTaskFinished: { if (this.receivedMessageMap[MsgTaskFinished]) { StartCoroutine(this.tool.UpdatePlacementStatus(this)); this.step++; } break; } case ModeratorStep.Judgement: { if (this.tool.IsPlacementCheckFinished()) { bool isSucceeded = this.tool.IsPlacementSucceeded(); if (HandymanConfig.Instance.configFileInfo.isAlwaysGoNext) { SIGVerseLogger.Warn("!!! DEBUG MODE !!! : always go next step : result=" + isSucceeded); isSucceeded = true; } if (isSucceeded) { SIGVerseLogger.Info("Succeeded '" + MsgTaskFinished + "'"); this.SendPanelNotice("Succeeded!", 150, PanelNoticeStatus.Green); this.scoreManager.AddScore(Score.Type.PlacementSuccess); this.GoToNextTaskTaskSucceeded(); } else { SIGVerseLogger.Info("Failed '" + MsgTaskFinished + "'"); this.SendPanelNotice("Failed\n" + MsgTaskFinished.Replace('_', ' '), 100, PanelNoticeStatus.Red); this.scoreManager.AddScore(Score.Type.PlacementFailure); this.GoToNextTaskTaskFailed(MsgTaskFinished); } } break; } case ModeratorStep.WaitForNextTask: { if (this.stepTimer.IsTimePassed((int)this.step, 5000)) { if (!this.tool.IsPlaybackFinished()) { break; } SceneManager.LoadScene(SceneManager.GetActiveScene().name); } break; } } } catch (Exception exception) { Debug.LogError(exception); SIGVerseLogger.Error(exception.Message); SIGVerseLogger.Error(exception.StackTrace); this.ApplicationQuitAfter1sec(); } }
protected override void SubscribeMessageCallback(RosBridge.human_navigation.HumanNaviMsg humanNaviMsg) { SIGVerseLogger.Info("Received message :" + humanNaviMsg.message); this.punRpcManager.ForwardSubRosMessage(humanNaviMsg); }
// Update is called once per frame void Update() { try { if (this.isAllTaskFinished) { return; } switch (this.step) { case PlacingStep.Initialize: //Configure everything just the first time if (tool.IsConnectedToRos()) { this.step++; } break; case PlacingStep.WaitForIamReady: //Send Are you ready? message and wait for answer this.SendRosMessage(MsgAreYouReady, string.Empty); break; case PlacingStep.SetUpScene: //Cycle goes back here to start new scene this.scorePlacing = ""; if (this.fakeCount < numOfScenes) { //Scene configuration and showing this.setUpScene(); this.fakeCount++; this.step++; sceneNumber++; this.scoreValText.text = "XXX"; this.sceneValText.text = sceneNumber.ToString(); this.strategy = UnityEngine.Random.Range(1, numStrategies + 1); } else { //When finishing the number of scenes configured goes to last step this.step = PlacingStep.Stoping; } break; case PlacingStep.WaitForImagesCaptured: string cameraHeigth; if (PlacingTools.typeLower) { cameraHeigth = "L-"; } else { cameraHeigth = "U-"; } //Send Setting completed message and wait for Images captured message from robot //Sending camera height for metadata file cameraHeigth += tool.getFurnitureID(); //Sending strategy number from 1 to max strategies number cameraHeigth += "-" + this.strategy; this.SendRosMessage(MsgSettingCompleted, cameraHeigth); break; //While robot is placing object on table, unity starts scoring manager for scene case PlacingStep.ExcecutePlacing: tool.startPlacing(); break; //When receiving Object Placed message calculates score case PlacingStep.CalculateScore: this.scorePlacing = tool.finishPlacing(); this.step++; break; //Send score and wait for Score Saved message, finally goes back to WaitForIamReady case PlacingStep.WaitForNextTask: string sc = this.scorePlacing; this.scoreValText.text = this.scorePlacing.Split(':')[0]; sc += "-" + tool.getTargetID(); this.SendRosMessage(MsgScore, sc); tool.resetRobot(); break; //When finished all scenes send Stop Process message case PlacingStep.Stoping: this.scenes.moveHouse(); this.scoreValText.text = "XXX"; this.SendRosMessage(MsgStopProcess, string.Empty); this.isAllTaskFinished = true; Start(); break; case PlacingStep.Final: this.sceneValText.text = "FINISHED"; this.SendRosMessage(MsgStopProcess, string.Empty); this.isAllTaskFinished = true; break; } } catch (Exception exception) { SIGVerseLogger.Error(exception.Message); SIGVerseLogger.Error(exception.StackTrace); this.ApplicationQuitAfter1sec(); } }
private void GetGameObjects(GameObject avatarMotionPlayback, GameObject worldPlayback) { this.robot = GameObject.FindGameObjectWithTag(TagRobot); this.hsrBaseFootPrint = SIGVerseUtils.FindTransformFromChild(this.robot.transform, HSRCommon.BaseFootPrintName); this.hsrGraspingDetector = this.robot.GetComponentInChildren <HSRGraspingDetector>(); GameObject moderator = GameObject.FindGameObjectWithTag(TagModerator); // Get grasping candidates this.graspingCandidates = GameObject.FindGameObjectsWithTag(TagGraspingCandidates).ToList <GameObject>(); if (this.graspingCandidates.Count == 0) { throw new Exception("Count of GraspingCandidates is zero."); } // List<GameObject> dummyGraspingCandidates = GameObject.FindGameObjectsWithTag(TagDummyGraspingCandidates).ToList<GameObject>(); this.graspables = new List <GameObject>(); this.graspables.AddRange(this.graspingCandidates); // this.graspables.AddRange(dummyGraspingCandidates); // Check the name conflict of graspables. if (this.graspables.Count != (from graspable in this.graspables select graspable.name).Distinct().Count()) { throw new Exception("There is the name conflict of graspable objects."); } SIGVerseLogger.Info("Count of Graspables = " + this.graspables.Count); this.bedRoomArea = GameObject.Find(this.environmentName + "/RoomArea/" + AreaNameBedRoom); this.kitchenArea = GameObject.Find(this.environmentName + "/RoomArea/" + AreaNameKitchen); this.livingArea = GameObject.Find(this.environmentName + "/RoomArea/" + AreaNameLiving); this.lobbyArea = GameObject.Find(this.environmentName + "/RoomArea/" + AreaNameLobby); // Get grasping candidates positions this.graspingCandidatesPositions = GameObject.FindGameObjectsWithTag(TagGraspingCandidatesPosition).ToList <GameObject>(); if (this.graspables.Count > this.graspingCandidatesPositions.Count) { throw new Exception("graspables.Count > graspingCandidatesPositions.Count."); } else { SIGVerseLogger.Info("Count of GraspingCandidatesPosition = " + this.graspingCandidatesPositions.Count); } this.destinationCandidates = GameObject.FindGameObjectsWithTag(TagDestinationCandidates).ToList <GameObject>(); this.destinationCandidates.Add(moderator); // Treat moderator as a destination candidate if (this.destinationCandidates.Count == 0) { throw new Exception("Count of DestinationCandidates is zero."); } // Check the name conflict of destination candidates. if (this.destinationCandidates.Count != (from destinations in this.destinationCandidates select destinations.name).Distinct().Count()) { throw new Exception("There is the name conflict of destination candidates objects."); } SIGVerseLogger.Info("Count of Destinations = " + this.destinationCandidates.Count); this.avatarMotionPlayer = avatarMotionPlayback.GetComponent <HandymanAvatarMotionPlayer>(); this.avatarMotionRecorder = avatarMotionPlayback.GetComponent <HandymanAvatarMotionRecorder>(); this.playbackRecorder = worldPlayback.GetComponent <HandymanPlaybackRecorder>(); }
/// <summary> /// Robot -> Human Avatar /// </summary> public void OnReceiveRosStringMsg(RosBridge.std_msgs.String rosMsg) { this.SendChatMessage(rosMsg.data); SIGVerseLogger.Info("Robot: Sent a message. sender=" + this.transform.root.name + ", message=" + rosMsg.data); }
private void InsertMotionsToMySQL() { MySqlConnection mysqlConn = null; MySqlCommand mysqlCommand = null; try { string connString = "server =" + this.mysqlIpInputField.text + ";" + "port =" + this.mysqlPortInputField.text + ";" + "database=" + MysqlSchemaName + ";" + "userid =" + this.mysqlUserInputField.text + ";" + "password="******"Inserted " + "1" + " records."); // Write motion data int cnt = 0; insertSql = string.Empty; foreach (string savedMotionString in this.savedMotionStrings) { this.CreateInsertQuery(ref insertSql, savedMotionString); cnt++; // Execute the insert query every 100 times. if (cnt == 100) { mysqlCommand = new MySqlCommand(insertSql, mysqlConn); mysqlCommand.ExecuteNonQuery(); cnt = 0; insertSql = string.Empty; } } if (cnt != 0) { mysqlCommand = new MySqlCommand(insertSql, mysqlConn); mysqlCommand.ExecuteNonQuery(); } SIGVerseLogger.Info("Inserted " + savedMotionStrings.Count + " records."); mysqlCommand.Dispose(); mysqlConn.Close(); this.isWriting = false; } catch (Exception ex) { SIGVerseLogger.Error(ex.Message); SIGVerseLogger.Error(ex.StackTrace); if (mysqlConn != null) { mysqlConn.Close(); } Application.Quit(); } }
//void OnDestroy() //{ // this.CloseRosConnections(); //} // Update is called once per frame void Update() { try { if (this.isAllTaskFinished) { return; } if (this.interruptedReason != string.Empty && this.step != Step.WaitForNextTrial) { SIGVerseLogger.Info("Failed '" + this.interruptedReason + "'"); this.SendPanelNotice("Failed\n" + interruptedReason.Replace('_', ' '), 100, PanelNoticeStatus.Red); this.TimeIsUp(); } if (OVRInput.GetDown(OVRInput.RawButton.X) && this.isDuringTrial) { if (!this.sessionManager.GetSeechRunState()) { this.SendRosHumanNaviMessage(MsgRequest, ""); } } switch (this.step) { case Step.Initialize: { if (this.isCompetitionStarted) { this.PreProcess(); this.step++; } break; } case Step.InitializePlayback: // Need to wait for an update to finish instantiating objects to record { this.InitializePlayback(); this.step++; break; } case Step.WaitForStart: { if (this.stepTimer.IsTimePassed((int)this.step, 3000)) { if (this.IsPlaybackInitialized() && this.IsConnectedToRos()) { this.step++; } } break; } case Step.TrialStart: { this.goToNextTrialPanel.SetActive(false); SIGVerseLogger.Info("Trial start!"); this.RecordEventLog("Trial_start"); this.scoreManager.TaskStart(); this.SendPanelNotice("Trial start!", 100, PanelNoticeStatus.Green); base.StartCoroutine(this.ShowNoticeMessagePanelForAvatar("Trial start!", 3.0f)); this.isDuringTrial = true; this.step++; break; } case Step.WaitForIamReady: { if (this.receivedMessageMap[MsgIamReady]) { this.StartPlaybackRecord(); this.step++; break; } this.SendMessageAtIntervals(MsgAreYouReady, "", SendingAreYouReadyInterval); break; } case Step.SendTaskInfo: { this.SendRosTaskInfoMessage(this.taskInfoForRobot); SIGVerseLogger.Info("Waiting for end of trial"); this.step++; break; } case Step.WaitForEndOfSession: { this.CheckHandInteraction(this.LeftHand); this.CheckHandInteraction(this.rightHand); break; } case Step.WaitForNextTrial: { if (this.goNextTrial) { SIGVerseLogger.Info("Go to next trial"); this.RecordEventLog("Go_to_next_trial"); this.SendRosHumanNaviMessage(MsgGoToNextTrial, ""); this.step = Step.Initialize; } break; } } } catch (Exception exception) { Debug.LogError(exception); SIGVerseLogger.Error(exception.Message); SIGVerseLogger.Error(exception.StackTrace); this.ApplicationQuitAfter1sec(); } }
protected virtual void InitializeTargetTransforms() { // Transform this.targetTransforms = new List <Transform>(); switch (this.targetType) { case TargetType.AllObjects: { this.targetTransforms = FindObjectsOfType <Transform>().ToList(); // High Load break; } case TargetType.ObjectsWithRigidbodyAndItsChildObjects: { HashSet <Transform> targetHashSet = new HashSet <Transform>(); Rigidbody[] rigidbodies = FindObjectsOfType <Rigidbody>(); // High Load foreach (Rigidbody rb in rigidbodies) { targetHashSet.UnionWith(rb.gameObject.GetComponentsInChildren <Transform>()); } this.targetTransforms = targetHashSet.ToList(); break; } case TargetType.ObjectsWithRigidbody: { Rigidbody[] rigidbodies = FindObjectsOfType <Rigidbody>(); // High Load this.targetTransforms = rigidbodies.Select(x => x.transform).ToList(); break; } } // Exclude some objects. foreach (GameObject rootObjectToExclude in this.exclusionTargets) { Transform[] transformsToExclude = rootObjectToExclude.GetComponentsInChildren <Transform>(true); foreach (Transform transformToExclude in transformsToExclude) { this.targetTransforms.Remove(transformToExclude); } } int targetTransformCountBefore = this.targetTransforms.Count; foreach (String exclusionTargetNameRegex in this.exclusionTargetNameRegexs) { this.targetTransforms = this.targetTransforms.Where(x => !Regex.IsMatch(x.name, exclusionTargetNameRegex)).ToList(); } if (this.targetTransforms.Count != targetTransformCountBefore) { SIGVerseLogger.Info("The number excluded by name is " + (targetTransformCountBefore - this.targetTransforms.Count)); } }
//-------------------------------------------------- protected override void SubscribeMessageCallback(RosBridge.human_navigation.HumanNaviGuidanceMsg guidaneMsg) { SIGVerseLogger.Info("Received guide message: " + guidaneMsg.message + ", display type: " + guidaneMsg.display_type + ", source lang: " + guidaneMsg.source_language + ", target lang: " + guidaneMsg.target_language); this.tts.OnReceiveROSHumanNaviGuidanceMessage(guidaneMsg); }
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 OnReceiveChatMessage(string senderName, string message) { SIGVerseLogger.Info("Receive ChatMessage on ChatManager. user="******", message=" + message); this.photonView.RPC("ForwardMessage", RpcTarget.All, senderName, message); }
protected virtual void StopPlaying() { SIGVerseLogger.Info("( Stop the world playback playing )"); this.step = Step.Waiting; }