Beispiel #1
0
        // Use this for initialization
        void Start()
        {
            this.step            = ModeratorStep.Initialize;
            this.avatarStateStep = AvatarStateStep.Initialize;

            this.isAllTaskFinished = false;
            this.interruptedReason = string.Empty;

            if (this.executionMode == ExecutionMode.Competition)
            {
                this.mainPanelController.SetTaskMessageText(this.tool.GetTaskDetail());
            }

            List <GameObject> graspables = this.tool.GetGraspables();

            for (int i = 0; i < graspables.Count; i++)
            {
                Rigidbody rigidbody = graspables[i].GetComponent <Rigidbody>();

                rigidbody.constraints
                    = RigidbodyConstraints.FreezeRotation |
                      RigidbodyConstraints.FreezePositionX |
                      RigidbodyConstraints.FreezePositionZ;

                rigidbody.maxDepenetrationVelocity = 0.5f;

                StartCoroutine(this.tool.LoosenRigidbodyConstraints(rigidbody));
            }

            this.bgmAudioSource.volume = Mathf.Clamp01(CleanupConfig.Instance.configFileInfo.bgmVolume);
        }
Beispiel #2
0
        public void PointObject(Laser laser, AvatarStateStep avatarStateStep)
        {
            switch (this.executionMode)
            {
            // For the competition. Read generated data.
            case ExecutionMode.Competition:
            {
                switch (avatarStateStep)
                {
                case AvatarStateStep.WaitForPickItUp:
                {
                    this.hasPointedTarget = true;
                    break;
                }

                case AvatarStateStep.WaitForCleanUp:
                {
                    this.hasPointedDestination = true;
                    break;
                }

                default:
                {
                    SIGVerseLogger.Warn("This pointing by the avatar is an invalid timing. step=" + avatarStateStep);
                    break;
                }
                }
                break;
            }

            // For data generation.
            case ExecutionMode.DataGeneration:
            {
                switch (avatarStateStep)
                {
                case AvatarStateStep.WaitForPickItUp:
                {
                    this.hasPointedTarget = true;
                    this.graspingTarget   = laser.nearestGraspingObject;

                    break;
                }

                case AvatarStateStep.WaitForCleanUp:
                {
                    this.hasPointedDestination = true;
                    this.destination           = laser.nearestDestination;

                    // Add Placement checker to triggers
                    if (this.destination.GetComponentInChildren <PlacementChecker>() == null)
                    {
                        this.AddPlacementChecker(this.destination);
                    }

                    break;
                }

                default:
                {
                    SIGVerseLogger.Warn("This pointing by the avatar is an invalid timing. step=" + avatarStateStep);
                    break;
                }
                }
                break;
            }

            default:
            {
                throw new Exception("Illegal Execution mode. mode=" + CleanupConfig.Instance.configFileInfo.executionMode);
            }
            }
        }
Beispiel #3
0
        private IEnumerator StartAvatarStateController()
        {
            bool isAvatarControlling = true;

            int numberOfPointing = 1;

            while (isAvatarControlling)
            {
                if (this.step == ModeratorStep.WaitForNextTask)
                {
                    isAvatarControlling = false;
                }

                switch (this.avatarStateStep)
                {
                case AvatarStateStep.Initialize:
                {
                    this.tool.StartAvatarMotionPlaybackPlayer();
                    this.tool.StartAvatarMotionPlaybackRecorder();

                    this.avatarStateStep++;

                    break;
                }

                case AvatarStateStep.WaitForPickItUp:
                {
                    if (this.tool.HasPointedTarget())
                    {
                        this.SendRosMessage(MsgPickItUp, string.Empty);
                        this.tool.AddSpeechQueModerator("Please pick it up");
                        SIGVerseLogger.Info("Sent '" + MsgPickItUp + "'");

                        this.avatarStateStep++;
                    }
                    break;
                }

                case AvatarStateStep.WaitForCleanUp:
                {
                    if (this.tool.HasPointedDestination())
                    {
                        this.SendRosMessage(MsgCleanUp, string.Empty);
                        this.tool.AddSpeechQueModerator("Please clean up");
                        SIGVerseLogger.Info("Sent '" + MsgCleanUp + "'");

                        if (this.executionMode == ExecutionMode.DataGeneration && numberOfPointing == 1)
                        {
                            this.mainPanelController.SetTaskMessageText(this.tool.GetTaskDetail());

                            StartCoroutine(this.tool.SaveEnvironmentInfo());
                        }

                        this.avatarStateStep++;
                    }
                    break;
                }

                case AvatarStateStep.WaitForReturnToInitialPosition:
                {
                    if ((this.executionMode == ExecutionMode.DataGeneration && this.tool.HasPressedButtonToStopRecordingAvatarMotion()) ||
                        (this.executionMode == ExecutionMode.Competition && this.tool.IsAvatarMotionPlaybackPlayerFinished()))
                    {
                        this.tool.StopAvatarMotionPlaybackRecorder();

                        this.avatarStateStep++;
                    }
                    break;
                }

                case AvatarStateStep.ReturnToInitialPosition:
                {
                    if (this.executionMode == ExecutionMode.Competition)
                    {
                        IEnumerator makeAvatarInitialPosture = this.tool.MakeAvatarInitialPosture();

                        yield return(StartCoroutine(makeAvatarInitialPosture));
                    }

                    this.avatarStateStep++;

                    break;
                }

                case AvatarStateStep.WaitForNextPointing:
                {
                    if (this.executionMode == ExecutionMode.Competition && this.receivedMessageMap[MsgPointItAgain])
                    {
                        this.receivedMessageMap[MsgPointItAgain] = false;

                        this.scoreManager.AddScore(Score.Type.PointItAgain);

                        this.tool.ResetPointingStatus();

                        numberOfPointing++;

                        this.avatarStateStep = AvatarStateStep.Initialize;
                    }

                    break;
                }
                }

                yield return(null);
            }
        }