コード例 #1
0
    async void OnUbiiNodeInitialized()
    {
        ubiiSpecs = new Ubii.Devices.Component
        {
            Name          = NAME,
            Description   = DESCRIPTION,
            MessageFormat = MESSAGE_FORMAT,
            IoType        = Ubii.Devices.Component.Types.IOType.Subscriber,
            Topic         = GetTopicTargetVelocities()
        };
        ubiiSpecs.Tags.AddRange(TAGS);

        tokenTargetVelocities = await ubiiNode.SubscribeTopic(this.ubiiSpecs.Topic, (Ubii.TopicData.TopicDataRecord record) =>
        {
            for (int i = 0; i < record.Object3DList.Elements.Count; i++)
            {
                string boneString = record.Object3DList.Elements[i].Id;
                HumanBodyBones bone;
                if (HumanBodyBones.TryParse(boneString, out bone))
                {
                    Ubii.DataStructure.Pose3D pose = record.Object3DList.Elements[i].Pose;
                    Vector3 linear  = new Vector3((float)pose.Position.X, (float)pose.Position.Y, (float)pose.Position.Z);
                    Vector3 angular = new Vector3((float)pose.Euler.X, (float)pose.Euler.Y, (float)pose.Euler.Z);
                    SetTargetVelocity(bone, linear, angular);
                }
            }
        });

        ubiiReady = true;
    }
コード例 #2
0
    void OnUbiiInitialized()
    {
        ubiiSpecs = new Ubii.Devices.Component
        {
            Name          = "Unity Physical Avatar - Current Position and Orientation",
            Description   = "Publishes current avatars bone poses as Object3DList. Object3D.Id will be one of UnityEngine.HumanBodyBones (to be changed to .json config). Position and Quaternion also set reflecting current Rigidbody transform.",
            MessageFormat = "ubii.dataStructure.Object3DList",
            IoType        = Ubii.Devices.Component.Types.IOType.Publisher,
            Topic         = GetTopicCurrentPoseList()
        };
        ubiiSpecs.Tags.AddRange(new string[] { "avatar", "bones", "pose", "position", "orientation", "quaternion" });

        secondsBetweenPublish = 1f / (float)publishFrequency;
        tLastPublish          = Time.time;
        ubiiReady             = true;
    }