Next Article in Journal
Symmetrical Hardware-Software Design for Improving Physical Activity with a Gamified Music Step Sensor Box
Next Article in Special Issue
Consensus of Fixed and Adaptive Coupled Multi-Agent Systems with Communication Delays
Previous Article in Journal
Design of Cost-Efficient SRAM Cell in Quantum Dot Cellular Automata Technology
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Formal Verification of Robot Rotary Kinematics

1
College of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics, Nanjing 211106, China
2
College of Computer, National University of Defense Technology, Changsha 410073, China
*
Author to whom correspondence should be addressed.
Electronics 2023, 12(2), 369; https://doi.org/10.3390/electronics12020369
Submission received: 20 November 2022 / Revised: 30 December 2022 / Accepted: 7 January 2023 / Published: 11 January 2023

Abstract

:
With the widespread application of robots in aerospace, medicine, automation, and other fields, their motion safety is essential for the well-being of humans and the accomplishment of vital socially beneficial programs. Conventional robot hardware and software designs mainly rely on experiential knowledge and manual testing to ensure safety, but this fails to cover all possible testing paths and adds risks. Alternatively, formal, mathematically rigorous verifications can provide predictable and reliable guarantees of robot motion safety. To demonstrate the feasibility of this approach, we formalize the mathematical coordinate transformation of a robot’s rigid-body kinematics using the Coq Proof Assistant to verify the correctness of its theoretical design. First, based on record-type matrix formalization, we define and verify a robot’s spatial geometry by constructing formal expressions of the matrix’ Frobenius norm, trace, and inner product. Second, we divide rotary motion into revolution and rotation construct and provide their formal definitions. Next, we formally verify the rotational matrices of angle conventions (e.g., roll–pitch–yaw and Euler), and we complete the formal verification of the Rodriguez formula to formally verify the correctness of the motion theory in specific rotating kinematics problems. The formal work of this paper has a variety of essential applications and provides a generalizable kinematics analysis framework for robot control system verification. Moreover, it paves the way for automatic programming capabilities.

1. Introduction

In recent years, robots have been adopted in many operational areas that require high safety protocols (e.g., unmanned aerial vehicles (UAVs), surgery, and autonomous driving). Hence, the reliability and safety of robot development have become topics of considerable research interest [1]. Although most robots operate in structured environments with extensive testing and parametric fail-safes, manual testing programs often do not consider all high-risk scenarios, which compounds the risk of unforeseen mishaps. Formal methods [2,3] are crucial for ensuring the reliable design and development of complex robot systems, including their safety measures and fail-safes. Accordingly, our purpose in this research is to introduce a formal method for robot safety verification.
Our focus is on the formal verification of robot rotary kinematics. As an application of kinematic geometry, rotary kinematics [4] describes purely geometric problems (e.g., positions and orientations of robot motions). Thus, robot motion control [5] relies on kinematic descriptions and can be validated mathematically. Our objective is to formally verify the rotary problems of robot kinematics using the Coq Proof Assistant [6,7].
In a robot system, links and manipulators are considered rigid bodies; hence, vector-matrix theory [8,9] can be used to establish a general description of their positions and movements with respect to a global coordinate system, G. Robot manipulators can rotate and move around each other. Thus, the various robot components’ rigid-body coordinate systems ( B 1 , B 2 , …, B n ) along each link are referred to in terms of the generalized local coordinate system, B. Let G be the global coordinate system; B R G represents the transformation of vector r from G to B, and G R B represents the transformation of vector r from B to G. Through B R G and G R B , we can globally define the positions between connecting rods and between the rods and environment.
Formal verification relies on mathematical modeling and deductive reasoning, and it is more rigorous and reliable than empirical and heuristic methods [10,11]. Thus, by formally verifying robot rotary kinematics, we hope to ensure the safety of robot controls and their algorithmic designs. In summary, we apply a formal mathematical method of proof to the detection of “correctness’’ in robot rotary kinematics. The formal framework of robot rotary kinematics is illustrated in Figure 1. First, based on Matrix formalization, we formally define the matrix Frobenius norm, matrix trace, and matrix inner product, providing mathematical formal support for the formal verification of robot rotary kinematics. Then, we divide rotary motion into revolution and rotation, defining their formal representations. Based on this, we perform the formal verification of some common rotary problems, including the Euler angles and Rodriguez formula.
Our contributions can be summarized as follows. First, we expand the formal matrix library based on record type. Specifically, we add formal definitions and proofs of the matrix Frobenius norm, trace, and inner product using a verifiable mathematical process. We divide rotary motion into revolution and rotation, and formally verify the full system coordinate transformation. Moreover, we construct a rotation matrix of angles, which is conventionally used in engineering, to provide the formal definition and verification of Euler angles. Furthermore, we provide the formal definition and verification of the Rodriguez formula. Finally, we demonstrate the applicability of the proposed formal method through case analyses of robot rotary motion problems and demonstrate how to formally verify specific robot rotary problems.
The organization of the paper is as follows: In Section 2, we discuss related works. In Section 3, matrix formalization and rotary kinematics are briefly reviewed. In Section 4, formal spatial geometry verification methods are presented. In Section 5, we formally define “revolution” and “rotation” and verify their pertinent properties. In Section 6 and Section 7, we formally verify Euler angles and the Rodriguez Formula, respectively. In Section 8, we provide case analyses and verify the correctness of their rotary kinematics. Finally, in Section 9, we conclude and discuss future efforts.

2. Related Works

In the field of robot verification, many methods have been proposed in recent years. Ref. [12] focused on the safety of physical human–robot collaboration and proposed a formal verification-based risk analysis method for detecting and modifying hazardous situations early in a model’s design. From a multidisciplinary perspective, ref. [13] developed a two-step verification method by combining formal methods and schedulability analytics, which led to the design of a novel multi-resource locking mechanism for real-time robot services. A drone example was used to demonstrate the benefits of the above approach. Considering that camera pose estimation is a critical component of robot tasks, ref. [14] attempted to formalize and validate the unique and general solutions of pose estimation algorithms using an interactive theorem prover. Some researchers have combined formal validation with a robot operating system (ROS). Based on the formalization of ROS architectural models and node behaviors in Electrum, a formal specification language based on first-order linear temporal logic, ref. [15] integrated their proposed technique into the HAROS framework for the analysis and quality improvement of robotics software. Using a linear logic theorem prover, ref. [16] presented a new technique to formally describe and verify robotic systems to meet the need for an easy-to-use framework for expressing and verifying robot systems in a ROS. In summary, many researchers have applied formal verification methods to various real-world robot applications.
In the industrial domain, ref. [17] studied a representative safety-critical industrial paint robot system from ABB Inc. Through the transfer of hardware abstractions and verification results among tools, they formalized the convergence of a high-voltage system. To meet the demands of user-defined verification goals in robot manufacturing, a layer-based formal scheme was proposed by [18] to support state-space comprehensive verifications.
In healthcare settings, ref. [19] extended the application of formal methods to human modeling using hybrid automata formalism to capture the variability of human behaviors. This resulted in a user-friendly representation that used the Uppaal integrated tool environment for modeling, validation and verification of real-time systems to automatically generate and verify a formal model.
Notably, UAVs and autonomous vehicles are suitable for formal verification. In the context of a distributed UAV scenario representing urban air mobility, ref. [20] constructively provided some insightful ideas to accelerate the development cycle of transforming formally verified models to robotic simulations. To navigate a UAV inside a safety corridor, ref. [21] developed a genetic fuzzy system and demonstrated its adherence to behavior safety specifications. Considering the importance of the formal verification of robotics and autonomous vehicles, ref. [22] developed a binary-search method to extend timed automata models of robotic specifications with dynamic priority schedulers and demonstrated scalability improvements in a real robot case.
Unlike the abovementioned studies, we focus specifically on rotary kinematics problems and use the Coq Proof Assistant [23] to formally verify robot rotary kinematics.

3. Preliminaries

3.1. Matrix Formalization Based on Record Type

Because higher-order theorem provers are based on λ -type calculus, the basic data structure for traditional matrix realization is a λ expression rather than an imperative language version [24]. Hence, the higher-order method is suitable for describing inductive data structures with infinite extensibility (e.g., lists). However, it does not work for data structures with fixed lengths (e.g., vectors and matrices) because there is no direct description method. To make it work, Ma et al. [25] proposed a formal m a t r i x method based on the Coq R e c o r d type to verify matrices of any size. In Coq, the R e c o r d type is a macro that enables the creation of definitions. From this, a m a t r i x definition is expressed as
R e c o r d M a r i x ( m n : n a t ) : S e t : = m k M a t { m a t : l i s t ( l i s t A ) ; m a t _ l e n g t h : l e n g t h m a t = m ; m a t _ a l l _ l e n : a l l _ l e n _ n m a t n ; }
where m a t is a nested list that stores the data of the matrix, and m a t _ l e n g t h and m a t _ a l l _ l e n are matrix attributes indicating that the length of m a t is m and its width is n.

