diff --git a/Assets/ML-Agents/packerhand/Scenes/Test_30.unity b/Assets/ML-Agents/packerhand/Scenes/Test_30.unity index 48cf61b9..d7bc15dd 100644 --- a/Assets/ML-Agents/packerhand/Scenes/Test_30.unity +++ b/Assets/ML-Agents/packerhand/Scenes/Test_30.unity @@ -1289,6 +1289,7 @@ PrefabInstance: objectReference: {fileID: 2100000, guid: 1644c0cb0c67e314194579be857f87da, type: 2} m_RemovedComponents: - {fileID: 2674329426616174709, guid: 2f2c1469c0f2c8453ab01d6d68f6526f, type: 3} + - {fileID: 6303212369219772044, guid: 2f2c1469c0f2c8453ab01d6d68f6526f, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: diff --git a/Assets/ML-Agents/packerhand/Scenes/Test_412.unity b/Assets/ML-Agents/packerhand/Scenes/Test_412.unity index af30ddf8..a2e82882 100644 --- a/Assets/ML-Agents/packerhand/Scenes/Test_412.unity +++ b/Assets/ML-Agents/packerhand/Scenes/Test_412.unity @@ -572,7 +572,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: agent: {fileID: 0} - parent_mf: {fileID: 0} isCollidedGreen: 0 isCollidedBlue: 0 isCollidedRed: 0 @@ -748,7 +747,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: agent: {fileID: 0} - parent_mf: {fileID: 0} isCollidedGreen: 0 isCollidedBlue: 0 isCollidedRed: 0 @@ -1291,6 +1289,7 @@ PrefabInstance: objectReference: {fileID: 2100000, guid: 1644c0cb0c67e314194579be857f87da, type: 2} m_RemovedComponents: - {fileID: 2674329426616174709, guid: 2f2c1469c0f2c8453ab01d6d68f6526f, type: 3} + - {fileID: 6303212369219772044, guid: 2f2c1469c0f2c8453ab01d6d68f6526f, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: @@ -1447,7 +1446,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: agent: {fileID: 0} - parent_mf: {fileID: 0} isCollidedGreen: 0 isCollidedBlue: 0 isCollidedRed: 0 diff --git a/Assets/ML-Agents/packerhand/Scripts/PackerHand.cs b/Assets/ML-Agents/packerhand/Scripts/PackerHand.cs index f8304de0..ccb2f213 100644 --- a/Assets/ML-Agents/packerhand/Scripts/PackerHand.cs +++ b/Assets/ML-Agents/packerhand/Scripts/PackerHand.cs @@ -43,7 +43,7 @@ public class PackerHand : Agent public Vector3 [] verticesArray; // space: 2n + 1 Vector3 vertices where n = num boxes [HideInInspector] public int selectedVertexIdx = -1; [HideInInspector] private List boxPool; // space: num boxes - [HideInInspector] private List vertexIndices; + [HideInInspector] private List maskedVertexIndices; [HideInInspector] public List organizedBoxes; // list of organzed box indices [HideInInspector] public List historicalVerticesLog; [HideInInspector] public int VertexCount = 0; @@ -66,7 +66,7 @@ public class PackerHand : Agent [HideInInspector] public bool isEpisodeStart; [HideInInspector] public bool isAfterOriginVertexSelected; //[HideInInspector] public bool isBlackboxUpdated; - public bool isVertexSelected; + // public bool isVertexSelected; public bool isBoxSelected; public bool isRotationSelected; public bool isPickedup; @@ -174,7 +174,7 @@ public override void OnEpisodeBegin() boxSpawner.SetUpBoxes(m_ResetParams.GetWithDefault("regular_box", 0)); selectedVertex = origin; // refactor to select first vertex - isVertexSelected = true; + // isVertexSelected = true; //SetResetParameters(); @@ -214,7 +214,7 @@ public override void CollectObservations(VectorSensor sensor) // Add array of vertices (selected vertices are 0s) int i = 0; - vertexIndices = new List(); + maskedVertexIndices = new List(); foreach (Vector3 vertex in verticesArray) { Vector3 scaled_continuous_vertex = new Vector3(((vertex.x - origin.x)/binscale_x), ((vertex.y - origin.y)/binscale_y), ((vertex.z - origin.z)/binscale_z)); @@ -227,7 +227,7 @@ public override void CollectObservations(VectorSensor sensor) if (vertex == Vector3.zero) { //Debug.Log($"MASK VERTEX LOOP INDEX:{i}"); - vertexIndices.Add(i); + maskedVertexIndices.Add(i); } i++; } @@ -251,7 +251,7 @@ public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { // vertices action mask if (isAfterOriginVertexSelected) { - foreach (int vertexIdx in vertexIndices) + foreach (int vertexIdx in maskedVertexIndices) { //Debug.Log($"MASK VERTEX {vertexIdx}"); actionMask.SetActionEnabled(0, vertexIdx, false); @@ -652,7 +652,7 @@ public void SelectVertex(int action_SelectedVertex) selectedVertex = new Vector3(((unscaled_selectedVertex.x* binscale_x) + origin.x), ((unscaled_selectedVertex.y* binscale_y) + origin.y), ((unscaled_selectedVertex.z* binscale_z) + origin.z)); Debug.Log($"SVX Selected VerteX: {selectedVertex}"); - isVertexSelected = true; + // isVertexSelected = true; //AddReward(1f); // Debug.Log($"RWD {GetCumulativeReward()} total reward | +1 reward from isVertexSelected: {isVertexSelected}"); } @@ -1136,36 +1136,38 @@ public void ReverseSideNames(int id) } - public void BoxReset(string cause) - { - if (cause == "failedPhysicsCheck") - { - Debug.Log($"SCS BOX {selectedBoxIdx} RESET LOOP, BOX POOL COUNT IS {boxPool.Count}"); - // detach box from agent - targetBox.parent = null; - // add back rigidbody and collider - Rigidbody rb = boxPool[selectedBoxIdx].rb; - BoxCollider bc = boxPool[selectedBoxIdx].rb.gameObject.AddComponent(); - // not be affected by forces or collisions, position and rotation will be controlled directly through script - rb.isKinematic = true; - // reset to starting position - rb.transform.localScale = boxPool[selectedBoxIdx].startingSize; - rb.transform.rotation = boxPool[selectedBoxIdx].startingRot; - rb.transform.position = boxPool[selectedBoxIdx].startingPos; - ReverseSideNames(selectedBoxIdx); - // remove from organized list to be picked again - organizedBoxes.Remove(selectedBoxIdx); - // reset states - StateReset(); - // REQUEST DECISION FOR THE NEXT ROUND OF PICKING - GetComponent().RequestDecision(); - Academy.Instance.EnvironmentStep(); - // settting isBlackboxUpdated to true allows another vertex to be selected - //isBlackboxUpdated = true; - // setting isVertexSelected to true keeps the current vertex and allows another box to be selected - // isVertexSelected = true; - } - } +// public void BoxReset(string cause) +// { +// if (cause == "failedPhysicsCheck") +// { +// Debug.Log($"SCS BOX {selectedBoxIdx} RESET LOOP, BOX POOL COUNT IS {boxPool.Count}"); +// // detach box from agent +// targetBox.parent = null; +// // add back rigidbody and collider +// Rigidbody rb = boxPool[selectedBoxIdx].rb; +// BoxCollider bc = boxPool[selectedBoxIdx].rb.gameObject.AddComponent(); +// // not be affected by forces or collisions, position and rotation will be controlled directly through script +// rb.isKinematic = true; +// // reset to starting position +// rb.transform.localScale = boxPool[selectedBoxIdx].startingSize; +// rb.transform.rotation = boxPool[selectedBoxIdx].startingRot; +// rb.transform.position = boxPool[selectedBoxIdx].startingPos; +// ReverseSideNames(selectedBoxIdx); +// // remove from organized list to be picked again +// // to "be picked again" means to be added back to the boxPool?? +// organizedBoxes.Remove(selectedBoxIdx); +// // reset states +// StateReset(); +// // REQUEST DECISION FOR THE NEXT ROUND OF PICKING +// // Why is the DecisionRequester() still active in the Hand gameObject? +// GetComponent().RequestDecision(); +// Academy.Instance.EnvironmentStep(); +// // settting isBlackboxUpdated to true allows another vertex to be selected +// //isBlackboxUpdated = true; +// // setting isVertexSelected to true keeps the current vertex and allows another box to be selected +// // isVertexSelected = true; +// } +// } public void AgentReset() @@ -1200,7 +1202,7 @@ public void StateReset() boxPool[selectedBoxIdx].boxRot = default_rotation; } //isBlackboxUpdated = false; - isVertexSelected = false; + // isVertexSelected = false; isBoxSelected = false; isRotationSelected = false; isPickedup = false;