Skip to content

MjOrientationUtils

If true, angles (euler, axisangle, joint range) are in degrees.

MuJoCo's upstream default when no tag is present is "degree", so we match that. Without this default, models relying on the implicit default (e.g. tendon_arm/arm26.xml) get joint ranges like 0..120 treated as radians — the compile-time muscle lengthrange solver then diverges. / bool bAngleInDegrees = true; / Euler rotation sequence, e.g. "xyz", "XYZ", "zyx". Default "xyz" (intrinsic). */ FString EulerSeq = TEXT("xyz"); / Base directory for mesh file paths (from meshdir attribute). Empty = same dir as XML. / FString MeshDir; / Base directory for all asset paths (from assetdir attribute). Overrides meshdir for meshes if both present. / FString AssetDir; / If true, joints/tendons with a range attribute are automatically treated as limited (from autolimits). */ bool bAutoLimits = false; / Helper: resolve a relative mesh path using MeshDir / AssetDir with the given XML directory as the root. / FString ResolveMeshPath(const FString& RelPath, const FString& XmlDir) const { if (RelPath.IsEmpty()) return RelPath; // AssetDir takes priority for mesh lookups FString Base = AssetDir.IsEmpty() ? MeshDir : AssetDir; if (Base.IsEmpty()) Base = XmlDir; return FPaths::Combine(Base, RelPath); } }; /* Centralized utility for converting MuJoCo orientation attributes to quaternions. MuJoCo supports 5 orientation representations on spatial-frame elements: quat, axisangle, euler, xyaxes, zaxis Only one should be specified per element. Priority order (matching MuJoCo): quat > axisangle > euler > xyaxes > zaxis All functions produce MuJoCo-frame quaternions (w, x, y, z). Use MjUtils::MjToUERotation() to convert to Unreal frame afterwards.

Attribute Value
Kind Class

Properties

Public Properties

Property Type Description
Lowercase *

Lowercase

  • Type: *

Private Properties

Property Type Description
Result ** Multiply two quaternions:

Result

  • Type: ** Multiply two quaternions:

Functions

Public Functions

General

Function Returns Description
ParseCompilerSettings() FMjCompilerSettings Parse the element from an MJCF XML root and extract orientation-related settings.
OrientationToMjQuat() bool Read orientation attributes from an XML element and convert to a MuJoCo-frame quaternion.
AxisAngleToQuat() void Convert axis-angle (x, y, z, angle_rad) to quaternion. Axis need not be normalized.
EulerToQuat() void Convert Euler angles to quaternion given a 3-character euler sequence string.
XYAxesToQuat() void Convert xyaxes (6 values: x-axis 3, y-axis 3) to quaternion. Y is orthogonalized.
ZAxisToQuat() void Convert zaxis (3 values) to quaternion via minimal rotation from (0,0,1).
ParseCompilerSettings

Parse the element from an MJCF XML root and extract orientation-related settings.

OrientationToMjQuat

Read orientation attributes from an XML element and convert to a MuJoCo-frame quaternion.

  • Signature: OrientationToMjQuat(const FXmlNode* Node, const FMjCompilerSettings& Settings, double OutQuat[4])
  • Returns: bool
AxisAngleToQuat

Convert axis-angle (x, y, z, angle_rad) to quaternion. Axis need not be normalized.

  • Signature: AxisAngleToQuat(double x, double y, double z, double AngleRad, double OutQuat[4])
EulerToQuat

Convert Euler angles to quaternion given a 3-character euler sequence string.

  • Signature: EulerToQuat(double e1, double e2, double e3, const FString& EulerSeq, double OutQuat[4])
XYAxesToQuat

Convert xyaxes (6 values: x-axis 3, y-axis 3) to quaternion. Y is orthogonalized.

  • Signature: XYAxesToQuat(const double XYAxes[6], double OutQuat[4])
ZAxisToQuat

Convert zaxis (3 values) to quaternion via minimal rotation from (0,0,1).

  • Signature: ZAxisToQuat(const double ZAxis[3], double OutQuat[4])

Private Functions

General

Function Returns Description
ElementalRotQuat() void Create a quaternion for rotation around a single axis (0=x, 1=y, 2=z) by AngleRad.
QuatMul() void Multiply two quaternions: Result = A * B (Hamilton product). All in w,x,y,z order.
QuatNormalize() void Normalize a quaternion in-place.
RotMatToQuat() void Convert a 3x3 rotation matrix (row-major) to quaternion (w,x,y,z).
ElementalRotQuat

Create a quaternion for rotation around a single axis (0=x, 1=y, 2=z) by AngleRad.

  • Signature: ElementalRotQuat(int AxisIndex, double AngleRad, double OutQuat[4])
QuatMul

Multiply two quaternions: Result = A * B (Hamilton product). All in w,x,y,z order.

  • Signature: QuatMul(const double A[4], const double B[4], double Result[4])
QuatNormalize

Normalize a quaternion in-place.

  • Signature: QuatNormalize(double Q[4])
RotMatToQuat

Convert a 3x3 rotation matrix (row-major) to quaternion (w,x,y,z).

  • Signature: RotMatToQuat(const double R[9], double OutQuat[4])