3.2. Rotary Kinematics

Rotary kinematics studies most often use global coordinate system G or local (i.e., rigid-body) coordinate system B to describe robot motion [26]. To verify robot rotary kinematics, we describe the relationship between G and B.
For rigid body D in B, B initially coincides with G. We denote point O as the origin of the coordinate systems [27]. The motion of D around G is “revolution”. In this motion, rigid body D is stationary in B. Hence, for any vector, r, formed by point P and O in D, the equivalence relation of vector r in G and B is given by Formula (1). B r and G r are the algebraic representations of r in B and G, respectively, and Q is the revolution matrix.
G r = Q B r .
For rigid body D in G, the motion of D around B is “rotation”. In this motion, rigid body D is stationary in G. At this time, for any vector, r, formed by points P and O in D, the equivalence relation of r in G and B is given by Formula (2), with A being the rotation matrix [28].
B r = A G r .

4. Formalization of the Spatial Geometry

4.1. Formalization of the Matrix Trace

In linear algebra, the trace of matrix M ( m × m ) is defined as the sum of its diagonal elements, which is also equal to the sum of its eigenvalues, as shown in Formula (3):
t r ( M ) = i = 0 m 1 m i i .
In Coq, we formally solve the matrix trace recursively. In function t r , m is an implicit parameter representing the width of the matrix, and m a is a matrix with dimension m m . In the recursive function body, g e t _ S u m _ t r , the elements along the diagonal of the matrix are obtained and summed using the m a t c h strategy.
D e f i n i t i o n t r { m : n a t } ( m a : M a t R m m ) : = ( f i x g e t _ S u m _ t r ( m 0 n : n a t ) ( Z e r o : R ) ( m a 0 : M a t R m 0 m 0 ) { s t r u c t n } : R : = m a t c h n w i t h | 0 Z e r o | S n g e t _ S u m _ t r m 0 n ( Z e r o + m a t _ n t h m a 0 ( m 0 n 1 ) ( m 0 n 1 ) ) m a 0 e n d ) m m 0 m a .

4.2. Formalization of the Matrix Frobenius Norm

The Frobenius norm, also known as the F-norm, represents the length of a matrix for an intuitive understanding of matrix theory. Its definition in matrix space R m n is given by Formula (4):
| X | F = i = 0 m 1 j = 0 n 1 x i j 2 s . t . x i j X
Accordingly, the formal definition of the F-norm is given next. The recursive function, g e t _ S u m 1 , inputs list h as a real-number type and outputs the sum of the squares of all elements in the list. Recursive function g e t _ S u m 2 inputs nested list l l as a real-number type and provides the sum of the squares of all elements by calling g e t _ S u m 1 . Function F r o b e n i u s has an input matrix-type parameter, m a , with m rows and n columns, and function m a t provides the data elements as matrix types.
D e f i n i t i o n F r o b e n i u s { m n : n a t } ( m a : M a t R m n ) : = l e t l l : = ( m a t R m n m a ) i n s q r t ( ( f i x g e t _ S u m 2 ( l : l i s t ( l i s t R ) ) : R : = m a t c h l w i t h | [ ] = > 0 | h : : t = > ( f i x g e t _ S u m 1 ( l 0 : l i s t R ) : R : = m a t c h l 0 w i t h | [ ] = > 0 | h 0 : : t 0 = > h 0 h 0 + g e t _ S u m 1 t 0 e n d ) h + g e t _ S u m 2 t e n d ) l l ) .
In Coq, we use N o t a t i o n to define the Frobenius infix notation.
N o t a t i o n | m a | : = ( F r o b e n i u s m a ) ( a t l e v e l 70 ) .
Through the definition of Frobenius, we can formally verify the properties of special matrices.
Lemma 1.
The F-norm of a zero matrix is zero.
L e m m a l e m m a 1 : f o r a l l m n : n a t ( m a : M a t R m n ) , m a = R M a t r i x . M O m n | m a | = 0 .
Lemma 2.
The F-norm of an n-dimensional identity matrix is n .
L e m m a l e m m a 2 : f o r a l l n : n a t ( m a : M a t R n n ) , m a = R M a t r i x . M I n | m a | = s q r t n .

4.3. Formalization of the Matrix Inner Product

The inner product of matrices in matrix space R m n is given by Formula (5), where x i j X , y i j Y :
X · Y = i = 0 m 1 j = 0 n 1 x i j y i j .
Accordingly, the matrix inner product is formally defined as
D e f i n i t i o n D o t _ P r o d u c t { m n : n a t } ( m a m b : M a t R m n ) : = l e t m a : = ( m a t R m n m a ) i n l e t m b : = ( m a t R m n m b ) i n ( f i x g e t _ S u m 2 ( l a a l b b : l i s t ( l i s t R ) ) { s t r u c t l a a } : R : = m a t c h l a a w i t h | [ ] = > 0 | h a a : : l a a = > m a t c h l b b w i t h | [ ] = > 0 | h b b : : l b b = > ( f i x g e t _ S u m 1 ( l a l b : l i s t R ) { s t r u c t l a } : R : = m a t c h l a w i t h | [ ] = > 0 | h a : : l a = > m a t c h l b w i t h | [ ] = > 0 | h b : : l b = > h a h b + g e t _ S u m 1 l a l b e n d e n d ) h a a h b b + g e t _ S u m 2 l a a l b b e n d e n d ) m a m b .
Similar to the definition of F r o b e n i u s , D o t _ P r o d u c t also uses two recursive functions to calculate the matrix inner product. The infix notation of D o t _ P r o d u c t is expressed as
N o t a t i o n m 1 · m 2 " : = ( D o t _ P r o d u c t m 1 m 2 ) ( a t l e v e l 70 ) .
We formally verify the commutative and associative laws of the matrix inner product in the following lemmas.
Lemma 3.
In matrix space R m n , m a · m b = m b · m a .
L e m m a l e m m a 3 : f o r a l l { m n : n a t } ( m a m b : M a t R m n ) , ( m a · m b ) = ( m b · m a ) .
Lemma 4.
In matrix space R m n , for k being a constant of type R , ( k m a ) · m b = k ( m a · m b ) .
L e m m a l e m m a 4 : f o r a l l { m n : n a t } ( k : R ) ( m a m b : M a t R m n ) , ( ( k × m a ) · m b ) = k ( m a · m b ) .
Lemma 5.
In matrix space R m n , ( m a + m b ) · m c = m a · m c + m b · m c .
L e m m a l e m m a 5 : f o r a l l { m n : n a t } ( m a m b m c : M a t R m n ) , ( m a + m b ) · m c = ( m a · m c ) + ( m b · m c ) .

4.4. Vector Formalization

Because a vector is a special kind of matrix with a row or column of dimension 1, we formally define it as follows:
D e f i n i t i o n R _ v e c t o r ( n : n a t ) : = M a t R n 1 .
Let m 1 and m 2 be any vector in space and θ be the angle between m 1 and m 2 . The equivalence relation between the inner product and F-norm of a vector is given by Formula (6):
m 1 · m 2 = | m 1 | F | m 2 | F cos θ .
We formalize the equivalence relation in Formula (6), where < < m 1 , m 2 > > represents the angle between m 1 and m 2 .
Lemma 6.
Formal verification of Formula (6).
L e m m a l e m m a 6 : f o r a l l n : n a t ( m 1 m 2 : ( R _ v e c t o r n ) ) , ( m 1 · m 2 ) = ( | m 1 | | m 2 | ) cos ( < < m 1 , m 2 > > ) .

5. Formalization of the Rotary Kinematics

5.1. Global and Local Coordinate Systems

Because the formalization of the coordinate system is the basis for the formal verification of robot kinematics, we provide relative definitions. We use R A G to define global coordinate system G as a type with three constructors, X , Y , and Z , which correspond to the X, Y, and Z axes, respectively.
I n d u c t i v e R A G : T y p e : = | X | Y | Z .
Analogously, we use R A B to define local coordinate system B, where the three constructors, x, y, and z, in B corresponds to the x, y, and z axes, respectively.
I n d u c t i v e R A B : T y p e : = | x | y | z .
Figure 2 illustrates the two coordinate systems. Given any r, G r and B r are the representations of r in G and B, respectively. Additionally, X 1 , Y 1 , and Z 1 are the coordinates of r in G, whereas x 1 , y 1 , and z 1 are the coordinates of r in B. Therefore, the r in G and B can be expressed using Formula (7), where I, J, and K are the direction vectors of G, and i, j, and k are the direction vectors of B.
G r = X 1 I + Y 1 J + Z 1 K B r = x 1 i + y 1 j + z 1 k
We formally define Formula (7) as follows:
V a r i a b l e X 1 Y 1 Z 1 x 1 y 1 z 1 : R . D e f i n i t i o n G r : = X 1 × I + Y 1 × J + Z 1 × K . D e f i n i t i o n B r : = x 1 × i + y 1 × j + z 1 × k .
Then, a x i o m 1 and a x i o m 2 describe the relations of r in G and B. Therefore, the geometric meanings of B r · I , B r · J , and B r · K are expressed as the projection length of vector B r on I, J, and K, respectively. Similarly, the geometric meanings of G r · i , G r · j , and G r · k are expressed as the projection length of vector G r on i, j, and k, respectively.
A x i o m a x i o m 1 : X 1 = ( B r · I ) Y 1 = ( B r · J ) Z 1 = ( B r · K ) . A x i o m a x i o m 2 : x 1 = ( G r · i ) y 1 = ( G r · j ) z 1 = ( G r · k ) .

