<fix> 로봇 Grab하는 동안 생긴 버그 해결, 놓으면 바로 멈추도록 변경, 프로그램 재생 시에도 사운드 재생하도록 변경

This commit is contained in:
SOOBEEN HAN
2025-11-25 15:15:54 +09:00
parent d599d066be
commit 810432db96
12 changed files with 347 additions and 126 deletions

View File

@@ -10,7 +10,7 @@ public enum HandSide { Left, Right }
public class InteractionView : MonoBehaviour
{
public event Action<bool> OnRobotHoverStateChanged;
public event Action OnRobotGrabStart;
public event Action<Vector3> OnRobotGrabStart;
public event Action<Vector3, Quaternion> OnRobotGrabbed;
public event Action<RobotData> OnRobotReleased;
public event Action<int, Vector3> OnPointClicked;
@@ -173,7 +173,7 @@ public class InteractionView : MonoBehaviour
isGrabbingRobot = true;
currentGrabbedPointIndex = -1;
OnRobotGrabStart?.Invoke();
OnRobotGrabStart?.Invoke(startGrabPosition);
OnPointDragStart?.Invoke(currentGrabbedPointIndex);
}
}

View File

@@ -3,13 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
// 인터페이스
public interface IPathLineView
{
}
[RequireComponent(typeof(LineRenderer))]
public class PathLineView : MonoBehaviour, IPathLineView
public class PathLineView : MonoBehaviour
{
private LineRenderer lineRenderer;

View File

@@ -21,21 +21,43 @@ public class PointManagerView : MonoBehaviour
private Vector3 ConvertRobotDataToVector3(RobotData pose)
{
float x = Convert.ToSingle(pose.x / -1000.0); // mm -> m
float x = Convert.ToSingle(pose.x / -1000.0); // Robot X(mm) -> Unity X(m)
float y = Convert.ToSingle(pose.z / 1000.0); // Robot Z(mm) -> Unity Y(m)
float z = Convert.ToSingle(pose.y / -1000.0); // Robot Y(mm) -> Unity Z(m)
return new Vector3(x, y, z);
}
private Quaternion ConvertRobotDataToQuaternion(RobotData pose)
{
float rx = pose.rx;
float ry = pose.z;
float rz = pose.y;
return Quaternion.Euler(pose.rx, -pose.rz, pose.ry);
}
public void CreatePoint(RobotData pose, int index)
{
if(pointPrefab == null)
{
Debug.Log("마커 프리팹이 할당되지 않았습니다.");
return;
}
Vector3 localPos = ConvertRobotDataToVector3(pose);
Vector3 worldPos = localPos;
//Quaternion localRot = ConvertRobotDataToQuaternion(pose);
//Vector3 toolOffset = new Vector3(0.681004044f, -0.221942063f, -0.447616011f);
//Vector3 rotatedOffset = localRot * toolOffset;
//Vector3 finalLocalPos = localPos + rotatedOffset;
Vector3 worldPos = localPos;
//Quaternion worldRot = localRot;
// 로봇 Base가 있다면, 로컬 좌표를 월드 좌표로 변환
if (robotBaseTransform != null)
{
worldPos = robotBaseTransform.TransformPoint(localPos);
//worldRot = robotBaseTransform.rotation * localRot;
}
else
{
@@ -44,6 +66,9 @@ public class PointManagerView : MonoBehaviour
// 변환된 월드 좌표에 생성
GameObject pointObj = Instantiate(pointPrefab, worldPos, Quaternion.identity, this.transform);
Debug.Log($"마커 프리팹 생성됨, 위치: {worldPos}");
//pointObj.transform.localRotation = Quaternion.identity;
activePoints.Add(pointObj);
RobotPoint pointComponent = pointObj.GetComponent<RobotPoint>();

View File

@@ -122,7 +122,7 @@ public class ProgramInfoView : MonoBehaviour
private void ShowProgramInfoPanel(InputAction.CallbackContext obj)
{
isPressingX = !isPressingX;
if (!isPressingX)
if (isPressingX)
{
infoPanel.transform.SetParent(leftControllerTransform);
infoPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f);
@@ -143,7 +143,7 @@ public class ProgramInfoView : MonoBehaviour
private void PlayProgram(InputAction.CallbackContext obj)
{
isPressingAorB = !isPressingAorB;
if (!isPressingAorB)
if (isPressingAorB)
{
OnStartClicked?.Invoke();
}