<fix> 로봇 모델 변경 및 TCP 실시간 좌표 안 받아와지던 버그 해결

This commit is contained in:
SOOBEEN HAN
2025-12-02 20:57:36 +09:00
parent 59bf5688b6
commit 66c2b29e5b
8 changed files with 4747 additions and 25 deletions

Binary file not shown.

View File

@@ -0,0 +1,137 @@
fileFormatVersion: 2
guid: 78c7883768003264f962f1a220a160e9
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC"
second: {fileID: 2100000, guid: ade1fa40ff9fda54387992620195b107, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC.001"
second: {fileID: 2100000, guid: ca3be46a3b8d9ef44a2a056be6bcc42c, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC.002"
second: {fileID: 2100000, guid: d577930781341d84784b0d51b5f577f1, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC.003"
second: {fileID: 2100000, guid: 5e7c0762c5f635b4eb2f8aefa958f7cb, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC.004"
second: {fileID: 2100000, guid: 5fadfa4282a2d4e4ba1bc94d381cd149, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: "\uB9E4\uD14C\uB9AC\uC5BC.005"
second: {fileID: 2100000, guid: c056a7df43bfbb847811d423b2cab0cf, type: 2}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 1
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -48,7 +48,7 @@ public class BoxController : MonoBehaviour
// 로봇 팔을 부모로 설정하여 따라다니게 함
attachParent = other.transform;
transform.SetParent(attachParent);
transform.localPosition = new Vector3(0, 0, -0.00199f);
transform.localPosition = new Vector3(0.000360000005f, 0f, 0.00267999992f);
transform.localRotation = Quaternion.identity;
// 부착된 동안 물리적 충돌이나 중력을 무시하도록 Rigidbody를 Kinematic으로 설정

View File

@@ -53,7 +53,7 @@ public class ProgramModel
public async Task InitializeAsync()
{
await LoadAllPrograms();
hasNewData = false;
hasNewData = true;
IsMoving = false;
isError = false;
@@ -72,17 +72,14 @@ public class ProgramModel
public bool IsNewDataAvailable()
{
lock (lockObject)
{
return hasNewData;
}
return robotData != null;
}
public RobotData GetLatestRobotData()
{
lock (lockObject)
{
hasNewData = false; // 데이터를 읽었으므로 플래그를 내림
//hasNewData = false; // 데이터를 읽었으므로 플래그를 내림
return robotData;
}
}
@@ -236,7 +233,7 @@ public class ProgramModel
robotData = tempRobotData;
hasNewData = true;
}
await Task.Delay(50, token);
await Task.Delay(10, token);
}
catch (Exception e)
{
@@ -472,7 +469,7 @@ public class ProgramModel
startMovementPosition.z = Convert.ToSingle(Math.Round(position.y * 1000, 2));
string jsonResponse = await tcpClient.SendPostRequestAsync("/project/robot/move_to_pose_manual",
$"{{\"pose_tg\":{{\"crd\":\"robot\",\"_type\":\"Pose\",\"mechinfo\":1,\"x\":{startMovementPosition.x},\"y\":{startMovementPosition.y},\"z\":{startMovementPosition.z}, \"rx\":{robotData.rx}, \"ry\":{robotData.ry}, \"rz\":{robotData.rz}}}}}");
$"{{\"pose_tg\":{{\"crd\":\"robot\",\"_type\":\"Pose\",\"mechinfo\":1,\"x\":{startMovementPosition.x},\"y\":{startMovementPosition.y},\"z\":{startMovementPosition.z}, \"rx\":-180, \"ry\":0, \"rz\":180}}}}");
if (jsonResponse.Contains("200"))
{
@@ -543,7 +540,8 @@ public class ProgramModel
}
else
{
await Task.Delay(10, token);
await udpClient.SendFilledBytesAsync(new Dictionary<int, byte> { { 2, 0x00 }, { 4, 0x50 } });
await Task.Delay(100, token);
}
}
catch (TaskCanceledException)

View File

@@ -684,7 +684,7 @@ public class ProgramPresenter
private float CalcMaxFollowDistance(Bounds bounds)
{
float r = bounds.extents.magnitude;
return Mathf.Clamp(r * 0.8f, 0.15f, 0.30f);
return Mathf.Clamp(r * 1.5f, 0.2f, 1f);
}
//private void StartDragMoveLoop(Vector3 dragPosition)

View File

@@ -5,6 +5,9 @@ using System;
public class TCPView : MonoBehaviour
{
public event Action OnTCPupdateRequested;
// 이전 데이터를 기억할 변수 (캐싱)
private float lastX, lastY, lastZ, lastRx, lastRy, lastRz;
private bool isFirstUpdate = true;
// --- TCP 좌표들 ---
[SerializeField] private TextMeshProUGUI x;
@@ -24,12 +27,26 @@ public class TCPView : MonoBehaviour
public void SetCoordinates(RobotData data)
{
if (data == null) return;
if (!isFirstUpdate &&
Mathf.Approximately((float)data.x, lastX) &&
Mathf.Approximately((float)data.y, lastY) &&
Mathf.Approximately((float)data.z, lastZ) &&
Mathf.Approximately((float)data.rx, lastRx) &&
Mathf.Approximately((float)data.ry, lastRy) &&
Mathf.Approximately((float)data.rz, lastRz))
{
return;
}
x.text = data.x.ToString("F2");
Y.text = data.y.ToString("F2");
Z.text = data.z.ToString("F2");
Rx.text = data.rx.ToString("F2");
Ry.text = data.ry.ToString("F2");
Rz.text = data.rz.ToString("F2");
// 캐시 업데이트
lastX = (float)data.x; lastY = (float)data.y; lastZ = (float)data.z;
lastRx = (float)data.rx; lastRy = (float)data.ry; lastRz = (float)data.rz;
isFirstUpdate = false;
}
}

View File

@@ -3,7 +3,11 @@
--- !u!5 &1
TimeManager:
m_ObjectHideFlags: 0
Fixed Timestep: 0.02
Fixed Timestep:
m_Count: 1567998
m_Rate:
m_Denominator: 1
m_Numerator: 141120000
Maximum Allowed Timestep: 0.33333334
m_TimeScale: 1
Maximum Particle Timestep: 0.03