5.2. Formalization of Rotary Motion

5.2.1. Formalization of Revolution Motion

According to Formula (1), the formal definition of revolution matrix Q is as follows. I, J, K, i, j, and k are unit vectors with F-norms of one (Formula (4)). The column vector of matrix Q represents the cosine of the angle between each coordinate axis in B and G (Formula (6)).
D e f i n i t i o n Q : = m k M a t _ 3 _ 3 ( i · I ) ( j · I ) ( k · I ) ( i · J ) ( j · J ) ( k · J ) ( i · K ) ( j · K ) ( k · K ) .
Based on this definition, we formally verify Formula (1) as follows:
Theorem 1.
Formal verification of Formula (1)
T h e o r e m t h e o r e m 1 : G r = Q × B r .
According to the definition of R A G , it can be divided into three cases (see Figure 3). Figure 3a shows the position relation between the two coordinate systems after D (a rigid body) rotates around the X axis of G (global coordinate system), where P is any vector in B. Similarly, Figure 3b,c show the position relationship between the two coordinate systems after D rotates around the Y and Z axes of G.
According to Figure 3, we formally define the corresponding revolution matrix as follows:
D e f i n i t i o n Q X ( γ : R ) : = m k M a t _ 3 _ 3 1 0 0 0 ( c o s γ ) ( ( s i n γ ) ) 0 ( s i n γ ) ( c o s γ ) D e f i n i t i o n Q Y ( β : R ) : = m k M a t _ 3 _ 3 ( c o s β ) 0 ( s i n β ) 0 1 0 ( ( s i n β ) ) 0 ( c o s β )
D e f i n i t i o n Q Z ( α : R ) : = m k M a t _ 3 _ 3 ( c o s α ) ( ( s i n α ) ) 0 ( s i n α ) ( c o s α ) 0 0 0 1
We use the following theorems to formally verify the equivalence of matrices Q and QX ( QY and QZ ).
Theorem 2.
When B rotates by angle γ around the X axis of G, Q = ( QX γ ).
T h e o r e m t h e o r e m 2 : f o r a l l ( a x i s : R A G ) , a x i s = X Q = ( Q X γ ) .
Theorem 3.
When B rotates by angle γ around the X axis of G, G r = ( QX γ ) B r .
T h e o r e m t h e o r e m 3 : f o r a l l ( a x i s : R A G ) , a x i s = X G r = ( Q X γ ) × B r .
Theorem 4.
When B rotates by angle β around the Y axis of G, Q = ( QY β ) .
T h e o r e m t h e o r e m 4 : f o r a l l ( a x i s : R A G ) , a x i s = Y Q = ( Q Y β ) .
Theorem 5.
When B rotates by angle β around the Y axis of G, G r = ( QY β ) B r .
T h e o r e m t h e o r e m 5 : f o r a l l ( a x i s : R A G ) , a x i s = Y G r = ( Q Y β ) × B r .
Theorem 6.
When B rotates by angle α around the Z axis of G, Q = ( QZ α ) .
T h e o r e m t h e o r e m 6 : f o r a l l ( a x i s : R A G ) , a x i s = Z Q = ( Q Z α ) .
Theorem 7.
When B rotates by angle α around the Z axis of G, G r = ( QZ α ) B r .
T h e o r e m t h e o r e m 7 : f o r a l l ( a x i s : R A G ) , a x i s = Z G r = ( Q Z α ) × B r .
After B undergoes a finite number of continuous revolutions, Q 1 , Q 2 , Q 3 , , Qn , around R A G , the equivalence relation between r in G and B is given by Formula (8):
G r = ( Q n ( Q 2 ( Q 1 B r ) ) ) .
Therefore, we formally define Formula (8) by C R G recursively. Thus, r l is a list containing pair-type elements, with the first and last elements recording the revolution type and angle, respectively. B r is the vector’s initial position.
F i x p o i n t C R G ( r l : l i s t ( R A G R ) ) ( B r : R _ v e c t o r 3 ) : = m a t c h r l w i t h | n i l B r | h : : l l e t M = ( g e t _ Q ( f s t h ) ( s n d h ) ) i n l e t B r = M × B r i n C R G l B r e n d .
In C R G , the recursive structure first judges r l . If r l is empty, the function returns the received B r ; otherwise, the function provides revolution matrix M through function g e t _ Q by multiplying M with B r while regarding the product as new position B r . Then, the recursive structure uses l and B r to continue the recursion. g e t _ Q is formally defined as follows:
D e f i n i t i o n g e t _ Q ( a x i s : R A G ) ( θ : R ) : = m a t c h a x i s w i t h | X ( Q X θ ) | Y ( Q Y θ ) | Z ( Q Z θ ) e n d .
We synthesize the finite continuous revolutions around R A G into one revolution around a specific line. The synthesized revolution matrix is the global revolution matrix, G Q B , given by Formula (9):
G Q B = Q n Q 2 Q 1 G r = G Q B B r
We formally define the global revolution matrix as follows, where function C m l represents the left multiplication of the matrix in list m l :
D e f i n i t i o n G Q B ( m l : l i s t ( R A G R ) ) : = ( f i x C m l ( m a t L i s t : l i s t ( R A G R ) ) ( r e s : M a t R 3 3 ) { s t r u c t m a t L i s t } : M a t R 3 3 : = m a t c h m a t L i s t w i t h | [ ] r e s | h : : l C m l l ( g e t _ Q ( f s t h ) ( s n d h ) × r e s ) e n d ) m l ( R M a t r i x . M I 3 ) .
Based on this definition, we formally verify Formula (9) as l e m m a 7 :
Lemma 7.
When r l = [ Q 1 Q 2 Q n ] is an arbitrary rotation sequence, r is the initial location in B, ( Q n ( Q 2 ( Q 1 r ) ) ) = ( Q n Q 2 Q 1 ) r ..
L e m m a l e m m a 7 : f o r a l l ( r l : l i s t ( R A G R ) ) ( r : R _ v e c t o r 3 ) , C R G r l r = ( G Q B r l ) × r .

5.2.2. Formalization of Rotation Motion

