浏览代码
Merge pull request #4732 from Unity-Technologies/goal-sensors
Merge pull request #4732 from Unity-Technologies/goal-sensors
Adds SensorTypes and GoalSensors/goal-conditioning
GitHub
4 年前
当前提交
ded1f79b
共有 40 个文件被更改,包括 518 次插入 和 113 次删除
-
6Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/SensorBase.cs
-
6Project/Assets/ML-Agents/TestScenes/TestCompressedTexture/TestTextureSensor.cs
-
6com.unity.ml-agents.extensions/Runtime/Match3/Match3Sensor.cs
-
6com.unity.ml-agents.extensions/Runtime/Sensors/GridSensor.cs
-
6com.unity.ml-agents.extensions/Runtime/Sensors/PhysicsBodySensor.cs
-
1com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
-
50com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/Observation.cs
-
9com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
-
29com.unity.ml-agents/Runtime/Sensors/ISensor.cs
-
6com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs
-
6com.unity.ml-agents/Runtime/Sensors/Reflection/ReflectionSensorBase.cs
-
9com.unity.ml-agents/Runtime/Sensors/RenderTextureSensor.cs
-
6com.unity.ml-agents/Runtime/Sensors/StackingSensor.cs
-
6com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
-
6com.unity.ml-agents/Tests/Editor/Communicator/GrpcExtensionsTests.cs
-
5com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs
-
5com.unity.ml-agents/Tests/Editor/ParameterLoaderTest.cs
-
5com.unity.ml-agents/Tests/Editor/Sensor/FloatVisualSensorTests.cs
-
5com.unity.ml-agents/Tests/Editor/Sensor/SensorShapeValidatorTests.cs
-
6com.unity.ml-agents/Tests/Editor/Sensor/StackingSensorTests.cs
-
4gym-unity/gym_unity/tests/test_gym.py
-
10ml-agents-envs/mlagents_envs/base_env.py
-
51ml-agents-envs/mlagents_envs/communicator_objects/observation_pb2.py
-
25ml-agents-envs/mlagents_envs/communicator_objects/observation_pb2.pyi
-
19ml-agents-envs/mlagents_envs/communicator_objects/unity_to_external_pb2.py
-
81ml-agents-envs/mlagents_envs/communicator_objects/unity_to_external_pb2_grpc.py
-
4ml-agents-envs/mlagents_envs/rpc_utils.py
-
26ml-agents-envs/mlagents_envs/tests/test_rpc_utils.py
-
11ml-agents-envs/mlagents_envs/tests/test_steps.py
-
8ml-agents/mlagents/trainers/tests/mock_brain.py
-
8ml-agents/mlagents/trainers/tests/simple_test_envs.py
-
7ml-agents/mlagents/trainers/tests/tensorflow/test_models.py
-
4ml-agents/mlagents/trainers/tests/tensorflow/test_tf_policy.py
-
45ml-agents/mlagents/trainers/tests/torch/test_reward_providers/test_curiosity.py
-
14ml-agents/mlagents/trainers/tests/torch/test_reward_providers/test_extrinsic.py
-
32ml-agents/mlagents/trainers/tests/torch/test_reward_providers/test_gail.py
-
32ml-agents/mlagents/trainers/tests/torch/test_reward_providers/test_rnd.py
-
7protobuf-definitions/proto/mlagents_envs/communicator_objects/observation.proto
-
48Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs
-
11Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs.meta
|
|||
using Unity.MLAgents.Sensors; |
|||
|
|||
|
|||
public class GoalSensorComponent : SensorComponent |
|||
{ |
|||
public int observationSize; |
|||
public GoalSensor goalSensor; |
|||
/// <summary>
|
|||
/// Creates a GoalSensor.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public override ISensor CreateSensor() |
|||
{ |
|||
goalSensor = new GoalSensor(observationSize); |
|||
return goalSensor; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override int[] GetObservationShape() |
|||
{ |
|||
return new[] { observationSize }; |
|||
} |
|||
|
|||
public void AddGoal(float goal) |
|||
{ |
|||
if (goalSensor != null) |
|||
{ |
|||
goalSensor.AddObservation(goal); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class GoalSensor : VectorSensor |
|||
{ |
|||
|
|||
public GoalSensor(int observationSize, string name = null) : base(observationSize) |
|||
{ |
|||
if (name == null) |
|||
{ |
|||
name = $"GoalSensor_size{observationSize}"; |
|||
} |
|||
} |
|||
|
|||
public override SensorType GetSensorType() |
|||
{ |
|||
return SensorType.Goal; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 163dac4bcbb2f4d8499db2cdcb22a89e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue