Ejemplo n.º 1
0
        // Start is called before the first frame update
        void Start()
        {
            // 速度をゆっくりに強制
            ModelJoint.SetAllJointsMaxSpeed(60f);

            _controller = GetComponent <PreMaid.RemoteController.PreMaidController>();
            List <TMP_Dropdown.OptionData> serialPortNamesList = new List <TMP_Dropdown.OptionData>();

            var portNames = SerialPort.GetPortNames();


            foreach (var VARIABLE in portNames)
            {
                TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(VARIABLE);
                serialPortNamesList.Add(optionData);

                Debug.Log(VARIABLE);
            }

            _serialPortsDropdown.ClearOptions();
            _serialPortsDropdown.AddOptions(serialPortNamesList);

            _joints = target.GetComponentsInChildren <ModelJoint>();
        }
Ejemplo n.º 2
0
        // Start is called before the first frame update
        void Start()
        {
            _controller = GetComponent <PreMaid.RemoteController.PreMaidControllerSPUP>();
            List <TMP_Dropdown.OptionData> serialPortNamesList = new List <TMP_Dropdown.OptionData>();

            var portNames = SerialPortUtility.SerialPortUtilityPro.GetConnectedDeviceList(SerialPortUtility.SerialPortUtilityPro.OpenSystem.BluetoothSSP);

            if (portNames != null)
            {
                foreach (var VARIABLE in portNames)
                {
                    TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(VARIABLE.SerialNumber);
                    serialPortNamesList.Add(optionData);

                    Debug.Log(VARIABLE);
                }

                _serialPortsDropdown.ClearOptions();
                _serialPortsDropdown.AddOptions(serialPortNamesList);
            }
            else
            {
                // Android実機でのデバッグ用
                serialPortNamesList.Add(new TMP_Dropdown.OptionData("RNBT-4FFA"));
                serialPortNamesList.Add(new TMP_Dropdown.OptionData("RNBT-50D6"));
                serialPortNamesList.Add(new TMP_Dropdown.OptionData("RNBT-9C50"));
                serialPortNamesList.Add(new TMP_Dropdown.OptionData("RNBT-94F6"));

                _serialPortsDropdown.ClearOptions();
                _serialPortsDropdown.AddOptions(serialPortNamesList);
                _serialPortsDropdown.SetValueWithoutNotify(0);
            }

            // 上半身だけを操作対象とする
            _controller.jointMask = (uint)(PreMaidControllerSPUP.JointMask.UpperBody);

            // 関節速度制限
            ModelJoint.SetAllJointsMaxSpeed(90f);

            //対象のAnimatorにBoneにHumanoidModelJoint.csのアタッチ漏れがあるかもしれない
            //なので、一旦全部検索して、見つからなかったサーボ情報はspineに全部動的にアタッチする
            Transform spineBone = target.GetBoneTransform(HumanBodyBones.Spine);

            //仮でspineにでも付けておこう
            if (target != null)
            {
                var joints = target.GetComponentsInChildren <HumanoidModelJoint>();

                foreach (PreMaidServo.ServoPosition item in Enum.GetValues(typeof(PreMaidServo.ServoPosition)))
                {
                    if (Array.FindIndex(joints, joint => joint.TargetServo == item) == -1)
                    {
                        var jointScript = spineBone.gameObject.AddComponent <HumanoidModelJoint>();
                        jointScript.TargetServo = item;
                    }
                }

                // 手首だけは最高速度を高くしておく
                var modeljoints = target.GetComponentsInChildren <ModelJoint>();
                foreach (ModelJoint j in modeljoints)
                {
                    if (j.ServoID == "15" || j.ServoID == "17")
                    {
                        j.maxSpeed = 180f;
                    }
                }
            }

            _joints = target.GetComponentsInChildren <HumanoidModelJoint>();
        }