Similar to the definition of a rotation matrix, Q , according to Formula (2), we formally define the rotation matrix A as follows:
D e f i n i t i o n A : = m k M a t _ 3 _ 3 ( I · i ) ( J · i ) ( K · i ) ( I · j ) ( J · j ) ( K · j ) ( I · k ) ( J · k ) ( K · k ) .
Accordingly, we formally verify Formula (2) as follows:
Theorem 8.
Formal verification of Formula (2).
T h e o r e m t h e o r e m 8 : B r = A × G r .
Figure 4 shows three cases in R A B , in which the rotation matrices in Figure 4a–c are defined as A x , A y , and A z , respectively.
D e f i n i t i o n A x ( ψ : R ) : = m k M a t _ 3 _ 3 1 0 0 0 ( c o s ψ ) ( s i n ψ ) 0 ( ( s i n ψ ) ) ( c o s ψ ) D e f i n i t i o n A y ( θ : R ) : = m k M a t _ 3 _ 3 ( c o s θ ) 0 ( ( s i n θ ) ) 0 1 0 ( s i n θ ) 0 ( c o s θ )
D e f i n i t i o n A z ( ϕ : R ) : = m k M a t _ 3 _ 3 ( c o s ϕ ) ( s i n ϕ ) 0 ( ( s i n ϕ ) ) ( c o s ϕ ) 0 0 0 1
We use the following theorems to formally verify the equivalence of matrices A and Ax ( Ay and Az ).
Theorem 9.
When D rotates by angle ψ around the x axis of B, A = ( Ax ψ ) .
T h e o r e m t h e o r e m 9 : f o r a l l ( a x i s : R A B ) , a x i s = x A = ( A x ψ ) .
Theorem 10.
When D rotates by angle ψ around the x axis of B, B r = ( Ax ψ ) G r .
T h e o r e m t h e o r e m 10 : f o r a l l ( a x i s : R A B ) , a x i s = x B r = ( A x ψ ) × G r .
Theorem 11.
When D rotates by angle θ around the y axis of B, A = ( Ay θ ) .
T h e o r e m t h e o r e m 11 : f o r a l l ( a x i s : R A B ) , a x i s = y A = A y θ .
Theorem 12.
When D rotates by angle θ around the y axis of B, B r = ( Ay θ ) G r .
T h e o r e m t h e o r e m 12 : f o r a l l ( a x i s : R A B ) , a x i s = y B r = ( A y θ ) × G r .
Theorem 13.
When D rotates by angle ϕ around the z axis of B, A = ( Az ϕ ) .
T h e o r e m t h e o r e m 13 : f o r a l l ( a x i s : R A B ) , a x i s = z A = ( A z ϕ ) .
Theorem 14.
When D rotates by angle ϕ around the z axis of B, B r = ( Az ϕ ) G r .
T h e o r e m t h e o r e m 14 : f o r a l l ( a x i s : R A B ) , a x i s = z B r = ( A z ϕ ) × G r .
After D performs a finite number of continuous rotations, A 1 , A 2 , A 3 , , An , around R A B , the equivalence relation between r in B and G is given by Formula (10):
B r = ( A n ( A 2 ( A 1 G r ) ) ) .
Similar to the definition of C R G , we formally define Formula (10) in C R B , where G r is the vector initial position, and function g e t _ A provides the corresponding rotation matrix according to the rotation type and angle:
F i x p o i n t C R B ( r l : l i s t ( R A B R ) ) ( G r : R _ v e c t o r 3 ) : = m a t c h r l w i t h | n i l G r | h : : l l e t M = ( g e t _ A ( f s t h ) ( s n d h ) ) i n l e t G r = M × G r i n C R B l G r e n d . D e f i n i t i o n g e t _ A ( a x i s ) ( θ ) : = m a t c h a x i s w i t h | x ( A x θ ) | y ( A y θ ) | z ( A z θ ) e n d .
We synthesize the finite continuous rotations around R A B into one rotation around a specific line in B. The synthesized rotation matrix is called the local rotation matrix ( B A G ), and is given by Formula (11):
B A G = A n A 2 A 1 B r = B A G G r
We formally define B A G as follows, where function C m l represents the left multiplication of the rotation matrix in list m l :
D e f i n i t i o n B A G ( m l : l i s t ( R A B R ) ) : = ( f i x C m l ( m a t L i s t : l i s t ( R A B R ) ) ( r e s : M a t R 3 3 ) { s t r u c t m a t L i s t } : M a t R 3 3 : = m a t c h m a t L i s t w i t h | [ ] r e s | h : : l C m l l ( g e t _ A ( f s t h ) ( s n d h ) × r e s ) e n d ) m l ( R M a t r i x . M I 3 ) .
Based on this definition, we use a formal method to verify Formula (15), as shown in l e m m a 8 :
Lemma 8.
When r l = [ A 1 A 2 A n ] is an arbitrary rotation sequence, r is the initial location in G, ( A n ( A 2 ( A 1 r ) ) ) = ( A n A 2 A 1 ) r .
L e m m a l e m m a 8 : f o r a l l ( r l : l i s t ( R A B R ) ) ( r : ( R _ v e c t o r 3 ) ) , C R B r l r = ( B A G r l ) × r .

5.2.3. Relationship between B A G and G Q B

From Formulas (9) and (11), the relationship between B A G and G Q B is given by Formula (12):
B r = B A G G Q B B r G r = G Q B B A G G r
For Formula (12), we use l e m m a 9 and l e m m a 10 to prove the inverse of G Q B and B A G , where r L B and r L G are lists. The list order is the same as the matrix rotation order, and R M a t r i x . M I 3 represents an identity matrix with dimension 3.
Lemma 9.
For any non-zero vector r, G Q B is the revolution matrix of B G and B A G is the rotation matrix of G B , then B A G G Q B = I .
L e m m a l e m m a 9 : | B r | < > 0 ( B A G r L B ) × ( G Q B r L G ) = R M a t r i x . M I 3 .
Lemma 10.
For any non-zero vector r, G Q B is the revolution matrix of B G and B A G is the rotation matrix of G B , then G Q B B A G = I .
L e m m a l e m m a 10 : | G r | < > 0 ( G Q B r L G ) × ( B A G r L B ) = R M a t r i x . M I 3 .
Similar to the proof of the inverses of G Q B and B A G , we verify the transpose of G Q B and B A G . The formal definition of transpose is as follows, where t r a n s represents the transpose operation of the matrix, and r e v represents the inverse operation of the list:
Lemma 11.
G Q B is the revolution matrix of B G and B A G is the rotation matrix of G B , then G Q B = B A G T .
L e m m a L e m m a 11 : G Q B r L G = t r a n s R 0 ( B A G ( r e v r L B ) ) .
Lemma 12.
G Q B is the revolution matrix of B G and B A G is the rotation matrix of G B , then B A G = G Q B T .
L e m m a L e m m a 12 : B A G r L B = t r a n s R 0 ( G Q B ( r e v r L G ) ) .

6. Euler Angles

In a three-dimensional (3D) space, the orientation of any coordinate system can be represented by Euler angles. The global coordinate system is assumed to be stationary, whereas the local coordinate system rotates with the rigid body. Euler angles are described by three independent parameters that determine the position of a fixed-point rotating rigid body through its precession, nutation, and rotation angles. Figure 5 shows the geometric representation of the Euler angles in space, where X, Y, and Z are the axes of the global coordinate system, and x, y, and z are the axes of the local coordinate system. Additionally, N is the intersection line of X Y _ p l a n e and x y _ p l a n e .
There is no consensus on the convention for Euler angles in different fields. Hence, their use requires specifying one. In this paper, we formally define and verify commonly used Euler angle conventions.

6.1. Euler Angles per the x y z Convention

The angles obtained from the x y z convention are also called “Tait—Bryan’’ angles, and they often appear in engineering applications to describe the direction of mobile vehicles or missiles. The three angles reflect the roll about the rotation of the airframe axis, the pitch describing the rotation perpendicular to the airframe axis, and the yaw describing the rotation of the vertical axis. In Figure 6, the rotations around the x, y, and z axes are called “roll” ( ψ ), “pitch” ( θ ), and “yaw” ( ϕ ), respectively.
Based on Formula (15), the roll–pitch–yaw rotation matrix is given by Formula (13):
BAG _ rpy = A ( z , ϕ ) A ( y , θ ) A ( x , ψ ) .
According to the physical meaning of roll, pitch, and yaw, we provide the following formal definition:
V a r i a b l e ψ θ ϕ : R . D e f i n d e t i o n B A G _ r p y : = ( A z ϕ ) × ( ( A y θ ) × ( A x ψ ) ) .
Next, we prove the equivalence of B A G _ r p y in l e m m a 13 so that the roll–pitch–yaw sequence can be transformed into a rotation matrix.
Lemma 13.
Formal verification of Formula (13).
L e m m a l e m m a 13 : B A G _ r p y = m k M a t _ 3 _ 3 ( c o s ϕ c o s θ ) ( s i n ϕ c o s ψ + c o s ϕ s i n θ s i n ψ ) ( s i n ϕ s i n ψ c o s ϕ s i n θ c o s ψ ) ( ( s i n ϕ c o s θ ) ) ( c o s ϕ c o s ψ s i n ϕ s i n θ s i n ψ ) ( c o s ϕ s i n ψ + s i n ϕ s i n θ c o s ψ ) ( s i n θ ) ( c o s θ s i n ψ ) ( c o s θ c o s ψ ) .

6.2. Euler Angles per the z x z Convention

