Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
QuaternionTransformSensor.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
4 using UnityEngine;
5 
6 namespace droid.Runtime.Prototyping.Sensors.Transform {
10  [AddComponentMenu(SensorComponentMenuPath._ComponentMenuPath
11  + "QuaternionTransform"
12  + SensorComponentMenuPath._Postfix)]
13  [ExecuteInEditMode]
14  [Serializable]
17  [Header("Observation", order = 103)]
18  [SerializeField]
19  Vector3 _position;
20 
21  [SerializeField] Quaternion _rotation;
22 
23  [Header("Specific", order = 102)]
24  [SerializeField]
25  ObservationSpace _space = ObservationSpace.Environment_;
26 
27  [SerializeField] bool _use_environments_coordinates = true;
28 
32  public override string PrototypingTypeName { get { return "QuaternionTransform"; } }
33 
37  public Vector3 Position { get { return this._position; } }
38 
42  public Quaternion Rotation { get { return this._rotation; } }
43 
47  public override IEnumerable<float> FloatEnumerable {
48  get {
49  return new[] {
50  this._position.x,
51  this._position.y,
52  this._position.z,
53  this._rotation.x,
54  this._rotation.y,
55  this._rotation.z,
56  this._rotation.w
57  };
58  }
59  }
60 
64  public override void UpdateObservation() {
65  var transform1 = this.transform;
66  if (this.ParentEnvironment != null && this._use_environments_coordinates) {
67  this._position = this.ParentEnvironment.TransformPoint(transform1.position);
68  this._rotation = Quaternion.Euler(this.ParentEnvironment.TransformDirection(transform1.forward));
69  } else {
70  this._position = transform1.position;
71  this._rotation = transform1.rotation;
72  }
73  }
74 
78  protected override void PreSetup() { }
79  }
80 }