Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WebSocketSharp;
using ETSI.ARF.WorldAnalysis;
using ETSI.ARF.WorldAnalysis.REST;
using ETSI.ARF.OpenAPI.WorldAnalysis;
using Pose = ETSI.ARF.OpenAPI.WorldAnalysis.Pose;
using UnityEngine.InputSystem;
using System;
using static WorldAnalysisInterface;
public class ClientTest : MonoBehaviour
{
static public string token = "ARF_Permission";
static public string session = "HHI";
public WorldAnalysisREST rest;
public GameObject asset1;
// Start is called before the first frame update
void Start()
{
if (asset1 != null) asset1.GetComponent<Renderer>().material.color = Color.red;
rest.CheckServer();
Capability[] caps;
if (rest.GetCapabilities(token, out caps) == WorldAnalysisInterface.CapabilityResult.OK)
{
rest.PrintCapabilities(caps);
}
int validity = 0;
Guid subs;
Guid anchor = Guid.Parse("fa8bbe40-8052-11ec-a8a3-0242ac120002");
rest.SubscribeToPose(token, anchor, Mode_WorldAnalysis.TRACKABLES_TO_DEVICE, PoseCallback, ref validity, out subs);
}
// Update is called once per frame
bool updateAsset1 = false;
Color asset1Color = Color.grey;
void Update()
{
if (Keyboard.current.spaceKey.wasPressedThisFrame)
{
//webSocket.Send("PoseStart:10");
}
if (updateAsset1)
{
updateAsset1 = false;
asset1.GetComponent<Renderer>().material.color = asset1Color;
}
}
void SetColor(Color c)
{
updateAsset1 = true;
asset1Color = c;
}
public void SubscribeToPose()
{
Guid uuid = new Guid(); // request id from anchor or trackable
Guid subId;
int validity = 1;
InformationSubscriptionResult response = rest.SubscribeToPose(token, uuid, Mode_WorldAnalysis.TRACKABLES_TO_DEVICE, PoseCallback, ref validity, out subId);
if (response == InformationSubscriptionResult.OK)
{
// State: yellow
}
}
public void PoseCallback(WorldAnalysisInterface.PoseEstimationResult result, ETSI.ARF.OpenAPI.WorldAnalysis.Pose pose)
{
switch (result)
{
case PoseEstimationResult.OK:
// State: green
//asset1.transform.rotation = WorldAnalysisUnityHelper.ConvertETSIARFQuaternionToUnity(pose.Value.ro...)
break;
case PoseEstimationResult.NONE:
// State: yellow
break;
case PoseEstimationResult.NOT_ALLOWED:
// State: red
break;
case PoseEstimationResult.FAILURE:
// State: red
break;
case PoseEstimationResult.NOT_SUPPORTED:
// State: red
break;
case PoseEstimationResult.UNKNOWN_ID:
// State: red
break;
}
}
}