Using the z x z convention, precession is the rotation around the z axis, nutation is the rotation around the x axis, and spin is another rotation around the z axis. Its rotation matrix is given by Formula (14), where α is the precession angle, ψ is the nutation angle, and ϕ is the rotation angle:
E u l e r _ z x z = A ( z , ϕ ) A ( x , ψ ) A ( z , α ) .
Our formal proof of the rotation matrix reflecting Euler angles is as follows:
Lemma 14.
Formal verification of Formula (14).
L e m m a l e m m a 14 : E u l e r _ z x z = m k M a t _ 3 _ 3 ( c o s ϕ c o s α s i n ϕ c o s ψ s i n α ) ( c o s ϕ s i n α + s i n ϕ c o s ψ c o s α ) ( s i n ϕ s i n ψ ) s i n ϕ c o s α c o s ϕ c o s ψ s i n α ) ( s i n ϕ s i n α + c o s ϕ c o s ψ c o s α ) ( c o s ϕ s i n ψ ) ( s i n ψ s i n α ) ( s i n ψ c o s α ) ( c o s ψ ) .
Based on precession angle α , nutation angle ψ , and rotation angle ϕ , we can calculate the overall rotation matrix according to l e m m a 14 . Given a rotation matrix, we can recover the Euler angles. For example, Formula (15) describes the solution for precession angle α from a rotation matrix:
α = arctan ( E u l e r _ z x z 31 / E u l e r _ z x z 32 ) π , π α < π / 2 , arctan ( E u l e r _ z x z 31 / E u l e r _ z x z 32 ) , π / 2 α < π / 2 , arctan ( E u l e r _ z x z 31 / E u l e r _ z x z 32 ) + π , π / 2 α < π .
We formally verify the precession angle solution as follows, where l e m m a 15 l e m m a 18 represent the verification of α in the first–fourth quadrants, respectively.
D e f i n i t i o n r ( i j : n a t ) : = m a t _ n t h E u l e r _ z x z ( i 1 ) ( j 1 ) .
Lemma 15.
In the domain of definition [ 0 , π / 2 ) , α = arctan ( r 31 / r 32 ) .
L e m m a l e m m a 15 : 0 < = α < P I / 2 c o s α < > 0 α = a t a n ( ( r 3 1 ) / ( r 3 2 ) ) .
Lemma 16.
In the domain of definition [ π / 2 , π / 2 ) , α = arctan ( r 31 / r 32 ) + π .
L e m m a l e m m a 16 : P I / 2 < = α < P I c o s α < > 0 α = a t a n ( ( r 3 1 ) / ( r 3 2 ) ) + P I .
Lemma 17.
In the domain of definition [ π , π / 2 ) , α = arctan ( r 31 / r 32 ) π .
L e m m a l e m m a 17 : P I < = α < ( P I / 2 ) c o s α < > 0 α = a t a n ( ( r 3 1 ) / ( r 3 2 ) ) P I .
Lemma 18.
In the domain of definition [ π / 2 , 0 ) , α = arctan ( r 31 / r 32 ) .
L e m m a l e m m a 18 : ( P I / 2 ) < = α < 0 c o s α < > 0 α = a t a n ( ( r 3 1 ) / ( r 3 2 ) ) .
Formula (16) describes the solution for nutation angle ψ , given a rotation matrix:
ψ = arccos ( E u l e r _ z x z 33 ) , π ψ < 0 , arccos ( E u l e r _ z x z 33 ) , 0 ψ < π .
Then, the formal verification of the nutation angle solution is expressed as
Lemma 19.
In the domain of definition [ 0 , π ) , ψ = arccos ( r 33 ) .
L e m m a l e m m a 19 : 0 < = ψ < P I ψ = a c o s ( r 3 3 ) .
Lemma 20.
In the domain of definition [ π , 0 ) , ψ = arccos ( r 33 ) .
L e m m a l e m m a 20 : P I < = ψ < 0 ψ = a c o s ( r 3 3 ) .
Finally, Formula (17) describes the solution for rotation angle ϕ , given a rotation matrix:
ϕ = arctan ( E u l e r _ z x z 13 / E u l e r _ z x z 23 ) π , π ϕ < π / 2 , arctan ( E u l e r _ z x z 13 / E u l e r _ z x z 23 ) , π / 2 < ϕ < π / 2 , arctan ( E u l e r _ z x z 13 / E u l e r _ z x z 23 ) + π , π / 2 < ϕ < π .
Accordingly, the formal verification of the rotation angle solution is as follows:
Lemma 21.
In the domain of definition [ 0 , π / 2 ) , ϕ = arctan ( r 13 / r 23 ) .
L e m m a l e m m a 21 : 0 < = ϕ < P I / 2 c o s ϕ < > 0 ϕ = a t a n ( ( r 1 3 ) / ( r 2 3 ) ) .
Lemma 22.
In the domain of definition [ π / 2 , π ) , ϕ = arctan ( r 13 / r 23 ) + π .
L e m m a l e m m a 22 : P I / 2 < ϕ < P I c o s ϕ < > 0 ϕ = a t a n ( ( r 1 3 ) / ( r 2 3 ) ) + P I .
Lemma 23.
In the domain of definition [ π , π / 2 ) , ϕ = arctan ( r 13 / r 23 ) π .
L e m m a l e m m a 23 : P I < = ϕ < ( P I / 2 ) c o s ϕ < > 0 ϕ = a t a n ( ( r 1 3 ) / ( r 2 3 ) ) P I .
Lemma 24.
In the domain of definition [ π / 2 , 0 ) , ϕ = arctan ( r 13 / r 23 ) .
L e m m a l e m m a 24 : ( P I / 2 ) < ϕ < 0 c o s ϕ < > 0 ϕ = a t a n ( ( r 1 3 ) / ( r 2 3 ) ) .

7. Rodriguez Formula

For a rigid body with fixed point O, a revolution by angle, ϕ , around ξ in G can be decomposed into revolutions around three specific non-coplanar axes. On the contrary, after a rigid body rotates for a finite number of times, its revolution effect is equivalent to a specific revolution around a specific axis. The Rodriguez formula is a simple and effective way to describe such revolutions.

7.1. Proof of the Existence of the Rodriguez Formula

Let ξ be a line passing through origin O in G and the rigid body that rotates by angle ϕ around ξ . We denote the direction vector of ξ as u. The revolution of the rigid body around u is equivalent to the following process: (1) Rotate one axis in B to coincide with u; (2) B rotates ϕ around u; (3) B performs a revolution inverse to that in Step 1. We rotate the z axis in B to coincide with u, as shown in Figure 7.
In Figure 7, the rigid body first rotates by angle ϑ around the z axis and then by angle φ around the y axis, such that the z axis coincides with u. Then, it rotates by angle ϕ around the z axis and finally rotates in the reverse sequence. The corresponding revolution is shown in Formula (18), where G R B is the revolution matrix of B G :
G R B = G Q B = B A G T
= ( ( Az ( φ ) ) × ( Ay ( ϑ ) ) × ( Az ϕ ) × ( Ay ϑ ) × ( Az φ ) ) T
s . t . s i n φ = u 2 u 1 2 + u 2 2 c o s φ = u 1 u 1 2 + u 2 2 s i n ϑ = u 1 2 + u 2 2 c o s ϑ = u 3
With this corollary, we can assume that the z axis coincides with u after two rotations. We use a formalization to verify this assumption.
Lemma 25.
There are angles φ and ϑ such that direction vector [ 0 0 1 ] of the z axis coincides with u in G after two rotations.
L e m m a l e m m a 25 : B r = m k M a t _ 3 _ 1 0 0 1 e x i s t s ( ϕ θ : R ) , u = t r a n s R 0 ( ( A y θ ) × ( A z ϕ ) ) × B r .
According to Formula (18), we assume the equivalence of G R B and solve the matrix form of G R B under constraints:
V a r i a b l e ϕ θ : R . H y p o t h e s i s G R B _ H y : G R B = t r a n s R 0 ( ( A z ( ϕ ) ) × ( A y ( θ ) ) × ( A z ϕ ) × ( A y θ ) × ( A z ϕ ) ) . H y p o t h e s i s u _ l e n : | u | = 1 . D e f i n i t i o n v e r s ( x : R ) : = 1 ( c o s x ) .
Lemma 26.
Formal verification of Formula (18)
L e m m a l e m m a 26 : s i n ϕ = u 2 / s q r t ( u 1 2 + u 2 2 ) c o s ϕ = u 1 / s q r t ( u 1 2 + u 2 2 ) s i n θ = s q r t ( u 1 2 + u 2 2 ) c o s θ = u 3 G R B = m k M a t _ 3 _ 3 ( u 1 2 ( v e r s ϕ ) + c o s ϕ ) ( u 1 u 2 ( v e r s ϕ ) u 3 s i n ϕ ) ( u 1 u 2 ( v e r s ϕ ) + u 3 s i n ϕ ) ( u 2 2 ( v e r s ϕ ) + c o s ϕ ) ( u 1 u 3 ( v e r s ϕ ) u 2 s i n ϕ ) ( u 2 u 3 ( v e r s ϕ ) + u 1 s i n ϕ ) ( u 1 u 3 ( v e r s ϕ ) + u 2 s i n ϕ ) ( u 2 u 3 ( v e r s ϕ ) u 1 s i n ϕ ) ( u 3 2 ( v e r s ϕ ) + c o s ϕ ) .

7.2. Formal Definition of the Rodriguez Formula

