Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
RotationSensor.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
5 using UnityEngine;
6 
7 namespace droid.Runtime.Prototyping.Sensors.Transform {
8  [AddComponentMenu(PrototypingComponentMenuPath._ComponentMenuPath + "Observers/Position")]
9  [ExecuteInEditMode]
10  [Serializable]
11  public class RotationSensor : Sensor,
13  [Header("Observation", order = 103)]
14  [SerializeField]
15  Quaternion _rotation;
16 
17  [Header("Specific", order = 102)]
18  [SerializeField]
19  ObservationSpace _space = ObservationSpace.Environment_;
20 
23  public ObservationSpace Space { get { return this._space; } }
24 
28  public override string PrototypingTypeName { get { return "Position"; } }
29 
33  public Quaternion ObservationValue { get { return this._rotation; } set { this._rotation = value; } }
34 
38  public Space4 QuadSpace { get; } = new Space4();
39 
43  protected override void PreSetup() { }
44 
48  public override IEnumerable<float> FloatEnumerable {
49  get { return new[] {this.ObservationValue.x, this.ObservationValue.y, this.ObservationValue.z}; }
50  }
51 
55  public override void UpdateObservation() {
56  if (this.ParentEnvironment != null && this._space == ObservationSpace.Environment_) {
57  this.ObservationValue = this.ParentEnvironment.TransformRotation(this.transform.rotation);
58  } else if (this._space == ObservationSpace.Local_) {
59  this.ObservationValue = this.transform.localRotation;
60  } else {
61  this.ObservationValue = this.transform.rotation;
62  }
63  }
64  }
65 }