1 using System.Collections.Generic;
7 namespace droid.Runtime.Prototyping.Sensors.Rigidbody {
11 [AddComponentMenu(SensorComponentMenuPath._ComponentMenuPath
13 + SensorComponentMenuPath._Postfix)]
20 [Header(
"Observation", order = 100)]
22 Vector3 _angular_velocity = Vector3.zero;
24 [SerializeField]
bool _differential =
false;
26 [SerializeField]
float _last_update_time = 0;
28 [Header(
"Configuration", order = 110)]
32 [SerializeField] Vector3 _velocity = Vector3.zero;
38 public override string PrototypingTypeName {
40 if (this._differential) {
41 return "RigidbodyDifferential";
51 public Vector3 Velocity {
52 get {
return this._velocity; }
63 public Vector3 AngularVelocity {
64 get {
return this._angular_velocity; }
66 this._angular_velocity = this._angular_space.
IsNormalised 75 public Space3 VelocitySpace {
get {
return this._velocity_space; } }
80 public Space3 AngularSpace {
get {
return this._angular_space; } }
85 public override IEnumerable<float> FloatEnumerable {
91 this.AngularVelocity.x,
92 this.AngularVelocity.y,
93 this.AngularVelocity.z
102 var update_time_difference = Time.time - this._last_update_time;
103 if (this._differential && update_time_difference > 0) {
104 var vel_diff = this.Velocity - this._rigidbody.velocity;
105 var ang_diff = this.AngularVelocity - this._rigidbody.angularVelocity;
107 var vel_magnitude = vel_diff.magnitude;
108 if (vel_magnitude > 0) {
109 this.Velocity = vel_diff / (update_time_difference +
float.Epsilon);
111 this.Velocity = vel_diff;
114 var ang_magnitude = ang_diff.magnitude;
115 if (ang_magnitude > 0) {
116 this.AngularVelocity = ang_diff / (update_time_difference +
float.Epsilon);
118 this.AngularVelocity = ang_diff;
121 this.Velocity = this._rigidbody.velocity;
122 this.AngularVelocity = this._rigidbody.angularVelocity;
125 this._last_update_time = Time.time;
override void UpdateObservation()
Vector3 ClipNormaliseRound(Vector3 v)