In l e m m a 25 , we proved that for any revolution axis, u, passing through the origin, it is always possible to match the u and z axes after two rotations. In l e m m a 26 , we verified the equivalent form of revolution matrix G R B under constraints. Using l e m m a 26 , the Rodriguez formula can be deduced as shown in Formula (19) for direction vector u:
I = 1 0 0 0 1 0 0 0 1 u = u 1 u 2 u 3 u ^ = 0 u 3 u 2 u 3 0 u 1 u 2 u 1 0 R ( u , ϕ ) = G R B = ( c o s ϕ ) I + ( 1 c o s ϕ ) u u T + ( s i n ϕ ) u ^ .
Generally, for any non-zero vector, ξ , its direction vector is e u = ξ | ξ | .
According to Formula (19), we formally define the Rodriguez formula as E L R . In the definition of E L R , ϕ represents the revolution angle, and ξ represents any non-zero revolution axis:
D e f i n i t i o n I : = R M a t r i x . M I 3 . D e f i n i t i o n ξ _ t i l d e ( ξ : M a t R 3 1 ) : = m k M a t _ 3 _ 3 0 ( ( m a t _ n t h ξ 2 0 ) ) ( m a t _ n t h ξ 1 0 ) ( m a t _ n t h ξ 2 0 ) 0 ( ( m a t _ n t h ξ 0 0 ) ) ( ( m a t _ n t h ξ 1 0 ) ) ( m a t _ n t h ξ 0 0 ) 0 . D e f i n i t i o n E L R ( ϕ : R ) ( ξ : M a t R 3 1 ) : = m a t c h R e q _ E M _ T ( | ξ | ) 1 w i t h | l e f t _ = > [ ( c o s ϕ ) × I ] + [ ( v e r s ϕ ) × [ ξ × ( t r a n s R 0 ξ ) ] ] + [ ( s i n ϕ ) × ( ξ _ t i l d e ξ ) ] | r i g h t _ = > l e t ξ : = [ ( 1 / | ξ | ) × ξ ] i n [ ( c o s ϕ ) × I ] + [ ( v e r s ϕ ) × [ ξ × ( t r a n s R 0 ξ ) ] ] + [ ( s i n ϕ ) × ( ξ _ t i l d e ξ ) ] e n d .  

7.3. Equivalence between the Rodriguez Formula and a Revolution around R A G

The Rodriguez formula applies to a rigid body rotating around ξ , a vector in G. When ξ coincides with the X axis (Y or Z axes), E L R is equivalent to revolution matrix Q around R A G .
Lemma 27.
When ξ = [ x , 0 , 0 ] and u = ξ / | ξ | , R ( u , ϕ ) = Q X ϕ .
L e m m a l e m m a 27 : f o r a l l x : R , x < > 0 ξ = m k M a t _ 3 _ 1 x 0 0 E L R ϕ ξ = Q X ϕ .
Lemma 28.
When ξ = [ 0 , y , 0 ] and u = ξ / | ξ | , R ( u , ϕ ) = Q Y ϕ .
L e m m a l e m m a 28 : f o r a l l y : R , y < > 0 ξ = m k M a t _ 3 _ 1 0 y 0 E L R ϕ ξ = Q Y ϕ .
Lemma 29.
When ξ = [ 0 , 0 , z ] and u = ξ / | ξ | , R ( u , ϕ ) = Q Z ϕ .
L e m m a l e m m a 29 : f o r a l l z : R , z < > 0 ξ = m k M a t _ 3 _ 1 0 0 z E L R ϕ ξ = Q Z ϕ .
l e m m a 27 indicates that when the revolution axis coincides with the X axis, the Rodriguez formula describes a revolution around the X axis. Similarly, l e m m a 28 and l e m m a 29 show that when the revolution axis coincides with the Y and Z axes, respectively, the Rodriguez formula describes revolutions around R A G .

7.4. Non-Uniqueness of the Revolution Axis and Angle

Using E L R , we can obtain the corresponding revolution matrix, G R B , given revolution angle ϕ and revolution axis ξ . Conversely, for the given G R B , we can obtain ϕ and u (i.e., the direction vector of ξ ). This is shown in Formula (20), where G R B 10 denotes the element at position (1,0) in G R B :
u ^ = 1 2 s i n ϕ ( G R B G R B T ) s i n ϕ = ( G R B 10 G R B 01 ) + ( G R B 02 G R B 20 ) + ( G R B 21 G R B 12 ) 2 ( u 1 + u 2 + u 3 ) c o s ϕ = 1 2 ( t r ( G R B ) 1 )
From Formula (20), the solutions of ϕ and ξ are non-unique for the given G R B . We formally verify the non-uniqueness of the solution in l e m m a 30 and l e m m a 31 :
Lemma 30.
When ξ is any non-zero vector and u = ξ / | ξ | , R ( u , ϕ ) = R ( u , ϕ )
L e m m a l e m m a 30 : f o r a l l ( ϕ : R ) ( ξ : M a t R 3 1 ) , E L R ϕ ξ = E L R ( ϕ ) ( ξ ) ,
Lemma 31.
When ξ is any non-zero vector and u = ξ / | ξ | , R ( u , ϕ ) = R ( u , ϕ + 2 π )
L e m m a l e m m a 31 : f o r a l l ( ϕ : R ) ( ξ : M a t R 3 1 ) , E L R ϕ ξ = E L R ( ϕ + 2 P I ) ( ξ ) .
l e m m a 30 shows that when the rigid body revolution by angle ϕ around ξ , the revolution is equivalent to a revolution by angle ϕ around ξ . This equivalence relation is obvious in a geometric proof. l e m m a 30 proves this equivalence through the formal method. Similarly, l e m m a 31 shows that when the revolution angle increases by 2 π , the revolution matrix is equivalent.

7.5. Generalized Rodriguez Formula

The formal verification of the Rodriguez formula assumed that B and G coincide initially. That is, in the initial state, r has an equivalence in G and B. More generally, B and G need not coincide initially, as shown in Formula 22, where B R G is the revolution matrix.
B r = B R G G r .
When the initial state coordinate systems do not coincide, to obtain the Rodriguez formula, we assume a new global coordinate system, G 0 , which coincides with B initially. Therefore, transformation B G of r is decomposed into B G 0 and G 0 G .
To obtain the revolution matrix of B G 0 , we apply the Rodriguez formula. The revolution axis should be represented in u 0 , as shown in Formula (22), where u ( | u | = 1 ) is the revolution axis in G, 0 R B is the revolution matrix of B G 0 , and ϕ is the revolution angle.
0 R G = B R G u 0 = 0 R G u 0 R B = c o s ϕ I + ( v e r s ϕ ) u 0 u 0 T + ( s i n ϕ ) u 0 ^ = c o s ϕ I + ( v e r s ϕ ) ( 0 R G u ) ( 0 R G u ) T + ( s i n ϕ ) 0 R G u ^ 0 R G T = c o s ϕ I + ( v e r s ϕ ) ( 0 R G u ) u T 0 R G T + ( s i n ϕ ) 0 R G u ^ 0 R G T
Therefore, the revolution matrix of B G in the final state is given by Formula (23), where G R 0 = 0 R G T can be obtained from l e m m a 11 and l e m m a 12 . Similarly, G R 0 0 R G T = I can be obtained from l e m m a 9 and l e m m a 10 .
G R 0 = 0 R G T G R B = G R 0 0 R B = c o s ϕ G R 0 + ( v e r s ϕ ) u u T G R 0 + ( s i n ϕ ) u ^ G R 0 = R ( u , ϕ ) G R 0
We use the formal methods to infer and verify Formula (23). First, we formally define revolution axis u, revolution angle ϕ , and revolution matrix _ 0 R G of G B (in the initial state) and set the length of u to one.
V a r i a b l e u : M a t R 3 1 . V a r i a b l e ϕ : R . V a r i a b l e _ 0 R G : M a t R 3 3 . H y p o t h e s i s u _ l e n : | u | = 1 .
Second, according to l e m m a 11 , we define revolution matrix G R 0 of B G in the initial state.
L e t G R 0 : = t r a n s R 0 _ 0 R G .
Again, according to Formula (22), we redefine revolution axis _ 0 u in G 0 :
L e t _ 0 u : = 0 R G × u . L e t _ 0 R B : = E L R ϕ _ 0 u .
Finally, we formally define revolution matrix G R B for B G 0 G :
L e t G R B : = G R 0 × _ 0 R B .
Based on this definition, a formal proof of the equivalence relation in Formula (23) is provided in l e m m a 32 :
Lemma 32.
Formal verification of Formula (23).
L e m m a l e m m a 32 : G R B = E L R ϕ u × G R 0 .

8. Case Analysis and Verification

In this section, we analyze and prove several cases related to robot rotations to show the applicability of our formal verification of designed robots.

8.1. Revolution around the Global Coordinate System

Case 1: In the initial state, G coincides with B. Let rigid body D, represented in B, rotate continuously around the X axis of G at an angular velocity of 0.6 π r a d / s along with point P B = [ 10 , 20 , 30 ] T in rigid body D. We illustrate the calculation of position P G of point P B , represented in G, at t = 5 s.
S e c t i o n E x a m p l e 1 . V a r i a b l e δ t δ θ : R . V a r i a b l e a x i s : R A G . E x a m p l e E g _ 1 : B r = m k M a t _ 3 _ 1 R 10 20 30 δ t = 5 ω δ t δ θ = 0.6 P I a x i s = X G r = m k M a t _ 3 _ 1 R ( 10 ) 20 ( 30 ) . P r o o f . Q e d . E n d E x a m p l e 1 .
For this case, we obtain solution P G = [ 10 , 20 , 30 ] T via the informal method. For the formal method, we apply the formal verification shown above, where δ t is the time variable, δ θ is the revolution angle variable, and a x i s is the revolution axis variable. From E g _ 1 , we observe that the solution to this case is [ 10 , 20 , 30 ] T , as expected.

