81 lines
2.3 KiB
C#
81 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Linq;
|
|
using System;
|
|
using DG.Tweening;
|
|
|
|
// ¿ÞÂÊ ÆÐ³Î UI
|
|
public class RobotInfoUI : MonoBehaviour
|
|
{
|
|
public URRobot robot;
|
|
|
|
public Text[] text_torque;
|
|
public Text[] text_angle;
|
|
public Slider[] slider_angle;
|
|
public Text[] text_tcp;
|
|
|
|
// joint view toggle
|
|
public Sprite jointViewOn, jointViewOff;
|
|
public Toggle[] jointViewToggle;
|
|
|
|
// close
|
|
public RectTransform leftPaenl;
|
|
|
|
public Sprite closeSprite, openSprite;
|
|
public Image handle;
|
|
public bool isClose;
|
|
|
|
public void SetCurrentRobotRealtimeInfo(List<MQTTInfo> data)
|
|
{
|
|
for (int i = 0; i < robot.jointCount; i++)
|
|
{
|
|
if(Math.Sign(robot.rotationValueArray[i]) == -1)
|
|
{
|
|
robot.rotationValueArray[i] = robot.rotationValueArray[i] + 360;
|
|
}
|
|
|
|
text_angle[i].text = robot.rotationValueArray[i].ToString("0.00");
|
|
text_torque[i].text = data[robot.jointCount + i].value.ToString();
|
|
slider_angle[i].value = robot.rotationValueArray[i];
|
|
text_tcp[i].text = Convert.ToSingle(data[robot.jointCount * 2 + i].value).ToString();
|
|
|
|
//text_torque[i].text = (Math.Truncate(robot.rotationValueArray[i] * 100) / 100).ToString();
|
|
//text_torque[i].text = (Math.Truncate(data[robot.jointCount + i].value * 100) / 100).ToString();
|
|
//slider_angle[i].value = robot.rotationValueArray[i];
|
|
//text_tcp[i].text = (Math.Truncate(data[robot.jointCount* 2 + i].value / 10f * 100) / 100).ToString();
|
|
}
|
|
}
|
|
|
|
public void SelectJointViewToggle(int num)
|
|
{
|
|
if (jointViewToggle[num].isOn)
|
|
{
|
|
jointViewToggle[num].GetComponent<Image>().sprite = jointViewOn;
|
|
}
|
|
else
|
|
{
|
|
jointViewToggle[num].GetComponent<Image>().sprite = jointViewOff;
|
|
}
|
|
|
|
robot.jointUIArray[num].SetActive(jointViewToggle[num].isOn);
|
|
}
|
|
|
|
public void OnClickCloseTabBtn()
|
|
{
|
|
isClose = !isClose;
|
|
|
|
if(isClose)
|
|
{
|
|
leftPaenl.DOMoveX(-482f , 0.5f);
|
|
handle.sprite = closeSprite;
|
|
}
|
|
else
|
|
{
|
|
leftPaenl.DOMoveX(0f, 0.5f);
|
|
handle.sprite = openSprite;
|
|
}
|
|
}
|
|
}
|