Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if no joints on Root Body #5387

Merged
merged 3 commits into from May 24, 2021
Merged

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented May 24, 2021

Proposed change(s)

If there are no joints on a Rigid Body, the Rigid Body Sensor won't generate any useful observations, just identity values (unless there's a Virtual Root set, and that's different from the RB's GameObject). This adds a warning to the inspector in that case.

image

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix

Checklist

@chriselion chriselion requested a review from ervteng May 24, 2021 21:50
@Hunter-Unity Hunter-Unity self-requested a review May 24, 2021 22:16
Copy link
Collaborator

@Hunter-Unity Hunter-Unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i opened walker and added a RigidBodySensorComponent the WalkerRagdoll gameobject and it generates null refs when a RootBody isn't specified

NullReferenceException: Object reference not set to an instance of an object Unity.MLAgents.Extensions.Sensors.RigidBodySensorComponent.IsTrivial () (at /Users/brandonh/unity_projects/ml-agents-master/ml-agents/com.unity.ml-agents.extensions/Runtime/Sensors/RigidBodySensorComponent.cs:97) Unity.MLAgents.Extensions.Editor.RigidBodySensorComponentEditor.OnInspectorGUI () (at /Users/brandonh/unity_projects/ml-agents-master/ml-agents/com.unity.ml-agents.extensions/Editor/RigidBodySensorComponentEditor.cs:19) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /Users/bokken/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:527) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)

Copy link
Collaborator

@Hunter-Unity Hunter-Unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed null ref error is gone. looks good.


internal bool IsTrivial()
{
var joints = RootBody.GetComponentsInChildren<Joint>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either need to null check RootBody, or if it's null maybe we just transform.GetComponentsInChildren<Joint>();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the null-check above, so RootBody will always be non-null here.

@chriselion chriselion merged commit 4390c85 into main May 24, 2021
@delete-merged-branch delete-merged-branch bot deleted the MLA-1955-RB-sensor-warn-no-joints branch May 24, 2021 23:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants