9 namespace droid.Runtime.Prototyping.Configurables {
13 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
15 + ConfigurableComponentMenuPath._Postfix)]
19 [SerializeField]
bool _use_environments_space =
false;
21 [Header(
"Observation", order = 103)]
23 Quaternion observation_value = Quaternion.identity;
44 public Quaternion ObservationValue {
get {
return this.observation_value; } }
49 public Space4 QuadSpace {
get {
return this._quad_space; } }
55 this._x = this.Identifier +
"X_";
56 this._y = this.Identifier +
"Y_";
57 this._z = this.Identifier +
"Z_";
58 this._w = this.Identifier +
"W_";
65 this.ParentEnvironment =
66 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._x);
67 this.ParentEnvironment =
68 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._y);
69 this.ParentEnvironment =
70 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._z);
71 this.ParentEnvironment =
72 NeodroidUtilities.RegisterComponent(this.ParentEnvironment, (
Configurable)
this, this._w);
79 if (this.ParentEnvironment == null) {
83 this.ParentEnvironment.UnRegister(
this, this._x);
84 this.ParentEnvironment.UnRegister(
this, this._y);
85 this.ParentEnvironment.UnRegister(
this, this._z);
86 this.ParentEnvironment.UnRegister(
this, this._w);
89 public override ISpace ConfigurableValueSpace {
get; }
95 if (this._use_environments_space && this.ParentEnvironment != null) {
96 this.observation_value = this.ParentEnvironment.TransformRotation(this.transform.rotation);
98 this.observation_value = this.transform.rotation;
103 var rot = this.transform.rotation;
104 if (this.ParentEnvironment && this._use_environments_space) {
105 rot = this.ParentEnvironment.TransformRotation(this.transform.rotation);
109 if (this.QuadSpace.DecimalGranularity >= 0) {
110 v = (int)Math.Round(v,
this.QuadSpace.DecimalGranularity);
114 if (this.Debugging) {
115 Debug.Log($
"Applying {v} to {simulator_configuration.ConfigurableName} configurable");
119 if (this.RelativeToExistingValue) {
121 if (this.QuadSpace._Min_Values.x.CompareTo(
this.QuadSpace._Max_Values.x) != 0) {
122 if (v < this.QuadSpace._Min_Values.x || v > this.QuadSpace._Max_Values.x) {
123 Debug.Log($
"ConfigurableX does not accept input {v}, outside allowed range " 124 + $
"{this.QuadSpace._Min_Values.x} to {this.QuadSpace._Max_Values.x}");
129 rot.Set(rot.x - v, rot.y, rot.z, rot.w);
131 if (this.QuadSpace._Min_Values.y.CompareTo(
this.QuadSpace._Max_Values.y) != 0) {
132 if (v < this.QuadSpace._Min_Values.y || v > this.QuadSpace._Max_Values.y) {
133 Debug.Log($
"ConfigurableY does not accept input {v}, outside allowed range " 134 + $
"{this.QuadSpace._Min_Values.y} to {this.QuadSpace._Max_Values.y}");
139 rot.Set(rot.x, rot.y - v, rot.z, rot.w);
141 if (this.QuadSpace._Min_Values.z.CompareTo(
this.QuadSpace._Max_Values.z) != 0) {
142 if (v < this.QuadSpace._Min_Values.z || v > this.QuadSpace._Max_Values.z) {
143 Debug.Log($
"ConfigurableZ does not accept input {v}, outside allowed range " 144 + $
"{this.QuadSpace._Min_Values.z} to {this.QuadSpace._Max_Values.z}");
149 rot.Set(rot.x, rot.y, rot.z - v, rot.w);
151 if (this.QuadSpace._Min_Values.w.CompareTo(
this.QuadSpace._Max_Values.w) != 0) {
152 if (v < this.QuadSpace._Min_Values.w || v > this.QuadSpace._Max_Values.w) {
153 Debug.Log($
"ConfigurableW does not accept input {v}, outside allowed range " 154 + $
"{this.QuadSpace._Min_Values.w} to {this.QuadSpace._Max_Values.w}");
159 rot.Set(rot.x, rot.y, rot.z, rot.w - v);
163 if (this.QuadSpace._Min_Values.x.CompareTo(
this.QuadSpace._Max_Values.x) != 0) {
164 if (v < this.QuadSpace._Min_Values.x || v > this.QuadSpace._Max_Values.x) {
165 Debug.Log($
"ConfigurableX does not accept input {v}, outside allowed range " 166 + $
"{this.QuadSpace._Min_Values.x} to {this.QuadSpace._Max_Values.x}");
171 rot.Set(v, rot.y, rot.z, rot.w);
174 if (this.QuadSpace._Min_Values.y.CompareTo(
this.QuadSpace._Max_Values.y) != 0) {
175 if (v < this.QuadSpace._Min_Values.y || v > this.QuadSpace._Max_Values.y) {
176 Debug.Log($
"ConfigurableY does not accept input {v}, outside allowed range " 177 + $
"{this.QuadSpace._Min_Values.y} to {this.QuadSpace._Max_Values.y}");
182 rot.Set(rot.x, v, rot.z, rot.w);
185 if (this.QuadSpace._Min_Values.z.CompareTo(
this.QuadSpace._Max_Values.z) != 0) {
186 if (v < this.QuadSpace._Min_Values.z || v > this.QuadSpace._Max_Values.z) {
187 Debug.Log($
"ConfigurableZ does not accept input {v}, outside allowed range " 188 + $
"{this.QuadSpace._Min_Values.z} to {this.QuadSpace._Max_Values.z}");
193 rot.Set(rot.x, rot.y, v, rot.w);
196 if (this.QuadSpace._Min_Values.w.CompareTo(
this.QuadSpace._Max_Values.w) != 0) {
197 if (v < this.QuadSpace._Min_Values.w || v > this.QuadSpace._Max_Values.w) {
198 Debug.Log($
"ConfigurableW does not accept input {v}, outside allowed range " 199 + $
"{this.QuadSpace._Min_Values.w} to {this.QuadSpace._Max_Values.w}");
204 rot.Set(rot.x, rot.y, rot.z, v);
209 if (this.ParentEnvironment && this._use_environments_space) {
210 rot = this.ParentEnvironment.InverseTransformRotation(rot);
213 this.transform.rotation = rot;
221 var sample = this.QuadSpace.Sample();
223 var r =
Random.Range(0, 4);
238 throw new IndexOutOfRangeException();
static Space4 MinusOneOne
override void ApplyConfiguration(IConfigurableConfiguration simulator_configuration)
override void UpdateCurrentConfiguration()
override void RegisterComponent()
override Configuration [] SampleConfigurations()
override void UnRegisterComponent()