8.2. Rotation around the Local Coordinate System

Case 2: In the initial state, G coincides with B. Let rigid body D, represented in G, first rotate by π / 4 around the z axis and then rotate by π / 4 around the x axis to finally rotate by π / 4 around the y axis in B along with point P G = [ 10 , 20 , 30 ] T in rigid body D. We illustrate the calculation of position P B of point P G , represented in B, after rotation.
Similar to case 1, we obtain solution [ 5 2 / 2 , 5 + 15 2 , 30 5 2 / 2 ] T using the informal method. For the formal method, we show the formal verification below, where r o t L i s t is a list corresponding to the rotation order. From E g _ 2 , the solution to this case is 5 2 / 2 , 5 + 15 2 , 30 5 2 / 2 T , as expected.
S e c t i o n E x a m p l e 2 . V a r i a b l e r o t L i s t : l i s t ( R A B R ) . E x a m p l e E g _ 2 : r o t L i s t = ( p a i r z ( P I / 4 ) ) : : ( p a i r x ( P I / 4 ) ) : : ( p a i r y ( P I / 4 ) ) : : n i l C R B r o t L i s t ( m k M a t _ 3 _ 1 R 10 20 30 ) = m k M a t _ 3 _ 1 R ( 5 s q r t 2 / 2 ) ( 5 + 15 s q r t 2 ) ( 30 5 s q r t 2 / 2 ) . P r o o f . Q e d . E n d E x a m p l e 2 .

8.3. Euler Angle Cases

Case 3: Given precession angle α = π / 4 , nutation angle ψ = π / 4 , and rotation angle ϕ = π / 4 , we determine the corresponding Euler angle rotation matrix.
To obtain the rotation matrix from the given Euler angles, we can use l e m m a 14 to complete the formal verification with the following script:
E x a m p l e E g _ 3 : f o r a l l α ψ ϕ : R , α = P I / 4 ψ = P I / 4 ϕ = P I / 4 E u l e r _ z x z α ψ ϕ = m k M a t _ 3 _ 3 ( 1 / 2 s q r t 2 / 4 ) ( 1 / 2 + s q r t 2 / 4 ) ( 1 / 2 ) ( 1 / 2 s q r t 2 / 4 ) ( 1 / 2 + s q r t 2 / 4 ) ( 1 / 2 ) ( 1 / 2 ) ( 1 / 2 ) ( s q r t 2 / 2 ) . P r o o f . Q e d .
Our analysis of the Euler angles for a given rotation matrix is shown below.
Case 4: Given the rotation matrix in Formula (24), we determine the corresponding Euler angles:
E u l e r _ z x z = 1 2 2 4 1 2 + 2 4 1 2 1 2 2 4 1 2 + 2 4 1 2 1 2 1 2 2 2 .
For this type of case, we can use l e m m a 15 l e m m a 26 for verification, as follows:
E x a m p l e E g _ 4 : f o r a l l α ψ ϕ : R , 0 < = α < P I / 2 0 < = ψ < P I / 2 0 < = ϕ < P I / 2 E u l e r _ z x z α ψ ϕ = m k M a t _ 3 _ 3 ( 1 / 2 s q r t 2 / 4 ) ( 1 / 2 + s q r t 2 / 4 ) ( 1 / 2 ) ( 1 / 2 s q r t 2 / 4 ) ( 1 / 2 + s q r t 2 / 4 ) ( 1 / 2 ) ( 1 / 2 ) ( 1 / 2 ) ( s q r t 2 / 2 ) α = P I / 4 ψ = P I / 4 ϕ = P I / 4 . P r o o f . Q e d .

8.4. Rodriguez Revolutions

Case 5: Let local coordinate system B rotate by three Euler angles ( π 4 , π 4 , π 4 ) with respect to global coordinate system G. We determine revolution axis u and revolution angle ϕ equivalent to that revolution.
E x a m p l e E g _ 5 : s i n ϕ < > 0 G R B = E L R ϕ u θ 1 = P I / 4 θ 2 = P I / 4 θ 3 = P I / 4 B R G = E u l e r θ 1 θ 2 θ 3 u = m k M a t _ 3 _ 1 ( s q r t 2 / s q r t ( 5 + 2 s q r t 2 ) ) 0 ( ( 4 s q r t 2 + 4 ) / ( 4 s q r t ( 5 + 2 s q r t 2 ) ) ) u = m k M a t _ 3 _ 1 ( ( s q r t 2 / s q r t ( 5 + 2 s q r t 2 ) ) ) 0 ( ( ( 4 s q r t 2 + 4 ) / ( 4 s q r t ( 5 + 2 s q r t 2 ) ) ) ) P r o o f . Q e d .
Case 6: Let a rigid body rotate by π / 6 around the X axis, and suppose the rigid body continues to rotate by p h i = π / 2 around u = [ 3 / 3 , 3 / 3 , 3 / 3 ] . We determine the corresponding revolution matrix, G R B .
For this type of case, we can use l e m m a 32 for verification, as follows:
L e t u : = m k M a t _ 3 _ 1 ( s q r t 3 / 3 ) ( s q r t 3 / 3 ) ( s q r t 3 / 3 ) . L e t ϕ : = P I / 2 . L e t 0 R G : = Q X ( P I / 6 ) . L e t G R 0 : = t r a n s R 0 0 R G . L e t 0 u : = 0 R G × u . L e t 0 R B : = E L R ϕ 0 U . L e t G R B : = G R 0 × 0 R B . E x a m p l e E g _ 6 : G R B = m k M a t _ 3 _ 3 ( 1 / 3 ) ( ( 2 / 3 ) ) ( 2 / 3 ) ( s q r t 3 / 3 + 1 / 3 ) ( s q r t 3 / 3 1 / 6 ) ( s q r t 3 / 6 1 / 3 ) ( ( s q r t 3 / 3 ) + 1 / 3 ) ( s q r t 3 / 6 + 1 / 3 ) ( s q r t 3 / 3 + 1 / 6 ) . P r o o f . Q e d .

9. Conclusions

As one of the most basic theories in motion control systems, rotary kinesthetics is widely used in different research topics. In this paper, the formal technology was applied to verify the correctness of robot rotary motion theory. We divided rotary motion into two types (i.e., revolution and rotation) and defined them formally. Specifically, we established a 3D coordinate system model in the Coq Proof Assistant and formally defined the matrix trace, Frobenius norm, and inner product in the model. We formalized the definition of Euler angle and verified its transformation relationship with the rotation matrix. Moreover, we completed the machine proof of the Rodriguez formula. In this paper, all proofs and verifications were implemented using the Coq Proof Assistant. All source files are accessible at https://github.com/GuojunXie123/RFV.git (accessed on 7 January 2023).
Overall, the proofs of the formal verification consist of about 3200 lines of code. The code has been tested and should compile under Coq 8.13.2. Table 1 provides a detailed account of the formalization in terms of script files. To help navigate through them, we indicate the related sections in the paper. The count in terms of lines of code distinguishes between specifications and proofs.
In the future, we will complete the verification of more robot control technologies based on the formal verification framework of this paper. With more complex kinematic logic, we will improve the formal verification framework of more types of robot kinematics. Our goal is to complete the formal verification of a robot control system. We also plan to develop some automatic tactics that can be used to increase the automation of formal proofs. This will be a meaningful exploration and a worthwhile attempt in the field of automated control system verification. Additionally, we will also try to combine the technologies of code generation and formal verification. We plan to design a robot control algorithm and automatically generate the C code using Coq Proof Assistant. This is expected to vastly improve the safety assurance of robot control systems.

Author Contributions

