Next Article in Journal
Parametric Optimization of FDM Process for Improving Mechanical Strengths Using Taguchi Method and Response Surface Method: A Comparative Investigation
Previous Article in Journal
Friction-Induced Efficiency Losses and Wear Evolution in Hypoid Gears
Previous Article in Special Issue
Navigation of a Differential Wheeled Robot Based on a Type-2 Fuzzy Inference Tree
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Orientation Modeling Using Quaternions and Rational Trigonometry

1
Centro de Investigación en Computación, Instituto Politécnico Nacional, Ciudad de México 07738, Mexico
2
Campus Guadalajara, Instituto Tecnológico y de Estudios Superiores de Monterrey, Zapopan 45138, Mexico
3
Centro de Investigaciones en Óptica A. C., Guanajuato 37150, Mexico
4
Departamento de Ingeniería Mecánica Agrícola, Universidad Autónoma Chapingo, Texcoco 56235, Mexico
*
Author to whom correspondence should be addressed.
Machines 2022, 10(9), 749; https://doi.org/10.3390/machines10090749
Submission received: 16 June 2022 / Revised: 23 August 2022 / Accepted: 24 August 2022 / Published: 30 August 2022
(This article belongs to the Special Issue Control of Robotic Systems)

Abstract

:
In recent years, the recreational and commercial use of flight and driving simulators has become more popular. All these applications require the calculation of orientation in either two or three dimensions. Besides the Euler angles notation, other alternatives to represent rigid body rotations include axis-angle notation, homogeneous transformation matrices, and quaternions. All these methods involve transcendental functions in their calculations, which represents a disadvantage when these algorithms are implemented in hardware. The use of transcendental functions in software-based algorithms may not represent a significant disadvantage, but in hardware-based algorithms, the potential of rational models stands out. Generally, to calculate transcendental functions in hardware, it is necessary to utilize algorithms based on the CORDIC algorithm, which requires a significant amount of hardware resources (parallel) or the design of a more complex control unit (pipelined). This research presents a new procedure for model orientation using rational trigonometry and quaternion notation, avoiding trigonometric functions for calculations. We describe the orientation of a gimbal mechanism presented in many applications, from autonomous vehicles such as cars or drones to industrial manipulators. This research aims to compare the efficiency of a rational implementation to classical modeling using the techniques mentioned above. Furthermore, we simulate the models with software tools and propose a hardware architecture to implement our algorithms.

Graphical Abstract

1. Introduction

The kinematic analysis of a rigid body is usually done by taking its center of mass as a reference. However, since not all bodies have high symmetry, it is necessary to specify both position and orientation. The orientation can be visualized by adding an orthogonal vector base to the center of mass. Many methods describe the orientation of a rigid body; however, two of the most common techniques are the Euler angles and the quaternions.
Euler angles are properly called the six configurations in which the initial and final rotations are made on the same axis (e.g., z-y-z). On the other hand, Tait–Bryan angles (a.k.a., nautical angles) are three angles that define a rotation uniquely concerning the body reference frame. Unlike Euler angles, the Tait–Bryan procedure develops sequence rotation about different axes. In some literature, the Tait–Bryan sequence, x-y-z, is called roll, pitch, and yaw. This rotation sequence is widely used in aerospace engineering, but in some references, Tait–Bryan and Euler angles are used under the same terminology and are simply called Euler angles.
The most important quality of Euler orientation is that any combination of rotations is equivalent to a single rotation. Although matrix notation was introduced after the Euler results, it can be shown that the rotation’s composition turns mathematically equivalent to the product of orthogonal matrices. Another way of representing rotations is known as the Euler vector or rotation vector, which states that every rotation matrix has a real Eigenvector and represents the axis of rotation. Based on this idea, Euler introduced an alternative notation to determine the orientation, defined as a vector perpendicular to the plane of rotation the module of which is equivalent to the rotated angle. Therefore, any vector through the origin can represent a rotation.
A similar concept to Euler vectors is the quaternion representation, which includes vectors of four components and a module equal to one. This has many advantages over Euler representations since it is numerically more stable, computationally more efficient and easier to convert into matrices.
The orientation of a rigid body in 3D space changes by rotation, and when the solid has rotational symmetry, not all rotations are visually distinguishable. For instance, this happens when a sphere is rotated around its center in any direction or a cylinder around its symmetry-axis. All the above methods can be studied as purely geometric concepts, applicable to describing rigid bodies’ orientation in space.
Regardless of the chosen method, there are two ways to implement an algorithm in order to compute the orientation of a rigid body: by software or by hardware. These involve transcendental functions, from their definitions to their calculations. On the other hand, avoiding transcendental functions in software-based algorithms may not represent a great advantage, because current processors are so fast. However, in hardware-based algorithms, the potential of rational models stands out.
Generally, to compute transcendental functions in hardware, it is common to use algorithms based on CORDIC, which requires a large number of hardware resources (parallel) or the design of a complex control unit (pipelined). Some CORDIC algorithm implementations require 21 stages to compute a transcendental function, and it is possible to reduce these stages to at least 11 by losing accuracy. Many researchers use the CORDIC algorithm to compute orientation [1,2], and some of them combine this with quaternion representations to compute orientation [3]. In robotics, it is mandatory that applications compute variables at least 30 times per second, or even faster [4].
This research presents a novel approach to model orientation using rational trigonometry, avoiding trigonometric functions. We describe the orientation of a gimbal mechanism present in many applications, from autonomous vehicles such as cars or drones to industrial manipulators. This work aims to compare how the efficiency of implementation in a rational way to classical modeling that utilizes the techniques previously mentioned.
The main contributions of this paper are two novel models based on rational trigonometry: one for the orientation of a gimbal mechanism and the other for the position and orientation of a wrist mechanism, based on quaternions and dual quaternions in a rational way, respectively. It is worth mentioning that none of these proposed models involve using transcendental functions, which reduces the hardware demands of rational models for synthesizing circuits that compute additions, subtractions, multiplications, and some divisions. This proposition has the advantage of allowing more efficient and smaller hardware implementations than the classic CORDIC-based implementations.
The rest of the work is arranged as follows. In Section 2, a review of related works is presented. Section 3 and Section 4 are oriented to illustrate our proposed approach related to the quaternion transformation. Section 5 presents an application focused on orienting a robotic arm employing rational modeling. Section 6 shows the results of implementing our proposal in rational Euler angles and on physical hardware. Lastly, Section 7 is focused on concluding and highlighting some advantages of our proposal. Furthermore, Appendix A explains rational concepts equivalent to distance and angle, for the better understanding of the reader.

2. Related Work

In the film and advertising industry, there has been a need to use robotics to improve and automate the film and commercial recording process. One of the most used mechanisms to define the orientation of cameras and other devices is the so-called gimbal. This mechanism is widely used in patents [5,6,7,8] and even in measuring large-scale systems such as buildings [9].
In the robotics field, companies such as the Motorized Precision Company use industrial robotic arms to perform video capture. This company has adapted different kinematic modeling and trajectory generation techniques to achieve a wide range of features on its products, and orientation modeling is one of the fundamental factors in achieving all these features.
Another field in which research has been invested to improve orientation models is drone design [10,11]. Companies such as DJI sell devices that offer a wide range of features, including autonomous flight and flight stabilization in different environmental conditions.
The orientation issue is present in many robotic mechanisms, from platform systems for virtual reality to the most sophisticated manipulative robots. The described orientation is influenced by the ease with which the user interprets it. For instance, Euler angles are often preferred for orientation models because they are easier to understand and interpret for the user [12].
Fu et al. [13] presented an efficient method based on dual quaternion for coordinate calibration of dual robots in collaborative motion. In contrast, we have developed a modeling technique to describe the orientation of a gimbal mechanism using quaternions in a rational way. We have called this method rational modeling because no trigonometric functions have been used, as is common in all algorithms included in the bibliography [14,15,16]. We generate a rational model analog for Euler angles. Then, we develop a new model to describe the orientation of a robotic mechanism known as the spherical wrist, which is present in most industrial manipulators [17,18].
When we refer to robotic arms, the wrist mechanism is the one responsible for the orientation of the end effector. There are several techniques that try to reduce the number of operations needed to calculate the orientation, as developed in the following works [19,20,21].
In robotics and automation, orientation holds an important role in welding tasks because an efficient description of the orientation is required [22]. There are algorithms used to calculate the orientation either online or offline. However, most of the time, it is preferred to perform computations offline, since doing them online can be more cumbersome, and many times the accuracy requirements of the process are not met [23,24].
Nowadays, computer vision is present in many industrial processes. In this area, orientation modeling is required to control the position and orientation of objects in the workspace. For instance, some techniques have been developed to control the position and orientation of mobile robots based on control with neural networks [25,26].

3. Quaternions in a Rational Way

Rational trigonometry relies on the idea that algebra is more basic than analysis [27], and that the true measurements in elementary geometry should be quadratic rather than linear. In contrast to classical trigonometry, rational trigonometry does not require using transcendental functions [28]. We have included some rational concepts equivalent to distance and angle in Appendix A.
Quaternions are a form of four-dimensional algebra that lets us represent 3 D rotations in a simple way [29]. Every quaternion can be visualized in the diagram of Figure 1a, where the blue sphere is the S 3 sphere formed by all unit quaternions (i.e., | q | = 1 ), and the green box is the usual 3 D vector space. Any quaternion q has a component on the t-axis and a projection in the vector space. Such a projection has a unique vector representing the rotation axis in the 3 D vector space.
In order to understand the quaternion transformation, we analyze what happens with the space when we multiply by a general unit vector u. Suppose that vector u is orthogonal to the plane formed by v and w according to Figure 1b. The first step in analyzing the transformation is to break the 4D space into two planes, one span by { 1 , u } and the second span by { v , w } , as shown in Figure 2.
Quaternion multiplication is not commutative, and it follows the rules:
u · 1 = u u · v = w u · w = v u · u = 1 v · u = w w · u = v
On the plane generated by the multiplication between { 1 , u } and u, the left and right generate a counter-clockwise rotation, as shown in Figure 2a. However, if we conjugate the imaginary unit u (i.e., u ¯ = u ), the multiplication generates a clockwise rotation. In the plane spanned by { v , w } , the multiplication by u on the left of any vector is equivalent to a counter-clockwise rotation. In contrast, the multiplication by u on the right is equivalent to a clockwise rotation. When we multiply by the conjugate of u, the right and left multiplication generates a counter-clockwise and clockwise rotation, respectively.
To develop a transformation in a classical way, we choose a quaternion as:
q = ( t , u ^ ) = cos θ 2 , sin θ 2 u x , sin θ 2 u y , sin θ 2 u z
where θ is the amplitude of the rotation angle and u x , u y , u z are the components of the unit vector u ^ = ( u x , u y , u z ) , which represents the rotation axis. The plane generated by 1 , u is invariant under this transformation; however, the plane generated by v , w suffers a rotation twice the magnitude of θ .
In the rational method, we choose a quaternion more easily, and therefore we choose a rotation axis u and a half-turn to compute the t parameter:
t = u h
where vector u does not have to be unitary. The quaternion components are:
q = ( t , v ) = ( t , v x , v y , v z ) .
Lastly, the expression that describes a rotation in a rational way is the following:
φ r ( r ) = q · r · q ¯ Q ( q )
where Q ( q ) = q · q ¯ is the quadrance of q and Q ( q ) = 1 when q is unitary. The connection between angles and half-turns is done by the relation between the classical parameterization and the rational parameterization of the unit circle:
cos θ , sin θ = 1 h 2 1 + h 2 , 2 h 1 + h 2 .

4. Dual Quaternions in a Rational Way

Dual quaternions let us encode both position and orientation with only one quaternion [30]. A dual quaternion is a dual number a + b ε where a , b H ; ε is tied to the dual part and satisfies the expression ε 2 = 0 . Dual quaternion transformation can be analyzed into two parts, one for pure translation and one for pure rotation.
The pure translation is represented by a dual quaternion in the next form:
Q t = Q ¯ t * = ( 1 , 0 , 0 , 0 ) + 0 , r x 2 , r y 2 , r z 2 ε
where r x , r y , and r z represent the displacements for each coordinate given in quadrances. Applying transformation (4) with Q t and Q ¯ t * to the vector position in dual form V = ( 1 , 0 , 0 , 0 ) + ( 0 , v ) ε , we obtain a new dual quaternion V :
V = Q t V Q ¯ t * = ( 1 , 0 , 0 , 0 ) + 0 , v x + r x , v y + r y , v z + r z ε .
To represent a pure rotation transformation, we need to apply transformation (4), where quaternions Q r and Q ¯ r * have the following form:
Q r = ( t 1 , v x , v y , v z ) + ( 0 , 0 , 0 , 0 ) ε
Q ¯ r * = ( t 1 , v x , v y , v z ) + ( 0 , 0 , 0 , 0 ) ε
if Q r and Q ¯ r * are unity, Q ( Q r ) = 1 , but in another case, the transformation is:
V = Q r V Q ¯ r * Q ( Q r ) = ( 1 , 0 , 0 , 0 ) + ( t 2 , v x , v y , v z ) ε
the components of dual part t 2 , v x , v y , and v z are computed as:
t 2 = t 1 ( v · u ) ( t 1 v + u × v ) · ( u )
v = ( v · u ) u + t 1 ( t 1 v + u × v ) + ( t 1 v + u × v ) × ( u )
where vectors v and u ^ are the original position vector and the rotation axis, respectively. t 1 encodes the amplitude of rotation according to Equation (1).

5. Orientation Model

The robotic mechanism called the spherical wrist is responsible for guiding the tool placed at the robot’s tip. Figure 3 shows the wrist configuration of most industrial robotic arms.
In order to orient the mechanism in an arbitrary form, it is mandatory to define at least three parameters (one for each joint). A common way to describe the orientation is as a sequence of rotations on the Cartesian axes x, y, and z.
We use the z-y-z configuration for Euler angle notation, since it is used in most industrial robot manipulators. The letters z-y-z are the sequence of axes on which the rotations are made. Nevertheless, there are two ways to do this procedure, known as extrinsic and intrinsic rotations [31]. An extrinsic rotation applies rotations around the axes z-y-z belonging to the body frame, as shown in Figure 4a. On the other hand, an intrinsic rotation involves rotations around the axes z-y-z belonging to the general reference frame, as displayed in Figure 4b.
Euler angle representation is very useful because it adapts perfectly to the gimbal mechanism, as shown in Figure 5a, and can be adapted to the mechanism presented in Figure 3. However, the main problem of this mechanism is that it has singularities; i.e., when two different rotation axes are aligned, the mechanism loses a degree of freedom, as displayed in Figure 5b; the green axis rotates in the same direction as the red axis. In short, this implies that there are infinite solutions that put the mechanism in a particular configuration. Another popular representation for orientation is “roll-pitch-yaw”, also called Tait–Bryan angles, which is used in drones.
In contrast with the gimbal mechanism (Euler angles), the spherical wrist mechanism does not have its joints at the same point. Therefore, we should add some displacements between the joints, representing the length of robot joints. The following analysis is purely geometric. Figure 6 shows the breakdown movement according to the robotic orientation mechanism presented above.
According to Figure 6, it is important to point out the following:
  • The point O corresponds to the fourth joint of an industrial robotic arm and is the first degree of freedom for the orientation mechanism. Its rotation axis is parallel to the z 1 axis of our main reference frame;
  • The point C corresponds to the fifth joint of an industrial robotic arm and is the second degree of freedom for the orientation mechanism. This point is where the three rotation axes of the wrist intersect. The opening of this joint defines the final position of the wrist mechanism, but this point remains fixed under any variation of the three joint parameters;
  • The point P corresponds to the sixth joint of the manipulator and is the last degree of freedom for the orientation mechanism. P is where the end effector is, as long as the first joint of the orientation mechanism does not change. Otherwise, the end effector moves through the circular trajectory to P f .
In this orientation modeling, we consider the reference frame at the point O that exactly matches the origin of the Cartesian space.

5.1. Euler Angles in a Rational Way

Euler angles can be represented in matrix form in the following way:
q = cos ϕ sin ϕ 0 sin ϕ cos ϕ 0 0 0 1 cos θ 0 sin θ 0 1 0 sin θ 0 cos θ cos ψ sin ψ 0 sin ψ cos ψ 0 0 0 1
where θ 1 , θ 2 , and θ 3 represent the amplitude of rotation. Each rotation matrix can be interchanged with a quaternion in the form of Equation (1), as shown below:
q = ( cos ϕ 2 , sin ϕ 2 k ^ ) · ( cos θ 2 , sin θ 2 j ^ ) · ( cos ψ 2 , sin ψ 2 k ^ ) .
If we replace the angles by half-turns in the above expression, we obtain a rational representation for the configuration z-y-z of the Euler angles, as shown below:
q = ( t 1 , 0 , 0 , 1 ) · ( t 2 , 0 , 1 , 0 ) · ( t 3 , 0 , 0 , 1 )
where t 1 , t 2 , and t 3 are the magnitude of rotation according to Equation (2). Finally, by computing and simplifying, we obtain a rational model for Euler angles.
q = ( t 2 ( t 1 t 3 1 ) , t 1 t 3 , t 1 t 3 + 1 , t 2 ( t 1 + t 3 ) ) .
The quaternion q is used to calculate the final orientation according to Equation (4). Equation (16) only defines mechanism orientation, considering that there is no displacement between the joints of the wrist mechanism.

5.2. Real Mechanism in a Rational Way

