Rotation Sensing Overview
You can measure frame rotation in different formats. These include axis-angle, quaternion, and transform. 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,
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.
1 Weld Joint is an exception