diff --git a/Assets/Resources/RenderPipelines/UniversalRenderPipelineAsset.asset b/Assets/Resources/RenderPipelines/UniversalRenderPipelineAsset.asset index bdc7accf..ad6be46a 100644 --- a/Assets/Resources/RenderPipelines/UniversalRenderPipelineAsset.asset +++ b/Assets/Resources/RenderPipelines/UniversalRenderPipelineAsset.asset @@ -104,6 +104,10 @@ MonoBehaviour: m_PrefilterDBufferMRT1: 1 m_PrefilterDBufferMRT2: 1 m_PrefilterDBufferMRT3: 1 + m_PrefilterSoftShadowsQualityLow: 1 + m_PrefilterSoftShadowsQualityMedium: 1 + m_PrefilterSoftShadowsQualityHigh: 1 + m_PrefilterSoftShadows: 0 m_PrefilterScreenCoord: 1 m_PrefilterNativeRenderPass: 1 m_ShaderVariantLogLevel: 0 diff --git a/Assets/Scripts/Devices/JointState.cs b/Assets/Scripts/Devices/JointState.cs index b30ab58a..3bdde25f 100644 --- a/Assets/Scripts/Devices/JointState.cs +++ b/Assets/Scripts/Devices/JointState.cs @@ -102,9 +102,22 @@ void FixedUpdate() var articulation = item.Item1; var jointState = item.Item2; - jointState.Effort = articulation.GetEffort(); - jointState.Position = articulation.GetJointPosition(); - jointState.Velocity = articulation.GetJointVelocity(); + var jointVelocity = articulation.GetJointVelocity(); + var jointPosition = articulation.GetJointPosition(); + var jointForce = articulation.GetForce(); + + jointState.Effort = (articulation.IsRevoluteType()) ? + DeviceHelper.Convert.CurveOrientation(jointForce) : + (articulation.IsPrismaticType() ? + DeviceHelper.Convert.PrismaticDirection(jointForce, articulation.GetAnchorRotation()) : jointForce); + + jointState.Position = (articulation.IsRevoluteType()) ? + DeviceHelper.Convert.CurveOrientation(jointPosition) : + (articulation.IsPrismaticType() ? + DeviceHelper.Convert.PrismaticDirection(jointPosition, articulation.GetAnchorRotation()) : jointPosition); + + jointState.Velocity = (articulation.IsRevoluteType()) ? + DeviceHelper.Convert.CurveOrientation(jointVelocity) : jointVelocity; } } } diff --git a/Assets/Scripts/Devices/Modules/Articulation.cs b/Assets/Scripts/Devices/Modules/Articulation.cs index 852778d8..7fe07626 100644 --- a/Assets/Scripts/Devices/Modules/Articulation.cs +++ b/Assets/Scripts/Devices/Modules/Articulation.cs @@ -5,6 +5,7 @@ */ using UnityEngine; +using System.Collections.Generic; public class Articulation { @@ -41,6 +42,11 @@ public bool IsRevoluteType() return (Type == ArticulationJointType.RevoluteJoint || Type == ArticulationJointType.SphericalJoint) ? true : false; } + public bool IsPrismaticType() + { + return (Type == ArticulationJointType.RevoluteJoint || Type == ArticulationJointType.PrismaticJoint) ? true : false; + } + protected void SetJointVelocity(in float velocity, in int targetDegree = 0) { if (_jointBody != null) @@ -59,38 +65,37 @@ private int GetValidIndex(in int index) return (_jointBody == null) ? -1 : ((index >= _jointBody.dofCount) ? (_jointBody.dofCount - 1) : index); } + public Vector3 GetAnchorRotation() + { + return (_jointBody == null) ? Vector3.zero : _jointBody.anchorRotation.eulerAngles; + } + /// in radian for angular and in meters for linear public float GetJointPosition(int index = 0) { if (IsRevoluteType()) { index = GetValidIndex(index); - return (_jointBody == null || index == -1) ? 0 : - DeviceHelper.Convert.CurveOrientation(_jointBody.jointPosition[index]); + return (_jointBody == null || index == -1) ? 0 : _jointBody.jointPosition[index]; } else { if (Type == ArticulationJointType.PrismaticJoint) { - var anchorRotation = _jointBody.anchorRotation.eulerAngles; - var direction = (Mathf.Approximately(anchorRotation.x, 180) || - Mathf.Approximately(anchorRotation.y, 180) || - Mathf.Approximately(anchorRotation.z, 180)) ? -1f : 1f; - if (_jointBody.linearLockX == ArticulationDofLock.LockedMotion && _jointBody.linearLockY == ArticulationDofLock.LockedMotion) { - return direction * _jointBody.transform.localPosition.z; + return _jointBody.transform.localPosition.z; } else if (_jointBody.linearLockY == ArticulationDofLock.LockedMotion && _jointBody.linearLockZ == ArticulationDofLock.LockedMotion) { - return direction * _jointBody.transform.localPosition.x; + return _jointBody.transform.localPosition.x; } else if (_jointBody.linearLockX == ArticulationDofLock.LockedMotion && _jointBody.linearLockZ == ArticulationDofLock.LockedMotion) { - return direction * _jointBody.transform.localPosition.y; + return _jointBody.transform.localPosition.y; } } } @@ -111,16 +116,15 @@ public float GetJointVelocity(int index = 0) { index = GetValidIndex(index); var value = (_jointBody == null || index == -1) ? 0 : _jointBody.jointVelocity[index]; - return (IsRevoluteType() ? DeviceHelper.Convert.CurveOrientation(value) : value); + return value; } /// torque for angular and force for linear - public float GetEffort() + public float GetForce(int index = 0) { - var drive = GetDrive(); - var F = drive.stiffness * (GetJointPosition() - drive.target) - drive.damping * (GetJointVelocity() - drive.targetVelocity); - // Debug.Log(_jointBody.name + ": Calculated force = " + F); - return F; + index = GetValidIndex(index); + var value = (_jointBody == null || index == -1) ? 0 : _jointBody.driveForce[index]; + return value; } /// angular velocity in degrees per second OR target position diff --git a/Assets/Scripts/Devices/Modules/Base/DeviceHelper.cs b/Assets/Scripts/Devices/Modules/Base/DeviceHelper.cs index 629bb403..5fda92e3 100644 --- a/Assets/Scripts/Devices/Modules/Base/DeviceHelper.cs +++ b/Assets/Scripts/Devices/Modules/Base/DeviceHelper.cs @@ -155,6 +155,13 @@ public static float CurveOrientation(in float value) { return -value; } + + public static float PrismaticDirection(in float value, in Vector3 rotation) + { + return (Mathf.Approximately(rotation.x, 180) || + Mathf.Approximately(rotation.y, 180) || + Mathf.Approximately(rotation.z, 180)) ? -value : value; + } } public static Vector3[] SolveConvexHull2D(in Vector3[] points) diff --git a/Assets/Scripts/Devices/Modules/Motor.cs b/Assets/Scripts/Devices/Modules/Motor.cs index 9e100591..0bc35c99 100644 --- a/Assets/Scripts/Devices/Modules/Motor.cs +++ b/Assets/Scripts/Devices/Modules/Motor.cs @@ -45,8 +45,8 @@ public void Wait() public class MotorMotionFeedback { - public float compensatingVelocityIncrease = 0.20f; - public float compensatingVelocityDecrease = 0.60f; + public const float CompensatingVelocityIncrease = 0.10f; + public const float CompensatingVelocityDecrease = 0.50f; private bool _isRotating = false; private float _currentTwistAngularVelocity = 0; @@ -84,12 +84,12 @@ public float Compensate() { if (IsTargetReached() == false) { - _compensateValue += compensatingVelocityIncrease; + _compensateValue += CompensatingVelocityIncrease; // Debug.Log("_test: it is low speed, " + _currentTwistAngularVelocity + " < " + _targetTwistAngularVelocity); } else { - _compensateValue -= compensatingVelocityDecrease; + _compensateValue -= CompensatingVelocityDecrease; if (_compensateValue < 0) { @@ -125,7 +125,7 @@ public Motor(in GameObject gameObject) public void SetPID(in float pFactor, in float iFactor, in float dFactor) { - _pidControl = new PID(pFactor, iFactor, dFactor, 50, -50, 300, -300); + _pidControl = new PID(pFactor, iFactor, dFactor, 10, -10, 100, -100); } /// Get Current Joint Velocity @@ -173,8 +173,6 @@ public void Update(in float duration) } _currentMotorVelocity = GetMotorVelocity(duration); - // Debug.LogFormat("joint vel({0}) accel({1}) force({2}) friction({3}) pos({4})", - // Body.jointVelocity[0], Body.jointAcceleration[0], Body.jointForce[0], Body.jointFriction, Body.jointPosition[0]); // do stop motion of motor when motor disabled if (_enableMotor) diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index f59a84c1..7e54a8dc 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -10,7 +10,7 @@ "url": "https://packages.unity.com" }, "com.unity.burst": { - "version": "1.8.9", + "version": "1.8.10", "depth": 1, "source": "registry", "dependencies": { @@ -58,7 +58,16 @@ "com.unity.mathematics": "1.2.1", "com.unity.burst": "1.8.9", "com.unity.render-pipelines.core": "14.0.9", - "com.unity.shadergraph": "14.0.9" + "com.unity.shadergraph": "14.0.9", + "com.unity.render-pipelines.universal-config": "14.0.9" + } + }, + "com.unity.render-pipelines.universal-config": { + "version": "14.0.9", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.render-pipelines.core": "14.0.9" } }, "com.unity.robotics.vhacd": { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 5a4e328b..4356d57c 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -136,7 +136,7 @@ PlayerSettings: vulkanEnableLateAcquireNextImage: 0 vulkanEnableCommandBufferRecycling: 1 loadStoreDebugModeEnabled: 0 - bundleVersion: 4.2.0 + bundleVersion: 4.2.1 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -385,7 +385,6 @@ PlayerSettings: switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 switchEnableFileSystemTrace: 0 - switchUseGOLDLinker: 0 switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index e4eac159..da671891 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.12f1 -m_EditorVersionWithRevision: 2022.3.12f1 (4fe6e059c7ef) +m_EditorVersion: 2022.3.14f1 +m_EditorVersionWithRevision: 2022.3.14f1 (eff2de9070d8) diff --git a/README.md b/README.md index d6c0abab..9a071049 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ if `` element of `