Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
VelocitySensor.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
5 using UnityEngine;
6 
7 namespace droid.Runtime.Prototyping.Sensors.Rigidbody {
11  public class VelocitySensor : Sensor,
12  IHasTriple {
13  [SerializeField] UnityEngine.Rigidbody _rigidbody;
14  [SerializeField] Vector3 _velocity;
15  [SerializeField] Space3 _velocity_space = new Space3(new DistributionSampler(), 10);
16 
20  public override string PrototypingTypeName { get { return "Rigidbody"; } }
21 
24  public Vector3 ObservationValue {
25  get { return this._velocity; }
26  set {
27  this._velocity = this._velocity_space.IsNormalised
28  ? this._velocity_space.ClipNormaliseRound(value)
29  : value;
30  }
31  }
32 
33  public Space3 TripleSpace { get { return this._velocity_space; } }
34 
38  public override IEnumerable<float> FloatEnumerable {
39  get { return new[] {this.ObservationValue.x, this.ObservationValue.y, this.ObservationValue.z}; }
40  }
41 
44  public override void UpdateObservation() { this.ObservationValue = this._rigidbody.velocity; }
45 
49  protected override void PreSetup() { this._rigidbody = this.GetComponent<UnityEngine.Rigidbody>(); }
50  }
51 }
Vector3 ClipNormaliseRound(Vector3 v)
Definition: Space3.cs:55