Generated reference › Euler To Quaternion — Robotics/Orientation 3D
kind: generated#block#robotics-orientation-3d

Euler To Quaternion — Robotics/Orientation 3D

Robotics/Orientation_3D/Euler_To_Quaternion · 3 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Euler To Quaternion

Robotics / Orientation 3D

Converts three ZYX intrinsic Euler angles – yaw, pitch, roll, in radians – into the equivalent unit quaternion, stored scalar-first as [w x y z]T:

q = qZ(yaw) ⊗ qY(pitch) ⊗ qX(roll)

Writing cy = cos(yaw/2), sy = sin(yaw/2) and likewise cp/sp for pitch and cr/sr for roll:

  • w = cy·cp·cr + sy·sp·sr
  • x = cy·cp·sr − sy·sp·cr
  • y = cy·sp·cr + sy·cp·sr
  • z = sy·cp·cr − cy·sp·sr

Intrinsic means each rotation turns about the axis the previous one left behind: yaw about Z, then pitch about the new Y, then roll about the new X. That is the same rotation as the extrinsic XYZ order read right to left, and it is the order aerospace and robotics use.

Ports

  • yaw – rotation about Z, applied first. A [1,1] scalar in radians, unwrapped: any real value is accepted and the block is periodic in it.
  • pitch – rotation about the new Y, second. [1,1], radians.
  • roll – rotation about the new X, last. [1,1], radians.
  • q – the quaternion [w x y z]T, [4,1]. Its size is fixed, not inherited: a quaternion is four numbers. It is a unit quaternion for every input, to rounding.

Parameters

  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. There is no tunable parameter, because the block has no parameter at all – all three angles arrive on ports.

The three HDL targets are simulation-only real arithmetic, not synthesizable Q16.16: the body needs six half-angle sines and cosines every sample, and there is no fixed-point trigonometry to call. Quantization happens only at the port boundary. This is the opposite of Quaternion Multiply, whose product is multiply-add throughout and does synthesize – the difference is the trigonometry, not the family.

The half-angle is formed as × 0.5 rather than ÷ 2 in every target, so no backend carries a divider for it.

Simulink bridge

None, and the reason is measured rather than assumed: Simulink's Euler-to-quaternion conversions live in the Aerospace Blockset and the Robotics System Toolbox, and neither is installed on this machine (aero, aeroblks, robotics, nav and fusion are all absent from matlabroot/toolbox). A model carrying this block exports with the block reported rather than silently dropped.

Notes

  • Algebraic and stateless: the output depends only on the current inputs, so the block cannot break an algebraic loop.
  • The Euler order is the block. There are twelve Euler conventions and nothing in three numbers says which one they are, so feeding ZYX angles to a block expecting another order gives a perfectly valid quaternion for the wrong rotation. This block is ZYX intrinsic throughout the Robotics family. Note also that several orders coincide when the three angles are equal, so a quick check with all three set the same cannot tell them apart.
  • Scalar-first (w, x, y, z), Hamilton – the same convention as Quaternion Multiply, Quaternion Rotate Vector and the rest of the family, and the PyTorch/Eigen/textbook one rather than JPL.
  • Angles are radians and unwrapped. Feed degrees through a Gain of π/180 first. Because the half-angles are periodic in 4π, yaw and yaw + 2π give quaternions that differ in sign – the same rotation, since q and −q rotate identically.
  • Exactly invertible by Quaternion To Euler, which is the block's partner and reads the same convention. The round trip returns each angle wrapped into that block's stated output ranges, so an input yaw of 3.4 rad comes back as 3.4 − 2π: the same orientation, a different representative.
  • Nonlinear, so deliberately no state space – sine and cosine of the inputs are not a linear form, and a fabricated one would let model reduction merge matrices that do not describe this block.

Code facts#

FactValue
registered typeRobotics/Orientation_3D/Euler_To_Quaternion
familyRobotics/Orientation_3D
solver environment classICoreBlock_0_Robotics_1_Orientation_3D_2_Euler_To_Quaternion
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Euler_To_Quaternion/ICoreBlock_0_Robotics_1_Orientation_3D_2_Euler_To_Quaternion.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Euler_To_Quaternion/ICoreBlock_0_Robotics_1_Orientation_3D_2_Euler_To_Quaternion.h
default size on canvas132 × 96 px
ports at insert3 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubleyaw
2inICoreDoublepitch
3inICoreDoubleroll
4outICoreDoubleq

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

No config variable beyond the Sampling Time (s) every block carries.

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent available: the Euler-to-quaternion conversions ship in the Aerospace Blockset and the Robotics System Toolbox, neither of which is installed. Rebuild the conversion on the Simulink side from Trigonometric Function and Product blocks, keeping the ZYX-intrinsic order and the scalar-first (w, x, y, z) Hamilton convention this block uses

Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Euler To Quaternion — ZYX intrinsic (yaw, pitch, roll) to a scalar-first [4,1] quaternion q = qz(yaw) (x) qy(pitch) (x) qx(roll)

with cy = cos(yaw*0.5), sy = sin(yaw*0.5), cp = cos(pitch*0.5), sp = sin(pitch*0.5), cr = cos(roll*0.5), sr = sin(roll*0.5):

w = cy*cp*cr + sy*sp*sr x = cy*cp*sr - sy*sp*cr y = cy*sp*cr + sy*cp*sr z = sy*cp*cr - cy*sp*sr

Written together with Quaternion_To_Euler, its exact inverse: the pair shares ONE convention and the value of either is its agreement with the other, so they were designed, emitted and checked as one job. See the header for the two ledger conventions this block obeys.

⚠ THE TERM TABLE BELOW IS THE CONTRACT. Every one of the ten backends walks QUAT_TERMS in this order and associates each triple product LEFT TO RIGHT ((a*b)*c), exactly as the C++ reference does. Floating-point multiplication and addition are not associative, so a backend that grouped them differently would disagree in the last ulp on most samples -- a row that moves for a reason having nothing to do with the export. It costs nothing to keep them identical, so they are kept identical.

⚠ THE HALF-ANGLE IS * 0.5, NEVER / 2, in all eleven implementations. The two are the same number in IEEE arithmetic, but the three HDL targets and PLC ST have no reason to carry a divider for a constant, and one backend spelling it the other way is one more thing that can differ.

No config of any kind, so no loadBlockConfig() call is needed anywhere: the generators bake in no constant and read no config map (§3's rule bites only blocks whose generators do).

Sample results#

Euler To Quaternion — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleEuler To Quaternion — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-202012345t (s)in ICoreDouble-Out-0in ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0 [4x1] entry 0
tin ICoreDouble-Out-0in ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0 [4x1] entry 0
0-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
0.40.50.50.5[0.9247, 0.173, 0.2916, 0.173]
0.8-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
1.20.50.50.5[0.9247, 0.173, 0.2916, 0.173]
1.6-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
20.50.50.5[0.9247, 0.173, 0.2916, 0.173]
2.4-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
2.80.50.50.5[0.9247, 0.173, 0.2916, 0.173]
3.2-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
3.60.50.50.5[0.9247, 0.173, 0.2916, 0.173]
4-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
4.40.50.50.5[0.9247, 0.173, 0.2916, 0.173]
4.8-2-2-2[-0.4381, -0.6282, 0.1369, -0.6282]
5.20.50.50.5[0.9247, 0.173, 0.2916, 0.173]

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0.7861 … 1
rampRamp: slope 1 from t = 0-0.9017 … 1
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias0.5657 … 1
stepStep: 0 -> 1 at t = 1 s0.7861 … 1

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Robotics__Orientation_3D__Euler_To_Quaternion.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).