Rotation Sensing Overview
You can measure frame rotation in different formats. These include axis-angle, quaternion, transform, and rotation sequence. The different formats are available through the Transform Sensor block and, to a limited extent, in joint blocks 1 . The choice of measurement format depends on the model. Select the format that is most convenient for the application.
Rotation is a relative quantity. The rotation of one frame is meaningful only with respect to another frame. As such, blocks with rotation sensing capability require two frames to make a measurement: measured and reference frames. In these blocks, the follower frame port identifies the measured frame; the base frame port identifies the reference frame of the measurement.
Simscape™ Multibody™ defines the rotation formats according to standard conventions. In some cases, more than one convention exists. This is the case, for example, of the quaternion. To properly interpret rotation measurements, review the definitions of the rotation formats.
Axis-angle is one of the simpler rotation measurement formats. This format uses two parameters to completely describe a rotation: axis vector and angle. The usefulness of the axis-angle format follows directly from Euler’s rotation theorem. According to the theorem, any 3–D rotation or rotation sequence can be described as a pure rotation about a single fixed axis.
To measure frame rotation in axis-angle format, use the Transform Sensor block. The block property inspector contains separate Axis and Angle parameters that you can select to expose the corresponding physical signal (PS) ports (labeled axs and q, respectively). Because the axis-angle parameters are listed separately, you can choose to measure the axis, the angle, or both.
The axis output is a 3D unit vector in the form [ax, ay, az]. This unit vector encodes the rotation direction according to the right-hand rule. For example, a frame spinning in a counterclockwise direction about the +X axis has rotation axis [1 0 0]. A frame spinning in a clockwise direction about the same axis has rotation axis [-1 0 0].
The angle output is a scalar number in the range 0–π. This number encodes the extent of rotation about the measured axis. By default, the angle is measured in radians. You can change the angle units in the PS-Simulink Converter block used to interface with Simulink® blocks.
The quaternion is a rotation representation based on hypercomplex numbers. The quaternion is made up of a scalar part, S, and a vector, V, part. The scalar part encodes the angle of rotation, and the vector part encodes the rotational axis.
A key advantage of quaternions is the singularity-free parameter space. Mathematical singularities, which are present in Euler angle sequences, result in the loss of rotational degrees of freedom. This phenomenon is known as gimbal lock. In Simscape Multibody, gimbal lock causes numerical errors that lead to simulation failure. The absence of singularities means that quaternions are more robust for simulation purposes.
To measure frame rotation in quaternion format, use:
A Transform Sensor block when measuring rotation between two general frames. The Rotation menu of the property inspector contains a Quaternion parameter that you can select to expose the corresponding physical signal port (labeled Q).
A joint block that has a spherical primitive when measuring the 3-D rotation between the two joint frames. The Sensing menu of the property inspector contains a Position parameter that you can select to expose the corresponding physical signal port (which is also labeled Q). For more information, see the Spherical Joint block reference page.
The quaternion output is a four-element row vector, , where:
θ is the angle of rotation and [Ux, Uy, Uz] is the unit vector of the rotational axis. Note that for any given rotation, there are two quaternions. They are negatives of each other, but represent the same rotation. For example, the quaternions [
0] and [
0] both represent the identity rotation.
The rotation transform is a 3×3 matrix that encodes frame rotation. In terms of base frame axes [x, y, z]B, the follower frame axes [x, y, z]F are:
Each matrix column contains the coordinates of a follower frame axis resolved in the base frame. For example, the first column contains the coordinates of the follower frame X-axis, as resolved in the base frame. Similarly, the second and third columns contain the coordinates of the Y and Z-axes, respectively. Operating on a vector with the rotation matrix transforms the vector coordinates from the follower frame to the base frame.
You can sense frame rotation in terms of a rotation matrix using the Transform Sensor block. The property inspector for this block contains a Transform option that when selected exposes a physical signal port labeled R. Use this port to output the rotation matrix signal, for example, for processing and analysis in a Simulink subsystem—after converting the output physical signal to a Simulink signal through the PS-Simulink Converter block.
Rotation Sequence Measurements
The rotation sequence measurements use three successive elementary rotations about the axes of
a frame to represent the orientation difference between two frames. To use the
rotation sequence measurements, you can use the
sequenceAngles method or the Rotation
Sequence parameter of the Transform
The elementary rotations are intrinsic if they are about an intermediate frame, which changes its orientation after each elementary rotation. When the elementary rotations are about a fixed frame the rotations are extrinsic. The measurements have 12 different rotation sequences including X-Y-X, X-Y-Z, X-Z-X, X-Z-Y, Y-X-Y, Y-X-Z, Y-Z-X, Y-Z-Y, Z-X-Y, Z-X-Z, Z-Y-X, and Z-Y-Z. Note that the outputs from the port seq of the Transform Sensor block are angles of intrinsic rotations. The image shows an example that represents a 3-D rotation with three intrinsic rotations based on the Z-Y-Z sequence.
Extrinsic rotations are equivalent to intrinsic rotations with the same angles but with an inverted sequence order. For example, the extrinsic rotations Z-Y-X by angles φ, θ, and Ψ are equivalent to the intrinsic rotations X-Y-Z by the angles Ψ, θ, and φ.
When the rotation does not has a locking issue, such as gimbal lock, a rotation sequence
measurement has two sets of solutions, but the Transform
Sensor block or the
only outputs one set of them. All three angles are in the range [-π, π]. If a
rotation sequence has different letters, such as X-Y-Z and Z-X-Y, the angle of
the second rotation is in the range of (-π/2, π/2). If the first and last
letters of a rotation sequence are the same, such as X-Y-X and Z-Y-Z, the angle
of the second rotation is in the range (0, π).
For these cases, the locking issue occurs and there are infinite number of solutions for the angles of the first and last rotations:
A rotation sequence has different letters and the second rotation angle equals -π/2 or π/2.
The first and last letters of a rotation sequence are the same and the second rotation angle equals 0 or π.
In these cases, the Transform Sensor block or the
sequenceAngles method outputs only one set of solutions where the magnitudes of the first and last angles are the same.
1 Weld Joint is an exception