Conceptualization, methodology, and validation, G.X. and H.D.; formal analysis and investigation, G.X. and Z.S.; writing–original draft preparation, G.X.; writing–review and editing, H.Y. and G.C.; supervision, G.C. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The data presented in this study are openly available in [github] at [https://github.com/GuojunXie123/RFV.git].

Acknowledgments

The authors are grateful to the anonymous reviewers for their helpful comments and valuable suggestions that led to a significant improvement in the manuscript.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Shen, Y.; Jia, Q.; Huang, Z.; Wang, R.; Fei, J.; Chen, G. Reinforcement learning-based reactive obstacle avoidance method for redundant manipulators. Entropy 2022, 24, 279. [Google Scholar] [CrossRef] [PubMed]
  2. Sun, T.; Yu, W. A formal verification framework for security issues of blockchain smart contracts. Electronics 2020, 9, 255. [Google Scholar] [CrossRef] [Green Version]
  3. Selsam, D.; Liang, P.; Dill, D.L. Developing bug-free machine learning systems with formal mathematics. In Proceedings of the International Conference on Machine Learning, Vienna, Austria, 12 July 2020. [Google Scholar]
  4. Xu, J.; Yu, Z.; Ni, B.; Yang, J.; Yang, X.; Zhang, W. Deep kinematics analysis for monocular 3D human pose estimation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Washington, DC, USA, 14 June 2020. [Google Scholar]
  5. Korovesis, N.; Kandris, D.; Koulouras, G.; Alexandridis, A. Robot motion control via an EEG-based brain–computer interface by using neural networks and alpha brainwaves. Electronics 2019, 8, 1387. [Google Scholar] [CrossRef] [Green Version]
  6. Yang, K.; Deng, J. Learning to prove theorems via interacting with proof assistants. In Proceedings of the International Conference on Machine Learning, Taiyuan, China, 8 November 2019. [Google Scholar]
  7. Zholtkevych, G. Event universes: Specification and analysis using Coq Proof Assistant. In Proceedings of the ICTERI Workshops, Kherson, Ukraine, 12 June 2019. [Google Scholar]
  8. Vu, V.H. Recent progress in combinatorial random matrix theory. Probab. Surv. 2021, 18, 179–200. [Google Scholar] [CrossRef]
  9. Dou, R.; Yu, S.; Li, W.; Chen, P.; Xia, P.; Zhai, F.; Yokoi, H.; Jiang, Y. Inverse kinematics for a 7-DOF humanoid robotic arm with joint limit and end pose coupling. Mech. Mach. Theory 2022, 169, 104637. [Google Scholar] [CrossRef]
  10. Alkassar, E.; Böhme, S.; Mehlhorn, K.; Rizkallah, C. A framework for the verification of certifying computations. J. Autom. Reason. 2014, 52, 241–273. [Google Scholar] [CrossRef] [Green Version]
  11. Ben Hafaiedh, I.; Ben Hamouda, R.; Robbana, R. A model-based approach for formal verification and performance analysis of dynamic load-balancing protocols in cloud environment. Clust. Comput. 2021, 24, 2977–2994. [Google Scholar] [CrossRef]
  12. Vicentini, F.; Askarpour, M.; Rossi, M.G.; Mandrioli, D. Safety assessment of collaborative robotics through automated formal verification. IEEE Trans. Robot. 2019, 36, 42–61. [Google Scholar] [CrossRef]
  13. Foughali, M.; Zuepke, A. Formal verification of real-time autonomous robots: An interdisciplinary approach. Front. Robot. AI 2022, 9, 1–25. [Google Scholar] [CrossRef] [PubMed]
  14. Chen, S.; Wang, G.; Li, X.; Zhang, Q.; Shi, Z.; Guan, Y. Formalization of camera pose estimation algorithm based on Rodrigues formula. Form. Asp. Comput. 2020, 32, 417–437. [Google Scholar] [CrossRef]
  15. Carvalho, R.; Cunha, A.; Macedo, N.; Santos, A. Verification of system-wide safety properties of ROS applications. In Proceedings of the International Conference on Intelligent Robots and Systems, Las Vegas, NV, USA, 24 October 2020. [Google Scholar]
  16. Kortik, S.; Shastha, T.K. Formal verification of ROS-based systems using a linear logic theorem prover. In Proceedings of the IEEE International Conference on Robotics and Automation, Xi’an, China, 30 May 2021. [Google Scholar]
  17. Murray, Y.; Sirevåg, M.; Ribeiro, P.; Anisi, D.A.; Mossige, M. Safety assurance of an industrial robotic control system using hardware/software co-verification. Sci. Comput. Program. 2022, 216, 102766. [Google Scholar] [CrossRef]
  18. Rathmair, M.; Haspl, T.; Komenda, T.; Reiterer, B.; Hofbaur, M. A formal verification approach for robotic workflows. In Proceedings of the International Conference on Advanced Robotics, Ljubljana, Slovenia, 6 December 2021. [Google Scholar]
  19. Lestingi, L.; Askarpour, M.; Bersani, M.M.; Rossi, M. Formal verification of human-robot interaction in healthcare scenarios. In Proceedings of the International Conference on Software Engineering and Formal Methods, Amsterdam, The Netherlands, 14 September 2020. [Google Scholar]
  20. Praveen, A.T.; Gupta, A.; Bhattacharyya, S.; Muthalagu, R. Assuring behavior of multirobot autonomous systems with translation from formal verification to ROS simulation. IEEE Syst. J. 2022, 16, 5092–5100. [Google Scholar] [CrossRef]
  21. Arnett, T.; Ernest, N.; Kunkel, B.; Boronat, H. Formal verification of a genetic fuzzy system for unmanned aerial vehicle navigation and target capture in a safety corridor. In Proceedings of the North American Fuzzy Information Processing Society Annual Conference, Washington, DC, USA, 20 August 2020. [Google Scholar]
  22. Foughali, M.; Hladik, P.E. Bridging the gap between formal verification and schedulability analysis: The case of robotics. J. Syst. Archit. 2020, 111, 101817. [Google Scholar] [CrossRef]
  23. Fatkina, A.; Iakushkin, O.; Selivanov, D.; Korkhov, V. Methods of formal software verification in the context of distributed systems. In Proceedings of the International Conference on Computational Science and Its Applications, Saint Petersburg, Russia, 1 July 2019. [Google Scholar]
  24. Ma, Z.W.; Chen, G. Matrix formalization based on Coq record. Comput. Sci. 2019, 7, 139–145. [Google Scholar]
  25. Ma, Y.Y.; Chen, G. Coq-based matrix code generation technology. J. Softw. 2022, 33, 2224–2245. [Google Scholar]
  26. Zhang, Y.; Guo, J.; Li, X. Study on redundancy in robot kinematic parameter identification. IEEE Access 2022, 10, 60572–60584. [Google Scholar] [CrossRef]
  27. Ali, Z.A.; Zhangang, H. Maneuvering control of hexrotor UAV equipped with a cable-driven gripper. IEEE Access 2021, 9, 65308–65318. [Google Scholar] [CrossRef]
  28. Shah, K.; Mishra, R. Modelling and optimization of robotic manipulator mechanism for computed tomography guided medical procedure. Sci. Iran. 2022, 29, 543–555. [Google Scholar] [CrossRef]
Figure 1. Formal framework of robot rotary kinematics.
Figure 1. Formal framework of robot rotary kinematics.
Electronics 12 00369 g001
Figure 2. Representation of vectors in different coordinate systems.
Figure 2. Representation of vectors in different coordinate systems.
Electronics 12 00369 g002
Figure 3. Revolution around the (a) X, (b) Y, and (c) Z axes of G.
Figure 3. Revolution around the (a) X, (b) Y, and (c) Z axes of G.
Electronics 12 00369 g003
Figure 4. Rotation around the (a) x, (b) y, and (c) z axes of B.
Figure 4. Rotation around the (a) x, (b) y, and (c) z axes of B.
Electronics 12 00369 g004
Figure 5. Euler angles.
Figure 5. Euler angles.
Electronics 12 00369 g005
Figure 6. Roll, pitch, and yaw angles.
Figure 6. Roll, pitch, and yaw angles.
Electronics 12 00369 g006
Figure 7. Relation diagram of the coordinate system when z and u coincide.
Figure 7. Relation diagram of the coordinate system when z and u coincide.
Electronics 12 00369 g007
Table 1. Overview of the formal verification of robot rotary kinesthetics.
Table 1. Overview of the formal verification of robot rotary kinesthetics.
FileReferenceSpecificationProof
Trace.vSection 4.1330
Norm.vSection 4.28820
DotProduct.vSection 4.311530
DotAngle.vSection 4.410047
Coordinate_Basics.vSection 5.1376350
Rotate_Around_G.vSection 5.2.1290260
Rotate_Around_G_Lemma.vSection 5.2.1320300
Rotate_Around_G_Example.vSection 5.2.1148130
Rotate_Around_B.vSection 5.2.2270240
Rotate_Around_B_Lemma.vSection 5.2.2 and Section 6.1320300
Rotate_Around_B_Exaplme.vSection 5.2.2150130
General_Rotate.vSection 5.2.37060
Relation_GB.vSection 5.2.3130120
Euler_Angle.vSection 6.2180170
RodriguezDef.vSection 7.2260230
RodriguezPf.vSection 7.1115100
RodriguezLem.vSection 7.3 and Section 7.4310300
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Xie, G.; Yang, H.; Deng, H.; Shi, Z.; Chen, G. Formal Verification of Robot Rotary Kinematics. Electronics 2023, 12, 369. https://doi.org/10.3390/electronics12020369

AMA Style

Xie G, Yang H, Deng H, Shi Z, Chen G. Formal Verification of Robot Rotary Kinematics. Electronics. 2023; 12(2):369. https://doi.org/10.3390/electronics12020369

Chicago/Turabian Style

Xie, Guojun, Huanhuan Yang, Hao Deng, Zhengpu Shi, and Gang Chen. 2023. "Formal Verification of Robot Rotary Kinematics" Electronics 12, no. 2: 369. https://doi.org/10.3390/electronics12020369

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