浏览代码
Revamp Crawler & Walker (#841)
Revamp Crawler & Walker (#841)
* Revamps agent code for walker and crawler environments to use shared JointDriveController system. * Crawler has been reworked to be very cute. * Crawler & Walker environments have been reworked to be visually consistent. * Added Dynamic Crawler scene. * All scenes re-trained and new models added. * Documentation changes./develop-generalizationTraining-TrainerController
GitHub
7 年前
当前提交
c9c9e147
共有 104 个文件被更改,包括 11335 次插入 和 3314 次删除
-
1.gitignore
-
13docs/Learning-Environment-Examples.md
-
999docs/images/crawler.png
-
999docs/images/walker.png
-
7python/trainer_config.yaml
-
5unity-environment/Assets/ML-Agents/Examples/Crawler.meta
-
2unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs.meta
-
881unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab.meta
-
2unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts.meta
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs.meta
-
5unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Agent.mat.meta
-
15unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Black.mat.meta
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Block.mat.meta
-
6unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/BlueAgent.mat
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerGoal.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerMany.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerRectangle.mat.meta
-
16unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerSquare.mat
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/FailGround.mat.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Goal.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Grass.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ground.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Obstacle.mat.meta
-
2unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/SuccessGround.mat.meta
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/UIDefault.mat.meta
-
12unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat
-
4unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat.meta
-
32unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs
-
5unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs.meta
-
132unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerAgent.prefab
-
935unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
-
6unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs
-
237unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
-
985unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
-
2unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes.meta
-
1unity-environment/ProjectSettings/EditorBuildSettings.asset
-
14unity-environment/ProjectSettings/ProjectSettings.asset
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes.meta
-
269unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
-
13unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat.meta
-
3unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png
-
84unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png.meta
-
195unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd
-
84unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat
-
8unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat.meta
-
58unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs.meta
-
178unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs.meta
-
40unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs
-
11unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs.meta
-
76unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat.meta
-
180unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab
-
8unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab.meta
-
76unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat.meta
-
76unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
-
7unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity.meta
-
1001unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity
-
8unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity.meta
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs.meta
-
19unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs.meta
-
21unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs
-
12unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs.meta
-
137unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs
999
docs/images/crawler.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
999
docs/images/walker.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: f156237910cf946e78a82c48410fef52 |
|||
guid: 3aea709eb8dc04856aaa6d93573fb0df |
|||
timeCreated: 1517447132 |
|||
licenseType: Free |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
881
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 3db4283e33af74336bfedb01d0e011bf |
|||
timeCreated: 1508548205 |
|||
licenseType: Free |
|||
guid: 0e8a62cb7c8f0483ebd12046bae9ca05 |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4a3b975c6f9424f52aa1d7b9b87b6e1a |
|||
guid: 0b737d19c4232404389d1325808e5b4d |
|||
timeCreated: 1508478093 |
|||
licenseType: Free |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 260483cdfc6b14e26823a02f23bd8baa |
|||
timeCreated: 1506189720 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: edd958d75ed1448138de86f3335ea4fa |
|||
timeCreated: 1497123463 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: f4abcb290251940948a31b349a6f9995 |
|||
timeCreated: 1506379314 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 624b24bbec31f44babfb57ef2dfbc537 |
|||
timeCreated: 1506189863 |
|||
licenseType: Pro |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 463606e709fd24f29ac1096d0aade647 |
|||
timeCreated: 1503267725 |
|||
licenseType: Free |
|||
mainObjectFileID: 2100000 |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 214660f4189b04cada2137381f5c3607 |
|||
timeCreated: 1497379290 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
935
unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
985
unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 6f158a795796a47a68104cc5eff941a1 |
|||
guid: 8d3f9a4b927984343b18c82559165047 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1b2e258570af540139c1ef84be60b3ea |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 0058b366f9d6d44a3ba35beb06b0174b |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 1b9d167a4e71146a883212e4f08bda88 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 100100000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 60c86839d191546c9bf58ce6a2824987 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using MLAgents; |
|||
|
|||
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
|
|||
public class CrawlerAgent : Agent |
|||
{ |
|||
[Header("Target To Walk Towards")] [Space(10)] |
|||
public Transform target; |
|||
|
|||
public Transform ground; |
|||
public bool detectTargets; |
|||
public bool respawnTargetWhenTouched; |
|||
public float targetSpawnRadius; |
|||
|
|||
[Header("Body Parts")] [Space(10)] public Transform body; |
|||
public Transform leg0Upper; |
|||
public Transform leg0Lower; |
|||
public Transform leg1Upper; |
|||
public Transform leg1Lower; |
|||
public Transform leg2Upper; |
|||
public Transform leg2Lower; |
|||
public Transform leg3Upper; |
|||
public Transform leg3Lower; |
|||
|
|||
[Header("Joint Settings")] [Space(10)] JointDriveController jdController; |
|||
Vector3 dirToTarget; |
|||
float movingTowardsDot; |
|||
float facingDot; |
|||
|
|||
[Header("Reward Functions To Use")] [Space(10)] |
|||
public bool rewardMovingTowardsTarget; // Agent should move towards target
|
|||
|
|||
public bool rewardFacingTarget; // Agent should face the target
|
|||
public bool rewardUseTimePenalty; // Hurry up
|
|||
|
|||
[Header("Foot Grounded Visualization")] [Space(10)] |
|||
public bool useFootGroundedVisualization; |
|||
|
|||
public MeshRenderer foot0; |
|||
public MeshRenderer foot1; |
|||
public MeshRenderer foot2; |
|||
public MeshRenderer foot3; |
|||
public Material groundedMaterial; |
|||
public Material unGroundedMaterial; |
|||
bool isNewDecisionStep; |
|||
int currentDecisionStep; |
|||
|
|||
public override void InitializeAgent() |
|||
{ |
|||
jdController = GetComponent<JointDriveController>(); |
|||
currentDecisionStep = 1; |
|||
|
|||
//Setup each body part
|
|||
jdController.SetupBodyPart(body); |
|||
jdController.SetupBodyPart(leg0Upper); |
|||
jdController.SetupBodyPart(leg0Lower); |
|||
jdController.SetupBodyPart(leg1Upper); |
|||
jdController.SetupBodyPart(leg1Lower); |
|||
jdController.SetupBodyPart(leg2Upper); |
|||
jdController.SetupBodyPart(leg2Lower); |
|||
jdController.SetupBodyPart(leg3Upper); |
|||
jdController.SetupBodyPart(leg3Lower); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// We only need to change the joint settings based on decision freq.
|
|||
/// </summary>
|
|||
public void IncrementDecisionTimer() |
|||
{ |
|||
if (currentDecisionStep == agentParameters.numberOfActionsBetweenDecisions |
|||
|| agentParameters.numberOfActionsBetweenDecisions == 1) |
|||
{ |
|||
currentDecisionStep = 1; |
|||
isNewDecisionStep = true; |
|||
} |
|||
else |
|||
{ |
|||
currentDecisionStep++; |
|||
isNewDecisionStep = false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Add relevant information on each body part to observations.
|
|||
/// </summary>
|
|||
public void CollectObservationBodyPart(BodyPart bp) |
|||
{ |
|||
var rb = bp.rb; |
|||
AddVectorObs(bp.groundContact.touchingGround ? 1 : 0); // Whether the bp touching the ground
|
|||
AddVectorObs(rb.velocity); |
|||
AddVectorObs(rb.angularVelocity); |
|||
|
|||
if (bp.rb.transform != body) |
|||
{ |
|||
Vector3 localPosRelToBody = body.InverseTransformPoint(rb.position); |
|||
AddVectorObs(localPosRelToBody); |
|||
AddVectorObs(bp.currentXNormalizedRot); // Current x rot
|
|||
AddVectorObs(bp.currentYNormalizedRot); // Current y rot
|
|||
AddVectorObs(bp.currentZNormalizedRot); // Current z rot
|
|||
AddVectorObs(bp.currentStrength / jdController.maxJointForceLimit); |
|||
} |
|||
} |
|||
|
|||
public override void CollectObservations() |
|||
{ |
|||
jdController.GetCurrentJointForces(); |
|||
// Normalize dir vector to help generalize
|
|||
AddVectorObs(dirToTarget.normalized); |
|||
|
|||
// Forward & up to help with orientation
|
|||
AddVectorObs(body.transform.position.y); |
|||
AddVectorObs(body.forward); |
|||
AddVectorObs(body.up); |
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
CollectObservationBodyPart(bodyPart); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Agent touched the target
|
|||
/// </summary>
|
|||
public void TouchedTarget() |
|||
{ |
|||
AddReward(1f); |
|||
if (respawnTargetWhenTouched) |
|||
{ |
|||
GetRandomTargetPos(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Moves target to a random position within specified radius.
|
|||
/// </summary>
|
|||
public void GetRandomTargetPos() |
|||
{ |
|||
Vector3 newTargetPos = Random.insideUnitSphere * targetSpawnRadius; |
|||
newTargetPos.y = 5; |
|||
target.position = newTargetPos + ground.position; |
|||
} |
|||
|
|||
public override void AgentAction(float[] vectorAction, string textAction) |
|||
{ |
|||
if (detectTargets) |
|||
{ |
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
if (bodyPart.targetContact && !IsDone() && bodyPart.targetContact.touchingTarget) |
|||
{ |
|||
TouchedTarget(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Update pos to target
|
|||
dirToTarget = target.position - jdController.bodyPartsDict[body].rb.position; |
|||
|
|||
// If enabled the feet will light up green when the foot is grounded.
|
|||
// This is just a visualization and isn't necessary for function
|
|||
if (useFootGroundedVisualization) |
|||
{ |
|||
foot0.material = jdController.bodyPartsDict[leg0Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot1.material = jdController.bodyPartsDict[leg1Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot2.material = jdController.bodyPartsDict[leg2Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
foot3.material = jdController.bodyPartsDict[leg3Lower].groundContact.touchingGround |
|||
? groundedMaterial |
|||
: unGroundedMaterial; |
|||
} |
|||
|
|||
// Joint update logic only needs to happen when a new decision is made
|
|||
if (isNewDecisionStep) |
|||
{ |
|||
// The dictionary with all the body parts in it are in the jdController
|
|||
var bpDict = jdController.bodyPartsDict; |
|||
|
|||
int i = -1; |
|||
// Pick a new target joint rotation
|
|||
bpDict[leg0Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg1Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg2Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg3Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0); |
|||
bpDict[leg0Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg1Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg2Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
bpDict[leg3Lower].SetJointTargetRotation(vectorAction[++i], 0, 0); |
|||
|
|||
// Update joint strength
|
|||
bpDict[leg0Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg1Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg2Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg3Upper].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg0Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg1Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg2Lower].SetJointStrength(vectorAction[++i]); |
|||
bpDict[leg3Lower].SetJointStrength(vectorAction[++i]); |
|||
} |
|||
|
|||
// Set reward for this step according to mixture of the following elements.
|
|||
if (rewardMovingTowardsTarget) |
|||
{ |
|||
RewardFunctionMovingTowards(); |
|||
} |
|||
|
|||
if (rewardFacingTarget) |
|||
{ |
|||
RewardFunctionFacingTarget(); |
|||
} |
|||
|
|||
if (rewardUseTimePenalty) |
|||
{ |
|||
RewardFunctionTimePenalty(); |
|||
} |
|||
|
|||
IncrementDecisionTimer(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Reward moving towards target & Penalize moving away from target.
|
|||
/// </summary>
|
|||
void RewardFunctionMovingTowards() |
|||
{ |
|||
movingTowardsDot = Vector3.Dot(jdController.bodyPartsDict[body].rb.velocity, dirToTarget.normalized); |
|||
AddReward(0.03f * movingTowardsDot); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Reward facing target & Penalize facing away from target
|
|||
/// </summary>
|
|||
void RewardFunctionFacingTarget() |
|||
{ |
|||
facingDot = Vector3.Dot(dirToTarget.normalized, body.forward); |
|||
AddReward(0.01f * facingDot); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Existential penalty for time-contrained tasks.
|
|||
/// </summary>
|
|||
void RewardFunctionTimePenalty() |
|||
{ |
|||
AddReward(-0.001f); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Loop over body parts and reset them to initial conditions.
|
|||
/// </summary>
|
|||
public override void AgentReset() |
|||
{ |
|||
if (dirToTarget != Vector3.zero) |
|||
{ |
|||
transform.rotation = Quaternion.LookRotation(dirToTarget); |
|||
} |
|||
|
|||
foreach (var bodyPart in jdController.bodyPartsDict.Values) |
|||
{ |
|||
bodyPart.Reset(bodyPart); |
|||
} |
|||
|
|||
isNewDecisionStep = true; |
|||
currentDecisionStep = 1; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2f37c30a5e8d04117947188818902ef3 |
|||
timeCreated: 1525902546 |
|||
licenseType: Free |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 310a6ef92323640b48a7342988a69466 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 24ef4b74625ba4c53b782ec33ad9f7d6 |
|||
TextScriptImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!21 &2100000 |
|||
Material: |
|||
serializedVersion: 6 |
|||
m_ObjectHideFlags: 0 |
|||
m_PrefabParentObject: {fileID: 0} |
|||
m_PrefabInternal: {fileID: 0} |
|||
m_Name: DarkGridFloor |
|||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _BumpMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailAlbedoMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailMask: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _DetailNormalMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MainTex: |
|||
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3} |
|||
m_Scale: {x: 200, y: 100} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _MetallicGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _OcclusionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _ParallaxMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 0 |
|||
- _SrcBlend: 1 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 0, g: 0.7255683, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: f79af4fbbccd341578da68fd5d3c7e0d |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |