浏览代码

canonicalize quaternion observations

/develop/canonicalize-quaternions
Chris Elion 5 年前
当前提交
3b9fe7e5
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 22
      com.unity.ml-agents/Runtime/Sensor/VectorSensor.cs

22
com.unity.ml-agents/Runtime/Sensor/VectorSensor.cs


/// <param name="observation">Observation.</param>
public void AddObservation(Quaternion observation)
{
AddFloatObs(observation.x);
AddFloatObs(observation.y);
AddFloatObs(observation.z);
AddFloatObs(observation.w);
// For a quaternion q, both q and -q represent the same rotation. In order
// to make things easier for training, convert the quaternion to a "canonical" form,
// where the the w component is always positive.
if (observation.w < 0f)
{
AddFloatObs(-observation.x);
AddFloatObs(-observation.y);
AddFloatObs(-observation.z);
AddFloatObs(-observation.w);
}
else
{
AddFloatObs(observation.x);
AddFloatObs(observation.y);
AddFloatObs(observation.z);
AddFloatObs(observation.w);
}
}
/// <summary>

正在加载...
取消
保存