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

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

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

- {fileID: 1159195261} - {fileID: 1159195261}
- {fileID: 1863707381} - {fileID: 1863707381}
- {fileID: 380448017} - {fileID: 380448017}
- {fileID: 2078653368}
- {fileID: 435986020}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Father: {fileID: 99578049} m_Father: {fileID: 99578049}
m_RootOrder: 3 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 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 --- !u!1 &589453881
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
- {fileID: 11400000, guid: 0d9d5ce547064a648b466ad7f208cf3d, type: 2} - {fileID: 11400000, guid: 0d9d5ce547064a648b466ad7f208cf3d, type: 2}
_brainsToControl: _brainsToControl:
- {fileID: 0} - {fileID: 0}
maxSteps: 0
- {fileID: 11400000, guid: 0d9d5ce547064a648b466ad7f208cf3d, type: 2}
maxSteps: 1000
trainingConfiguration: trainingConfiguration:
width: 84 width: 84
height: 84 height: 84
targetFrameRate: 60 targetFrameRate: 60
resetParameters: resetParameters:
resetParameters: [] resetParameters: []
cozmo: {fileID: 7570006596986120123}
startPoint: {fileID: 2078653368}
--- !u!4 &998256474 --- !u!4 &998256474
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1863707380} m_GameObject: {fileID: 1863707380}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 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 --- !u!1001 &7570006596986120122
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d, - target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 0.42
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d, - target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3} type: 3}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d, - target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3} type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: -0.529
value: -0.52
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d, - target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3} type: 3}
onDemandDecision: 1 onDemandDecision: 1
numberOfActionsBetweenDecisions: 1 numberOfActionsBetweenDecisions: 1
renderCamera: {fileID: 891713640} renderCamera: {fileID: 891713640}
academy: {fileID: 998256473}
movement: {fileID: 7570006596986120128} movement: {fileID: 7570006596986120128}
timeBetweenDecisionsAtInference: 0.15 timeBetweenDecisionsAtInference: 0.15
--- !u!65 &7570006596986120126 --- !u!65 &7570006596986120126

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

Moments m = new Moments(processedImage, true); Moments m = new Moments(processedImage, true);
CenterOfGravity = new Point(m.M10 / m.M00, m.M01 / m.M00); CenterOfGravity = new Point(m.M10 / m.M00, m.M01 / m.M00);


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

} }

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



public class CozmoAcademy : Academy 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

} }




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

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

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


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

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

public float timeBetweenDecisionsAtInference; public float timeBetweenDecisionsAtInference;
private float timeSinceDecision; 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 " + "a camera to render before making a decision. Place the agentCam here if using " +
"RenderTexture as observations.")] "RenderTexture as observations.")]
public Camera renderCamera; public Camera renderCamera;
private void SetMask() private void SetMask()
{ {
// Prevents the agent from picking an action that would make it collide with a wall // 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; var maxPosition = academy.gridSize - 1;


if (positionX == 0) if (positionX == 0)


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



// to be implemented by the developer // to be implemented by the developer
public override void AgentReset() public override void AgentReset()
{ {


private void WaitTimeInference() private void WaitTimeInference()
{ {
if(renderCamera != null)
if (renderCamera != null)
{ {
renderCamera.Render(); 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

--- !u!78 &1 --- !u!78 &1
TagManager: TagManager:
serializedVersion: 2 serializedVersion: 2
tags: []
tags:
- Goal
layers: layers:
- Default - Default
- TransparentFX - TransparentFX

Loading…
Cancel
Save