In order to obtain a real model of the mechanism depicted in Figure 6 that gathers both position and orientation, we will use a dual quaternion for each joint as follows:
V = Q t Q r V Q ¯ r * Q ¯ t * Q ( Q r ) .
Applying Equation (17) for each joint, we obtain the following expression:
V = Q t 3 Q r 3 Q t 2 Q r 2 Q t 1 Q r 1 V Q ¯ r 1 * Q ¯ t 1 * Q ¯ r 2 * Q ¯ t 2 * Q ¯ r 3 * Q ¯ t 3 * Q ( Q r 1 ) Q ( Q r 2 ) Q ( Q r 2 )
where each dual quaternion has the following parameters, according to Figure 6:
Q r 1 = ( t 1 , 0 , 0 , 1 ) + ( 0 , 0 , 0 , 0 ) ε
Q t 2 = ( 1 , 0 , 0 , 0 ) + ( 0 , 0 , 0 , L 1 2 ) ε
Q r 2 = ( t 2 , 2 t 1 , t 1 2 1 , 0 ) + ( 0 , 0 , 0 , 0 ) ε
Q t 3 = ( 0 , 0 , 0 , 0 ) + ( 0 , L 2 2 a a ) ε
Q r 3 = ( t 3 , 2 t 2 ( t 1 2 1 ) , 4 t 1 t 2 , t 2 2 ( t 1 2 1 ) 2 4 1 2 ) + ( 0 , 0 , 0 , 0 ) ε
where a = ( 2 t 2 ( t 1 2 1 ) , 4 t 1 t 2 , t 2 2 t 1 4 2 t 1 2 1 ) .
Computing all multiplications according to Equation (17), we obtain a unique dual quaternion whose components transform the original vector V into V . Figure 7 shows each transformation independently, beginning from the origin frame and ending in the final frame of the wrist mechanism. Note that Q t 1 does not appear, since the first joint is on the origin of the reference frame.

6. Experimental Results

6.1. Rational Euler Angles Implementation

The direct kinematic problem for orientation consists of finding the final orientation given three joint parameters. These three parameters are generally given in degrees or radians. However, they could also be provided in any of the aperture measurements discussed in Appendix A (spread, turn, or half-turn).
A common way of solving the direct kinematics for the orientation of a robotic arm is to employ rotation matrices to represent the Euler angles z-y-z. As already mentioned, this representation is not the most convenient, but it is one of the easiest to understand. The equations are obtained after multiplying the three rotation matrices corresponding to the axes z-y-z successively by an arbitrary vector v = ( x , y , z ) :
x = ( cos ( α ) cos ( β ) cos ( γ ) sin ( α ) sin ( γ ) ) x ( cos ( α ) cos ( β ) sin ( γ ) + sin ( α ) cos ( γ ) ) y + ( cos ( α ) sin ( β ) ) z
y = ( sin ( α ) cos ( β ) cos ( γ ) + cos ( α ) sin ( γ ) ) x + ( cos ( α ) cos ( γ ) sin ( α ) cos ( β ) sin ( γ ) ) y + ( sin ( α ) sin ( β ) ) z
z = sin ( β ) cos ( γ ) x + sin ( β ) sin ( γ ) y + cos ( β ) z
Thus far, the rotation has not been described and the equations do not contain transcendental functions. Considering the concept of half-turn proposed in the Appendix A, Equations (24)–(26) can be transformed in such a way that all the trigonometric functions disappear, as shown below:
x = x ( t 1 2 + e 1 x 2 e 1 y 2 e 1 z 2 ) + 2 y ( e 1 x e 1 y t 1 e 1 z ) + 2 z ( e 1 x e 1 z + t 1 e 1 y ) y = y ( t 1 2 e 1 x 2 + e 1 y 2 e 1 z 2 ) + 2 z ( e 1 y e 1 z t 1 e 1 x ) + 2 x ( e 1 x e 1 y + t 1 e 1 z ) z = z ( t 1 2 e 1 x 2 e 1 y 2 + e 1 z 2 ) + 2 x ( e 1 x e 1 z t 1 e 1 y ) + 2 y ( e 1 y e 1 z + t 1 e 1 x )
x = x ( t 2 2 + e 2 x 2 e 2 y 2 e 2 z 2 ) + 2 y ( e 2 x e 2 y t 2 e 2 z ) + 2 z ( e 2 x e 2 z + t 2 e 2 y ) y = y ( t 2 2 e 2 x 2 + e 2 y 2 e 2 z 2 ) + 2 z ( e 2 y e 2 z t 2 e 2 x ) + 2 x ( e 2 x e 2 y + t 2 e 2 z ) z = z ( t 2 2 e 2 x 2 e 2 y 2 + e 2 z 2 ) + 2 x ( e 2 x e 2 z t 2 e 2 y ) + 2 y ( e 2 y e 2 z + t 2 e 2 x )
x = x ( t 3 2 + e 3 x 2 e 3 y 2 e 3 z 2 ) + 2 y ( e 3 x e 3 y t 3 e 3 z ) + 2 z ( e 3 x e 3 z + t 3 e 3 y ) y = y ( t 3 2 e 3 x 2 + e 3 y 2 e 3 z 2 ) + 2 z ( e 3 y e 3 z t 3 e 3 x ) + 2 x ( e 3 x e 3 y + t 3 e 3 z ) z = z ( t 3 2 e 3 x 2 e 3 y 2 + e 3 z 2 ) + 2 x ( e 3 x e 3 z t 3 e 3 y ) + 2 y ( e 3 y e 3 z + t 3 e 3 x )
Equations (27)–(29) could be considered as the description of the orientation with Euler angles, but in a rational way, since they do not contain any transcendental functions. The parameters involved in the calculation of the orientation are t n and e n , where t n is a parameter obtained with Equation (2).
Vector e = ( e n x , e n y , e n z ) corresponds to the axis of rotation on which each half-turn acts. The values x , y , and z represent the coordinates of the resulting vector oriented according to the three parameters of half-turns entered by the user. As a result, Equations (21)–(23) represent an alternative to model the orientation without the need to involve trigonometric functions.
For Euler angle implementation, we used a graphical software called GeoGebra. Figure 8a,b show the implementation of intrinsic and extrinsic rotation, respectively. On other hand, Figure 8c exhibits the classical implementation of Euler angles using Equations (24)–(26). Finally, Figure 8d displays the rational replacement for Euler angles using Equations (27)–(29). The simulation of the wrist mechanism with dual quaternions is presented in Figure 9a. Additionally, the rotation algorithms for one axis were implemented in an Arduino-nano board, in order to prove how they work in real life after compiling them in the Arduino IDE software, as pictured in Figure 9b.

6.2. Hardware Implementation

As mentioned in the above section, software simulation was done using GeoGebra. Hardware implementation was done with an Intel FPGA using the rational analog for Euler angles (half-turn).
For hardware implementation, we used a 16-bit fixed-point architecture, where the integer part has eight bits (one bit for the sign and seven bits for the half-turn) and the other eight bits are for the fractional part of the half-turn. Table 1 shows the relation between the number of bits of the integer part and the maximum angle rotation in degrees that can be represented. Notice that we are describing the amount of rotation in “half-turn”, but in Table 1, this amount is expressed in degrees for didactic reasons.
The first column begins with two bits because the integer part always has one bit for the sign. Table 2 shows the relation between the number of bits of the fractional part and the minimum angle rotation in degrees that can be represented.
The first step for computing the final orientation of the gimbal mechanism is to find the rotation generated through a single axis. However, to easily calculate the final orientation of each rotation, we must compute the coefficients involved in each. Figure 10 depicts how to compute the rational replacements for the transcendental functions sine and cosine according to Equation (5). Notice that output A is the rational analog for the sine function and output B is the rational analog for the cosine function.
Because the gimbal mechanism uses the Euler angles in the z-y-z sequence, we can compute the final orientation using the modules presented in Figure 11. The module displayed in Figure 11a computes the rotation on the z- a x i s and the module shown in Figure 11b computes the rotation on the y- a x i s . Notice that the module named “FACTOR” is the module depicted in Figure 10.
Finally, using modules shown in Figure 11, we can compute the final orientation of the gimbal mechanism as exhibited below in Figure 12.
In order to compare the classical and rational methods, we contrast how many operations are involved for each one, as shown in Table 3 and Table 4. Although sin θ , cos θ , and square root are transcendental functions, we treated them separately due to the complexity that each one requires for its calculation in hardware.

7. Conclusions

Rational trigonometry provides an efficient alternative to represent rotations in 3 D space using quaternions. The implementations we made are more compact than those that would result from implementing the calculation of the orientation using rotation matrices and the CORDIC algorithm.
The use of rational trigonometry eases the computation of orientation, since there are no transcendental functions involved. Using quaternions in the rational form leads to an efficient and compact description of any robotic mechanism in real life. However, the only drawback is that we cannot parameterize a joint range of 360 , since the behavior of the “half-turn” is asymptotic. Still, with a relatively low number of bits, we can describe joint ranges greater than 350 (e.g., 7 bits = 358 . 18 ). Therefore, for practical applications, the proposed model is very useful. It is essential to point out that an architecture with more bits, e.g., 32 bits, would be required to improve the computation accuracy of the orientation.
The first model, called the “gimbal mechanism”, was simulated in GeoGebra software and implemented on an Arduino microcontroller to prove its operation. The second model, “wrist mechanism”, was also simulated in GeoGebra and implemented on an Arduino to verify its operation. Only the first model was implemented in hardware to compare the number of logic elements between classical and rational implementations. Both models are the continuation of research carried out by the authors [32], where some rational algorithms were obtained for calculating the direct and inverse kinematic for robotic mechanisms, showing that in a hardware implementation, these algorithms are more efficient.

Author Contributions

Methodology and investigation, R.M.; formal analysis and supervision, E.Z.; funding acquisition, H.S.; visualization, writing—review and editing, F.A.; writing, L.A.S. All authors have read and agreed to the published version of the manuscript.

Funding

This work was economically supported by the Instituto Politécnico Nacional under projects: 20200630, 20200651, 20210316, 20210788, 20220226, and 20220002, and CONACYT under projects 65 (Fronteras de la Ciencia) and 6005 (FORDECYT-PRONACES).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Acknowledgments

E.Z. and H.S. would like to acknowledge the support provided by CIC-IPN in carrying out this research, and F.A. would like to thank the Centro de Investigaciones en Óptica A.C. The first author thanks CONACYT for the scholarship granted towards pursuing his PhD studies.

Conflicts of Interest

The authors declare no conflict of interest.

Appendix A

In rational theory, there are some fundamental concepts; for instance, quadrance measures the separation between two points. The quadrance Q A 1 , A 2 between the points A 1 [ x 1 , y 1 , z 1 ] and A 2 [ x 2 , y 2 , z 2 ] is the number:
Q ( A 1 , A 2 ) = x 2 x 1 2 + y 2 y 1 2 + z 2 z 1 2
where x 1 , x 2 , y 1 and y 2 are the coordinates of points A 1 and A 2 , respectively, and they are rational numbers or even real numbers. By making a relationship between classical and rational trigonometry, the quadrance can be seen as the square of the Euclidean distance:
Q ( A 1 , A 2 ) = d ( A 1 , A 2 ) 2 .
Since the quadrance is the rational analog for distance, it makes sense to wonder, what is the rational analog for angle notion? The answer includes three rational replacements for angle, which are spread, turn, and half-turn. We only focus on the turn and half-turn in developing our experiments. Figure A1 compares these three rational measures for rotations in the plane.
Figure A1. Rational analogs for angle.
Figure A1. Rational analogs for angle.
Machines 10 00749 g0a1
Let z = a + b i be a complex number and z ¯ = a b i be its complex conjugate, where a = R e ( z ) and b = I m ( z ) . We can define the quadrance of z by:
Q ( z ) = z · z ¯ = a 2 + b 2 .
The definitions of the rational replacements for angle are explained as follows:
Turn: The turn of any complex number z is defined as:
u ( z ) b a
In a more general case, to compute the turn between two different complex numbers z 1 = a 1 + b 1 i and z 2 = a 2 + b 2 i as shown in Figure A1a, we need to apply:
u u ( z 1 , z 2 ) a 1 b 2 a 2 b 1 a 1 a 2 + b 1 b 2 .
Half-turn: For any complex number z on the unit circle, except the point [ 1 , 0 ] , the half-turn is the intersection between the y-axis and the line through the points [ 1 , 0 ] and z, as shown in Figure A1b. Therefore, the half-turn is defined by:
h ( z ) h .
In order to make an analogy between turns and half-turns, we will translate the orange line from the point [ 1 , 0 ] to the origin, as presented in Figure A1b. Notice that the separation between the points [ 1 , h ] and the x- a x i s is exactly half of the separation between the points [ 1 , u ] and the x- a x i s . This is true for any complex number on the unit circle, except the point [ 1 , 0 ] , and this is the reason why these parameters are called turns and half-turns.
Spread: The spread can be defined in several ways. According to Figure A1c, the spread is determined by:
s ( z ) b 2
where z is a unit complex number and b = I m ( z ) . However, in a more general way, the spread can be specified for any complex number by the next expression:
s ( w ) b 2 a 2 .

Rotations on the Plane

For every z C , we may associate a rotation φ z given by:
φ z ( w ) = z 2 w Q ( z ) = z · z · w z · z ¯ = z w z ¯
and in the same way, for each rotation, we can assign a complex number.
As in a stereographic projection, we make a rational parameterization for a circle:
z 2 Q ( z ) = 1 h 2 1 + h 2 + 2 h 1 + h 2 i
Figure A2a represents the stereographic projection in the complex plane of the circumference, centered at the origin with a radius equal to 1 on the straight-line z = 1 + t i . According to Equation (A7), h ( z ) is defined as the point [ 0 , h ] , resulting from the intersection between the y-axis and the line that goes from the point [ 1 , 0 ] to the point z = a + b i . On the other hand, u ( z ) can be described geometrically as the point of coordinates [ 1 , u ] from the intersection between the line that goes from the center of the circumference to the point z = a + b i and the line z = 1 + t i . Finally, if we move the orange line, created when defining h ( z ) , to the origin of the coordinates, we observe that the intersection of this line and the straight line z = 1 + t i occurs at the point ( 1 , h ) . In summary, Figure A2a shows the stereographic projection of the circle on the complex line z = 1 + t i , and Figure A2b displays the values obtained with the rational parameterization of the circumference using Equation (A10).
Additionally, as shown in Figure A2a, every point on the unit circle, except the point [ 1 , 0 ] , can be mapped over the line z = 1 + h i , and every point on the line can be associated with only one point on the unit circle, where h is the parameter half-turn defined above. The point [ 1 , 0 ] is the only one that does not have a projection on the line, since this point can correspond to ± , depending on the direction from which you approach the point. The rational parameterization of the circle, according to Equation (A10), lets us describe almost any point of a circle with radius one, centered on the point [ 0 , 0 ] , as presented in Figure A2b. This parameterization will help us to develop the quaternions in a rational way.
Figure A2. Rational parameterization of the unit circle. (a) Representation of the stereographic projection for the unit circumference. (b) Some points on the unit circle according to the half-turn parameter.
Figure A2. Rational parameterization of the unit circle. (a) Representation of the stereographic projection for the unit circumference. (b) Some points on the unit circle according to the half-turn parameter.
Machines 10 00749 g0a2
Example: Find the points on the unit circle when t = 0 , 1 , 2 , 3 , Figure A2b:
f o r t = 0 1 0 2 1 + 0 2 + 2 · 0 1 + 0 2 i = 1 + 0 · i = ( 1 , 0 ) , f o r t = 1 1 1 2 1 + 1 2 + 2 · 1 1 + 1 2 i = 0 + i = ( 0 , 1 ) , f o r t = 2 1 2 2 1 + 2 2 + 2 · 2 1 + 2 2 i = 3 5 + 4 5 i = ( 3 5 , 4 5 ) , f o r t = 3 1 3 2 1 + 3 2 + 2 · 3 1 + 3 2 i = 8 10 + 6 10 i = ( 4 5 , 3 5 ) .

References

  1. Arrigo, J.; Chau, P. Accurate motion capture at high rotational rates using the CORDIC algorithm. In Proceedings of the Thrity-Seventh Asilomar Conference on Signals, Systems and Computers, Pacific Grove, CA, USA, 9–12 November 2003; Volume 2, pp. 2203–2207. [Google Scholar]
  2. Lang, T.; Antelo, E. High-throughput 3D rotations and normalizations. In Proceedings of the Conference Record of Thirty-Fifth Asilomar Conference on Signals, Systems and Computers (Cat. No. 01CH37256), Pacific Grove, CA, USA, 4–9 November 2001; Volume 1, pp. 846–851. [Google Scholar]
  3. Biswas, D.; Ye, Z.; Mazomenos, E.B.; Jöbges, M.; Maharatna, K. CORDIC framework for quaternion-based joint angle computation to classify arm movements. In Proceedings of the 2018 IEEE International Symposium on Circuits and Systems (ISCAS), Vancouver, BC, Canada, 23–26 May 2018; pp. 1–5. [Google Scholar]
  4. Arrigo, J.F.; Chau, P.M. Power aware attitude computation during rapid rotational motion. IEEE Trans. Instrum. Meas. 2006, 55, 63–69. [Google Scholar] [CrossRef]
  5. Osborne, J.; Hicks, G.; Fuentes, R. Global analysis of the double-gimbal mechanism. IEEE Control Syst. Mag. 2008, 28, 44–64. [Google Scholar]
  6. Ahi, B.; Nobakhti, A. Hardware implementation of an ADRC controller on a gimbal mechanism. IEEE Trans. Control Syst. Technol. 2017, 26, 2268–2275. [Google Scholar] [CrossRef]
  7. Choi, C.L.; Rebello, J.; Koppel, L.; Ganti, P.; Das, A.; Waslander, S.L. Encoderless gimbal calibration of dynamic multi-camera clusters. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), Brisbane, Australia, 21–25 May 2018; pp. 2126–2133. [Google Scholar]
  8. Rajesh, R.; Kavitha, P. Camera gimbal stabilization using conventional PID controller and evolutionary algorithms. In Proceedings of the 2015 International Conference on Computer, Communication and Control (IC4), Indore, India, 10–12 September 2015; pp. 1–6. [Google Scholar]
  9. Lo, Y.L.; Li, Y.C.; Kim, Y.C. Downstream interference effect of low-Scruton-number high-rise buildings under turbulent boundary layer flow. J. Wind Eng. Ind. Aerodyn. 2020, 198, 104101. [Google Scholar] [CrossRef]
  10. Altan, A.; Hacıoğlu, R. Model predictive control of three-axis gimbal system mounted on UAV for real-time target tracking under external disturbances. Mech. Syst. Signal Process. 2020, 138, 106548. [Google Scholar] [CrossRef]
  11. Zheng, P.; Tan, X.; Kocer, B.B.; Yang, E.; Kovac, M. TiltDrone: A Fully-Actuated Tilting Quadrotor Platform. IEEE Robot. Autom. Lett. 2020, 5, 6845–6852. [Google Scholar] [CrossRef]
  12. Craig, J.J. Introduction to Robotics: Mechanics and Control; Pearson Educacion: London, UK, 2005. [Google Scholar]
  13. Fu, Z.; Pan, J.; Spyrakos-Papastavridis, E.; Chen, X.; Li, M. A Dual Quaternion-Based Approach for Coordinate Calibration of Dual Robots in Collaborative Motion. IEEE Robot. Autom. Lett. 2020, 5, 4086–4093. [Google Scholar] [CrossRef]
  14. Rodman, L. Topics in quaternion linear algebra. In Topics in Quaternion Linear Algebra; Princeton University Press: Princeton, NJ, USA, 2014. [Google Scholar]
  15. Morais, J.P.; Georgiev, S.; Sprößig, W. Real Quaternionic Calculus Handbook; Springer: Berlin/Heidelberg, Germany, 2014. [Google Scholar]
  16. Kavan, L.; Collins, S.; O’Sullivan, C.; Zara, J. Dual Quaternions for Rigid Transformation Blending; Technical report; Trinity College Dublin: Dublin, Ireland, 2006. [Google Scholar]
  17. Ma, R.; Gupta, K.C. On the motion of oblique bevel geared robot wrists. J. Robot. Syst. 1989, 6, 509–520. [Google Scholar] [CrossRef]
  18. Zhang, H. Feasibility analysis of displacement trajectories for robot manipulators with a spherical wrist. In Proceedings of the 1991 IEEE International Conference on Robotics and Automation, Sacramento, CA, USA, 9–11 April 1991; pp. 1252–1257. [Google Scholar]
  19. Jo, H.M.; Lim, D.J.; Chung, W.J.; Choi, J.K.; Kim, D.Y.; Ahn, Y.J.; Ahn, H.S. Optimal wrist design of wrist-hollow type 6-axis articulated robot using genetic algorithm. In Proceedings of the 2018 IEEE International Conference on Mechatronics and Automation (ICMA), Jilin, China, 5–8 August 2018; pp. 1486–1491. [Google Scholar]
  20. Bailly, F.; Charbonneau, E.; Danès, L.; Begon, M. Optimal 3D arm strategies for maximizing twist rotation during somersault of a rigid-body model. Multibody Syst. Dyn. 2021, 52, 193–209. [Google Scholar] [CrossRef]
  21. Chu, C.Y.; Xu, J.Y.; Lan, C.C. Design and experiment of a compact wrist mechanism with high torque density. Mech. Mach. Theory 2014, 78, 65–80. [Google Scholar] [CrossRef]
  22. Cheng, L.; Wang, H.; Liu, Y. Movement coupling analysis on the wrist of 165Kg spot welding robot. In Proceedings of the 2011 IEEE International Conference on Cyber Technology in Automation, Control, and Intelligent Systems, Kunming, China, 20–23 May 2011; pp. 244–248. [Google Scholar]
  23. Hildenbrand, D. Foundations of geometric algebra computing. In Proceedings of the AIP Conference Proceedings, Ft. Worth, TX, USA, 5–10 August 2012; American Institute of Physics: College Park, MD, USA; Volume 1479, pp. 27–30. [Google Scholar]
  24. Cao, Y.; Ji, W.; Li, Z.; Zhou, H.; Liu, M. Orientation-singularity and nonsingular orientation-workspace analyses of the stewart-gough platform using unit quaternion representation. In Proceedings of the 2010 Chinese Control and Decision Conference, Xuzhou, China, 26–28 May 2010; pp. 2282–2287. [Google Scholar]
  25. Wang, C.; Fu, Z. A new way to detect the position and orientation of the wheeled mobile robot on the image plane. In Proceedings of the IEEE International Conference on Robotics and Biomimetics (ROBIO 2014), Bali, Indonesia, 5–10 December 2014; pp. 2158–2162. [Google Scholar]
  26. Paulraj, M.; Ahmad, R.B.; Hema, C.; Hashim, F.; Yusoff, S. Active stereo vision based system for estimation of mobile robot orientation using affine moment invariants. In Proceedings of the 2008 International Conference on Electronic Design, Penang, Malaysia, 1–3 December 2008; pp. 1–7. [Google Scholar]
  27. Wildberger, N. A rational approach to trigonometry. Math Horizons 2007, 15, 16–20. [Google Scholar] [CrossRef]
  28. Wildberger, N.J. Divine Proportions: Rational Trigonometry to Universal Geometry; Wild Egg: Sydney, Australia, 2005. [Google Scholar]
  29. Jia, Y.B. Quaternions and rotations. Com. S 2008, 477, 15. [Google Scholar]
  30. Kenwright, B. A beginners guide to dual-quaternions: What they are, how they work, and how to use them for 3D character hierarchies. In Proceedings of the 20th International Conference in Central Europe on Computer Graphics, Visualization and Computer Vision 2012, Plzen, Czech Republic, 26–28 June 2012; pp. 1–10. [Google Scholar]
  31. Paul, R.P. Robot Manipulators: Mathematics, Programming, and Control: The Computer Control of Robot Manipulators; The MIT Press: Cambridge, MA, USA, 1981. [Google Scholar]
  32. Peralta, R.M.; Gómez, E.Z.; Azuela, J.H.S. Efficient FPGA hardware implementation for robot manipulator kinematic modeling using rational trigonometry. IEEE Lat. Am. Trans. 2019, 17, 1524–1536. [Google Scholar] [CrossRef]
Figure 1. Representation of four-dimensional space. (a) 4D space where the blue sphere represents an S3 sphere, the red sphere describes an S2 sphere, and q is a quaternion on the 4D space. (b) 4D space where the V space in green is equal to a 3D space and the t-axis is orthogonal to this space.
Figure 1. Representation of four-dimensional space. (a) 4D space where the blue sphere represents an S3 sphere, the red sphere describes an S2 sphere, and q is a quaternion on the 4D space. (b) 4D space where the V space in green is equal to a 3D space and the t-axis is orthogonal to this space.
Machines 10 00749 g001
Figure 2. Decomposition of 4D space.
Figure 2. Decomposition of 4D space.
Machines 10 00749 g002
Figure 3. Spherical wrist mechanism for orientation of a robot manipulator.
Figure 3. Spherical wrist mechanism for orientation of a robot manipulator.
Machines 10 00749 g003
Figure 4. Kinds of rotations.
Figure 4. Kinds of rotations.
Machines 10 00749 g004
Figure 5. Kinds of rotations.
Figure 5. Kinds of rotations.
Machines 10 00749 g005
Figure 6. Orientation change.
Figure 6. Orientation change.
Machines 10 00749 g006
Figure 7. Development of transformations for the rational orientation model.
Figure 7. Development of transformations for the rational orientation model.
Machines 10 00749 g007
Figure 8. Simulation of different rotation techniques. (a) Intrinsic rotation, where rotations were performed around the body reference frame with parameters ϕ = 111°, ɵ = 67°, and φ = 60°. (b) Extrinsic rotation, where rotations were performed around the general reference frame with parameters ϕ = 60°, ɵ = 67°, and φ = 111°. (c) Classical rotation algorithm with three parameters given in angles. (d) Rational rotation algorithm with three parameters given in rational form (half-turns).
Figure 8. Simulation of different rotation techniques. (a) Intrinsic rotation, where rotations were performed around the body reference frame with parameters ϕ = 111°, ɵ = 67°, and φ = 60°. (b) Extrinsic rotation, where rotations were performed around the general reference frame with parameters ϕ = 60°, ɵ = 67°, and φ = 111°. (c) Classical rotation algorithm with three parameters given in angles. (d) Rational rotation algorithm with three parameters given in rational form (half-turns).
Machines 10 00749 g008
Figure 9. Simulation for the spherical wrist mechanism.
Figure 9. Simulation for the spherical wrist mechanism.
Machines 10 00749 g009
Figure 10. FACTOR module for computing coefficients.
Figure 10. FACTOR module for computing coefficients.
Machines 10 00749 g010
Figure 11. Modules to compute rotations in a rational way.
Figure 11. Modules to compute rotations in a rational way.
Machines 10 00749 g011
Figure 12. Orientation module for the gimbal mechanism.
Figure 12. Orientation module for the gimbal mechanism.
Machines 10 00749 g012
Table 1. Relation between bits for the integer part and half-turns in degrees.
Table 1. Relation between bits for the integer part and half-turns in degrees.
BitsMaximum ValueHalf-Turn (Degrees)
21 ± 90
33 ± 143 . 13
47 ± 163 . 74
515 ± 172 . 37
631 ± 176 . 30
763 ± 178 . 18
8127 ± 179 . 1
Table 2. Relation between bits for the fractional part and half-turns in degrees.
Table 2. Relation between bits for the fractional part and half-turns in degrees.
BitsMaximum ValueHalf-Turn (Degrees)
10.5 ± 53 . 13
20.25 ± 28 . 07
30.125 ± 14 . 25
40.0625 ± 7 . 15
50.3125 ± 3 . 58
60.015625 ± 1 . 79
70.0078125 ± 0 . 9
80.00390625 ± 0 . 45
Table 3. Number of operations for each rotation computation.
Table 3. Number of operations for each rotation computation.
OperationRational MethodClassical Method
±45
×612
÷22
sin θ 01
cos θ 01
· 01
Table 4. Total number of operations for orientation computing.
Table 4. Total number of operations for orientation computing.
OperationRational MethodClassical Method
±1215
×1836
÷66
sin θ 03
cos θ 03
· 03
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Martínez, R.; Zamora, E.; Sossa, H.; Arce, F.; Soriano, L.A. Orientation Modeling Using Quaternions and Rational Trigonometry. Machines 2022, 10, 749. https://doi.org/10.3390/machines10090749

AMA Style

Martínez R, Zamora E, Sossa H, Arce F, Soriano LA. Orientation Modeling Using Quaternions and Rational Trigonometry. Machines. 2022; 10(9):749. https://doi.org/10.3390/machines10090749

Chicago/Turabian Style

Martínez, Rogelio, Erik Zamora, Humberto Sossa, Fernando Arce, and Luis Arturo Soriano. 2022. "Orientation Modeling Using Quaternions and Rational Trigonometry" Machines 10, no. 9: 749. https://doi.org/10.3390/machines10090749

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop