Add cozmomovement script; Adjust feature vectors for the brain

This commit is contained in:
Tobi
2019-04-17 16:52:29 +02:00
parent 1c22f4835e
commit c40daab5fd
14 changed files with 734 additions and 14 deletions
+3 -2
View File
@@ -15,13 +15,14 @@ MonoBehaviour:
brainParameters:
vectorObservationSize: 0
numStackedVectorObservations: 1
vectorActionSize: 01000000
vectorActionSize: 0300000003000000
cameraResolutions:
- width: 84
height: 84
blackAndWhite: 1
vectorActionDescriptions:
-
- forward
- rotate
vectorActionSpaceType: 0
model: {fileID: 0}
inferenceDevice: 0
+49 -5
View File
@@ -130,7 +130,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!65 &99578046
BoxCollider:
m_ObjectHideFlags: 0
@@ -284,7 +284,7 @@ GameObject:
- component: {fileID: 589453882}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -377,7 +377,8 @@ MonoBehaviour:
broadcastHub:
broadcastingBrains:
- {fileID: 11400000, guid: 94e62c225e4fe8148a7543c5fd1acfd4, type: 2}
_brainsToControl: []
_brainsToControl:
- {fileID: 11400000, guid: 94e62c225e4fe8148a7543c5fd1acfd4, type: 2}
maxSteps: 0
trainingConfiguration:
width: 80
@@ -471,7 +472,7 @@ PrefabInstance:
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.5
value: 0.332
objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
@@ -481,7 +482,7 @@ PrefabInstance:
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.5
value: -0.199
objectReference: {fileID: 0}
- target: {fileID: 7570006595835424293, guid: 0f97dac5215d69a4795763340d82925d,
type: 3}
@@ -557,3 +558,46 @@ MonoBehaviour:
resetOnDone: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 1
--- !u!65 &7570006596986120126
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7570006596986120123}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 0.05, y: 0.07, z: 0.08}
m_Center: {x: 0, y: 0.035, z: 0}
--- !u!54 &7570006596986120127
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7570006596986120123}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 84
m_CollisionDetection: 0
--- !u!114 &7570006596986120128
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7570006596986120123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2056048a78a0cc4c97e7899ba1c0e31, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Speed: 0.1
m_TurnSpeed: 50
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8400d2753da4d924bbdb3537db7363ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+90
View File
@@ -0,0 +1,90 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CozmoMovement : MonoBehaviour
{
public float m_Speed = 12f; // How fast the tank moves forward and back.
public float m_TurnSpeed = 180f; // How fast the tank turns in degrees per second.
private string m_MovementAxisName; // The name of the input axis for moving forward and back.
private string m_TurnAxisName; // The name of the input axis for turning.
private Rigidbody m_Rigidbody; // Reference used to move the tank.
private float m_MovementInputValue; // The current value of the movement input.
private float m_TurnInputValue; // The current value of the turn input.
private void Awake()
{
m_Rigidbody = GetComponent<Rigidbody>();
}
private void OnEnable()
{
// When the tank is turned on, make sure it's not kinematic.
m_Rigidbody.isKinematic = false;
// Also reset the input values.
m_MovementInputValue = 0f;
m_TurnInputValue = 0f;
}
private void OnDisable()
{
// When the tank is turned off, set it to kinematic so it stops moving.
m_Rigidbody.isKinematic = true;
}
private void Start()
{
// The axes names are based on player number.
m_MovementAxisName = "Vertical";
m_TurnAxisName = "Horizontal";
}
private void Update()
{
// Store the value of both input axes.
m_MovementInputValue = Input.GetAxis(m_MovementAxisName);
m_TurnInputValue = Input.GetAxis(m_TurnAxisName);
}
private void FixedUpdate()
{
// Adjust the rigidbodies position and orientation in FixedUpdate.
Move();
Turn();
}
private void Move()
{
// Create a vector in the direction the tank is facing with a magnitude based on the input, speed and the time between frames.
Vector3 movement = transform.forward * m_MovementInputValue * m_Speed * Time.deltaTime;
// Apply this movement to the rigidbody's position.
m_Rigidbody.MovePosition(m_Rigidbody.position + movement);
}
private void Turn()
{
// Determine the number of degrees to be turned based on the input, speed and time between frames.
float turn = m_TurnInputValue * m_TurnSpeed * Time.deltaTime;
// Make this into a rotation in the y axis.
Quaternion turnRotation = Quaternion.Euler(0f, turn, 0f);
// Apply this rotation to the rigidbody's rotation.
m_Rigidbody.MoveRotation(m_Rigidbody.rotation * turnRotation);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2056048a78a0cc4c97e7899ba1c0e31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: