Browse Source

Implemented Academy / Set GoalPoint / Bug: Training does not move agents

Development
Tobi 5 years ago
parent
commit
e3482a3eab

+ 1
- 1
Assets/Materials/GroundMaterial.mat View File

@@ -40,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 199bbc3b06fa73149b6e1ad35ae6d936, type: 3}
m_Texture: {fileID: 2800000, guid: e2f202a27eca89449af658ee823922fb, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:

+ 82
- 4
Assets/Scenes/CozmoTraining.unity View File

@@ -143,6 +143,8 @@ Transform:
- {fileID: 1159195261}
- {fileID: 1863707381}
- {fileID: 380448017}
- {fileID: 2078653368}
- {fileID: 435986020}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -437,6 +439,50 @@ Transform:
m_Father: {fileID: 99578049}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &435986019
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 435986020}
- component: {fileID: 435986021}
m_Layer: 0
m_Name: GoalPoint
m_TagString: Goal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &435986020
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 435986019}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.314, y: 0, z: 0.52}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 99578049}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &435986021
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 435986019}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.1, y: 0.1, z: 0.1}
m_Center: {x: 0, y: 0, z: 0.030643802}
--- !u!1 &589453881
GameObject:
m_ObjectHideFlags: 0
@@ -960,7 +1006,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 0d9d5ce547064a648b466ad7f208cf3d, type: 2}
_brainsToControl:
- {fileID: 0}
maxSteps: 0
- {fileID: 11400000, guid: 0d9d5ce547064a648b466ad7f208cf3d, type: 2}
maxSteps: 1000
trainingConfiguration:
width: 84
height: 84
@@ -975,6 +1022,8 @@ MonoBehaviour:
targetFrameRate: 60
resetParameters:
resetParameters: []
cozmo: {fileID: 7570006596986120123}
startPoint: {fileID: 2078653368}
--- !u!4 &998256474
Transform:
m_ObjectHideFlags: 0
@@ -1540,6 +1589,36 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1863707380}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &2078653367
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2078653368}
m_Layer: 0
m_Name: StartPoint
m_TagString: Untagged
m_Icon: {fileID: 3936346786652291628, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2078653368
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2078653367}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.52}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 99578049}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &7570006596986120122
PrefabInstance:
m_ObjectHideFlags: 0
@@ -1566,7 +1645,7 @@ PrefabInstance:
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.42
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
@@ -1576,7 +1655,7 @@ PrefabInstance:
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
propertyPath: m_LocalPosition.z
value: -0.529
value: -0.52
objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
@@ -1659,7 +1738,6 @@ MonoBehaviour:
onDemandDecision: 1
numberOfActionsBetweenDecisions: 1
renderCamera: {fileID: 891713640}
academy: {fileID: 998256473}
movement: {fileID: 7570006596986120128}
timeBetweenDecisionsAtInference: 0.15
--- !u!65 &7570006596986120126

+ 3
- 1
Assets/Scripts/CannyEdgeDetection/ImageProcessor.cs View File

@@ -134,10 +134,12 @@ public class ImageProcessor : MonoBehaviour
Moments m = new Moments(processedImage, true);
CenterOfGravity = new Point(m.M10 / m.M00, m.M01 / m.M00);

#if UNITY_EDITOR
// show the image with a point mark at the centroid
Cv2.Circle(processedImage, CenterOfGravity, 5, new Scalar(128, 0, 0), -1);
Cv2.Flip(processedImage, processedImage, FlipMode.X);
Cv2.ImShow("Image with center", processedImage);
//Cv2.WaitKey(0);
#endif
}

}

+ 17
- 1
Assets/Scripts/ML Cozmo/CozmoAcademy.cs View File

@@ -5,5 +5,21 @@ using UnityEngine;

public class CozmoAcademy : Academy
{
public GameObject cozmo;
public Transform startPoint;
//public bool testAcademyReset = false;

public override void AcademyReset()
{
cozmo.transform.position = startPoint.position;
}

//private void Update()
//{
// if (testAcademyReset)
// {
// AcademyReset();
// testAcademyReset = !testAcademyReset;
// }
//}
}

+ 9
- 0
Assets/Scripts/ML Cozmo/CozmoAgent.cs View File

@@ -112,6 +112,15 @@ public class CozmoAgent : Agent
}


private void OnTriggerEnter(Collider other)
{
if (other.transform.CompareTag("Goal"))
{
print("Collission");
Done();
}
}

private void WaitTimeInference()
{
if (renderCamera != null)

BIN
Assets/Textures/Ground/SimpleWay.png View File


+ 88
- 0
Assets/Textures/Ground/SimpleWay.png.meta View File

@@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: e2f202a27eca89449af658ee823922fb
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

+ 6
- 6
Assets/UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs View File

@@ -10,7 +10,7 @@ public class GridAgent : Agent
public float timeBetweenDecisionsAtInference;
private float timeSinceDecision;

[Tooltip("Because we want an observation right before making a decision, we can force " +
[Tooltip("Because we want an observation right before making a decision, we can force " +
"a camera to render before making a decision. Place the agentCam here if using " +
"RenderTexture as observations.")]
public Camera renderCamera;
@@ -48,8 +48,8 @@ public class GridAgent : Agent
private void SetMask()
{
// Prevents the agent from picking an action that would make it collide with a wall
var positionX = (int) transform.position.x;
var positionZ = (int) transform.position.z;
var positionX = (int)transform.position.x;
var positionZ = (int)transform.position.z;
var maxPosition = academy.gridSize - 1;

if (positionX == 0)
@@ -108,17 +108,17 @@ public class GridAgent : Agent

if (blockTest.Where(col => col.gameObject.CompareTag("goal")).ToArray().Length == 1)
{
Done();
SetReward(1f);
}
if (blockTest.Where(col => col.gameObject.CompareTag("pit")).ToArray().Length == 1)
{
Done();
SetReward(-1f);
}
}
}


// to be implemented by the developer
public override void AgentReset()
{
@@ -132,7 +132,7 @@ public class GridAgent : Agent

private void WaitTimeInference()
{
if(renderCamera != null)
if (renderCamera != null)
{
renderCamera.Render();
}

+ 6064
- 0
Notebooks/UnitySDK.log
File diff suppressed because it is too large
View File


+ 1030
- 5
Notebooks/getting-started.ipynb
File diff suppressed because it is too large
View File


+ 2
- 1
ProjectSettings/TagManager.asset View File

@@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Goal
layers:
- Default
- TransparentFX

Loading…
Cancel
Save