初めまして。
GetLocalSpaceOrientations()の数値を( (0.0, 0.0, 0.0, 0.0) のクウォータ二オンが出力されますが数値として考えるため深く考えなくていいです。)
現在consoleの出力内容をテキストにしてからpythonで数値を統計化してと考えていたのですが、unityから直接できることを知り調べたのですがわからなくて止まっています。
またテキストに書き込むこともできていないため、プログラムが中途半端になっています。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Enflux.SDK.Core;
using UnityEngine.UI;
using System;
using System.Linq;
using Enflux.Common.DataTypes;
using Enflux.SDK.Core.Devices;
using Enflux.SDK.DataTypes;
using Enflux.SDK.Extensions;
using Enflux.SDK.Utils;
using Enflux.Shim.Utils;
using System.IO;
public class math : MonoBehaviour
{
// Assign these in the editor.
public EnfluxManager EnfluxManager;
public Humanoid Humanoid;
// Retrieve limb orientations as Unity local space quaternions.
private void GetLocalSpaceOrientations()
{
var chest = Humanoid.LocalOrientations.Chest.Orientation;
var leftUpperArm = Humanoid.LocalOrientations.LeftUpperArm.Orientation;
var leftLowerArm = Humanoid.LocalOrientations.LeftLowerArm.Orientation;
var rightUpperArm = Humanoid.LocalOrientations.RightUpperArm.Orientation;
var rightLowerArm = Humanoid.LocalOrientations.RightLowerArm.Orientation;
var pelvis = Humanoid.LocalOrientations.Pelvis.Orientation;
var leftUpperLeg = Humanoid.LocalOrientations.LeftUpperLeg.Orientation;
var leftLowerLeg = Humanoid.LocalOrientations.LeftLowerLeg.Orientation;
var rightUpperLeg = Humanoid.LocalOrientations.RightUpperLeg.Orientation;
var rightLowerLeg = Humanoid.LocalOrientations.RightLowerLeg.Orientation;
}
// Retrieve limb orientations as real world NED (North-East-Down) space quaternions. private string GetNedSpaceOrientations() { var chest = EnfluxManager.NedOrientations.Chest.Orientation; var leftUpperArm = EnfluxManager.NedOrientations.LeftUpperArm.Orientation; var leftLowerArm = EnfluxManager.NedOrientations.LeftLowerArm.Orientation; var rightUpperArm = EnfluxManager.NedOrientations.RightUpperArm.Orientation; var rightLowerArm = EnfluxManager.NedOrientations.RightLowerArm.Orientation; var pelvis = EnfluxManager.NedOrientations.Pelvis.Orientation; var leftUpperLeg = EnfluxManager.NedOrientations.LeftUpperLeg.Orientation; var leftLowerLeg = EnfluxManager.NedOrientations.LeftLowerLeg.Orientation; var rightUpperLeg = EnfluxManager.NedOrientations.RightUpperLeg.Orientation; var rightLowerLeg = EnfluxManager.NedOrientations.RightLowerLeg.Orientation; /* Debug.Log("胸 " + chest); Debug.Log("<color=blue>" + "左肘 " + leftUpperArm + "</color>"); Debug.Log("<color=blue>" + "左手首 " + leftLowerArm + "</color>"); Debug.Log("<color=red>" + "右肘 " + rightUpperArm + "</color>"); Debug.Log("<color=red>" + "右手首 " + rightLowerArm + "</color>"); */ return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm + "\n\n"+ "\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg; } void Start() { } private float timeleft; int log;
void Update()
{
timeleft -= Time.deltaTime; if (timeleft <= 0.0) { timeleft = 1.0f; log++; Debug.Log(GetNedSpaceOrientations()); this.GetComponent<Text>().text = GetNedSpaceOrientations(); }
}
/* public void logSave(int num, string txt) { StreamWriter sw; FileInfo fi; fi = new FileInfo(Application.dataPath + "/FileName.csv"); sw = fi.AppendText(); sw.WriteLine("test output"); sw.Flush(); sw.Close(); } */ public void textSave(float GetNedSpaceOrientations) { StreamWriter sw = new StreamWriter("../aaaaa.txt", true); //true=追記 false=上書き sw.WriteLine(GetNedSpaceOrientations); sw.Flush(); sw.Close(); }
}
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
回答1件
あなたの回答
tips
プレビュー