浏览代码

Warn if no joints on Root Body (#5387)

/colab-links
GitHub 3 年前
当前提交
0312fcda
共有 4 个文件被更改,包括 32 次插入0 次删除
  1. 10
      com.unity.ml-agents.extensions/Editor/RigidBodySensorComponentEditor.cs
  2. 18
      com.unity.ml-agents.extensions/Runtime/Sensors/RigidBodySensorComponent.cs
  3. 3
      com.unity.ml-agents.extensions/Tests/Runtime/Sensors/RigidBodySensorTests.cs
  4. 1
      com.unity.ml-agents/CHANGELOG.md

10
com.unity.ml-agents.extensions/Editor/RigidBodySensorComponentEditor.cs


so.Update();
var rbSensorComp = so.targetObject as RigidBodySensorComponent;
if (rbSensorComp.IsTrivial())
{
EditorGUILayout.HelpBox(
"The Root Body has no Joints, and the Virtual Root is null or the same as the " +
"Root Body's GameObject. This will not generate any useful observations; they will always " +
"be the identity values. Consider removing this component since it won't help the Agent.",
MessageType.Warning
);
}
bool requireExtractorUpdate;
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());

18
com.unity.ml-agents.extensions/Runtime/Sensors/RigidBodySensorComponent.cs


{
GetPoseExtractor().SetPoseEnabled(index, enabled);
}
internal bool IsTrivial()
{
if (ReferenceEquals(RootBody, null))
{
// It *is* trivial, but this will happen when the sensor is being set up, so don't warn then.
return false;
}
var joints = RootBody.GetComponentsInChildren<Joint>();
if (joints.Length == 0)
{
if (ReferenceEquals(VirtualRoot, null) || ReferenceEquals(VirtualRoot, RootBody.gameObject))
{
return true;
}
}
return false;
}
}
}

3
com.unity.ml-agents.extensions/Tests/Runtime/Sensors/RigidBodySensorTests.cs


var gameObj = new GameObject();
var sensorComponent = gameObj.AddComponent<RigidBodySensorComponent>();
Assert.IsFalse(sensorComponent.IsTrivial());
var sensor = sensorComponent.CreateSensors()[0];
SensorTestHelper.CompareObservation(sensor, new float[0]);
}

UseLocalSpaceTranslations = true,
UseLocalSpaceRotations = true
};
Assert.IsTrue(sensorComponent.IsTrivial());
var sensor = sensorComponent.CreateSensors()[0];
sensor.Update();

UseLocalSpaceLinearVelocity = true
};
sensorComponent.VirtualRoot = virtualRoot;
Assert.IsFalse(sensorComponent.IsTrivial());
var sensor = sensorComponent.CreateSensors()[0];
sensor.Update();

1
com.unity.ml-agents/CHANGELOG.md


#### ml-agents / ml-agents-envs / gym-unity (Python)
- Added a fully connected visual encoder for environments with very small image inputs. (#5351)
### Bug Fixes
- RigidBodySensorComponent now displays a warning if it's used in a way that won't generate useful observations. (#5387)
## [2.0.0-exp.1] - 2021-04-22

正在加载...
取消
保存