Exemplo n.º 1
0
        public async Task InitAsync()
        {
#if UNITY_WSA && !UNITY_EDITOR
            store.putBlob(new MyPoint[] { new MyPoint(0, 0, 0, false), new MyPoint(1, 1, 1, true) });

            MainScript.Log("-1");
            var httpClient = RobotClientProvider.GetHttpClientAsync(hostname);
            MainScript.Log("0");

            //string url = "http://requestb.in/1df3ott1";
            //var response = await httpClient.GetAsync(new Uri(url));
            //var content = await response.Content.ReadAsStringAsync();
            //MainScript.Log("1 " + content);
            //return;

            yumi = new RemoteYumi(hostname, httpClient);

            await yumi.RightArm.DisableLiveFollow();

            MainScript.Log("1");
            await yumi.Init();

            MainScript.Log("2");
            await yumi.RunProcedureForBothArms("Home");

            MainScript.Log("3");
            await yumi.LeftArm.RunProcedure("HandUp");

            MainScript.Log("4");

            await yumi.RightArm.ActivateLiveFollow();

            await yumi.RightArm.OpenGripper();

            await Task.Delay(1000);

            await yumi.RightArm.CloseGripper();

            await Task.Delay(1000);

            await yumi.RightArm.DisableLiveFollow();

            await Task.Delay(1000);

            isInitialized = true;
            MainScript.Log("Initialized!");
            lastUpdate = DateTime.Now;
#endif
        }
Exemplo n.º 2
0
        async Task SetVariable(string moduleName, string name, string value)
        {
#if UNITY_WSA && !UNITY_EDITOR
            var parameters = new Dictionary <string, string>
            {
                { "value", value },
            };
            var    content  = new HttpFormUrlEncodedContent(parameters);
            string url      = $"http://{_hostname}/rw/rapid/symbol/data/RAPID/{_taskName}/{moduleName}/{name}?action=set";
            var    response = await _client.PostAsync(new Uri(url), content);

            response.EnsureSuccessStatusCode();
            string respcontent = await response.Content.ReadAsStringAsync();

            MainScript.Log("POST " + url + " " + DictToString(parameters) + " " + respcontent);
#else
            return;
#endif
        }
Exemplo n.º 3
0
        public void putBlob(MyPoint[] list)
        {
            DateTime now      = DateTime.Now;
            String   blobname = "path-" + now.Year + "." + now.Month + "." + now.Day + "-" + now.Hour + ":" + now.Minute;

            MainScript.Log("Blob: " + blobname);

            string j = "";

            foreach (MyPoint p in list)
            {
                string s = String.Format("{0},{1},{2},{3};", p.x, p.y, p.z, p.g);
                j += s;
            }

            MainScript.Log("Serialized: " + j);

            bs.PutTextBlob((pr) => { MainScript.Log(pr.StatusCode.ToString() + " [" + pr.Content + "]"); }, j, "hololense", blobname, "text/json");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set the program pointer to a routine.
        /// </summary>
        /// <param name="moduleName">The module containing the routine.</param>
        /// <param name="routineName">The name of the routine.</param>
        public async Task SetPPToRoutine(string moduleName, string routineName)
        {
#if UNITY_WSA && !UNITY_EDITOR
            string url        = $"http://{_hostname}/rw/rapid/tasks/{_taskName}/pcp?action=set-pp-routine";
            var    parameters = new Dictionary <string, string>
            {
                { "module", moduleName },
                { "routine", routineName },
            };
            var content = new HttpFormUrlEncodedContent(parameters);
            MainScript.Log(url + DictToString(parameters));
            var response = await _client.PostAsync(new Uri(url), content);

            if (!response.IsSuccessStatusCode)
            {
                MainScript.Log(await response.Content.ReadAsStringAsync());
            }
            response.EnsureSuccessStatusCode();
#endif
        }
Exemplo n.º 5
0
        async Task <bool> GetBoolVariable(string moduleName, string name)
        {
#if UNITY_WSA && !UNITY_EDITOR
            MainScript.Log($"GetBoolVariable {moduleName} {name}");
            string url      = $"http://{_hostname}/rw/rapid/symbol/data/RAPID/{_taskName}/{moduleName}/{name}?json=1";
            var    response = await _client.GetAsync(new Uri(url));

            response.EnsureSuccessStatusCode();
            var content = await response.Content.ReadAsStringAsync();

            var tr = content.Contains("\"value\":\"TRUE\"");
            //MainScript.Log("JSON " + content);
            //JObject json = JObject.Parse(content);
            //string value = json["_embedded"]["_state"][0]["value"].ToString();
            //string value = "false";
            MainScript.Log("GET " + url + " getBool() -> " + tr.ToString() + content);
            return(tr);
#else
            return(false);
#endif
        }